0

Hi found lots and lots of links for video encoding through ffmpeg 1,2,3,4 etc but they all start with using terminal commands but when i try to implement any on terminal like:

git clone git://github.com/lajos/iFrameExtractor.gitit says that-bash: git: command not found.

Also as per my knowledge it is not possible to use terminal command on iPhone. Can anybody point out how to encode a video recorded through ffmpeg in mp4 format and also to reduce the size of the video?Thanks in advance.

EDIT: I am already implementing this method to resize my video and it successfully takes place and I am able to send the video on server but then on server side it's giving problem in retrieving the data and to use it.

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self convertVideoToLowQuailtyWithInputURL:videoURL1 outputURL:[NSURL fileURLWithPath:videoStoragePath] handler:^(AVAssetExportSession *exportSession)
     {
         if (exportSession.status == AVAssetExportSessionStatusCompleted)
         {
             NSLog(@"%@",exportSession.error);
             printf("completed\n");
         }
         else
         {
             NSLog(@"%@",exportSession.error);
             printf("error\n");
         }
     }];
}

- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL 
                                   outputURL:(NSURL*)outputURL 
                                     handler:(void (^)(AVAssetExportSession*))handler
{
    [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
    exportSession.outputURL = outputURL;
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    [exportSession exportAsynchronouslyWithCompletionHandler:^(void) 
     {
         handler(exportSession);
         [exportSession release];
     }];
}
Community
  • 1
  • 1
Yama
  • 2,649
  • 3
  • 31
  • 63

1 Answers1

2

ffmpeg is an obsolete method try AVAssetWriter in AVFoundation framework.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
Tornado
  • 1,069
  • 12
  • 28
  • Thanks Tornado.I have used the uiimagepicker to record the video in my app and now I want to convert it into mp4 format to sent it on server. Is AVFoundation framework a good option for the same? It actually does not give me option to see what I am recording. What should I do for that? – Yama Dec 16 '11 at 07:05
  • i think u can convert format using AVFoundation .... i used it once to record video in mp4 format ...... – Tornado Dec 16 '11 at 07:38
  • hmmm first check on device itself whether the video u have made is playable or fine .. if its ok there then there might be a problem with retrieving code on server – Tornado Dec 16 '11 at 09:34
  • I am able to play from my side. but the .net developer has to convert the video in mp3 format and send it back to me but he says that my encoding method is not supported and hence i am stuck at this point.:( Any solution? – Yama Dec 16 '11 at 09:51
  • hey use AVFileTypeMPEG4 in exportSession.outputFileType = AVFileTypeQuickTimeMovie ..... u are creating .mov format file which ur .net developer is not able manipulate ..... AVFileTypeMPEG4 will create a .mp4 file .... also if possible change ur .net developer as well :P ... – Tornado Dec 16 '11 at 12:25
  • :) Well....as far as conversion is possible,i can try but changing the developer is not in my hand. Also AVFileTypeMPEG4 gives error and app crashes so i kept it as it is and just changed the extension and gave it to d developer. Lets see what's next.. – Yama Dec 16 '11 at 13:02
  • ya with AVFileTypeMPEG4 it gave error so i used that AVFileTypeQuickTimeMovie only and changed the extension as mp4 and with my surprise it worked for me. – Yama Dec 16 '11 at 13:20