Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
Taner Sener edited this page Jul 4, 2019 · 7 revisions
  1. Add MobileFFmpeg dependency to your Podfile in mobile-ffmpeg-<package name> format

    pod 'mobile-ffmpeg-min', '~> 4.2.2'
    
  2. Execute commands.

    #import <mobileffmpeg/MobileFFmpeg.h>
    
    [MobileFFmpeg execute: @"-i file1.mp4 -c:v mpeg4 file2.mp4"];
    
  3. Check execution output.

    int rc = [MobileFFmpeg getLastReturnCode];
    NSString *output = [MobileFFmpeg getLastCommandOutput];
    
    if (rc == RETURN_CODE_SUCCESS) {
        NSLog(@"Command execution completed successfully.\n");
    } else if (rc == RETURN_CODE_CANCEL) {
        NSLog(@"Command execution cancelled by user.\n");
    } else {
        NSLog(@"Command execution failed with rc=%d and output=%@.\n", rc, output);
    }
    
  4. Stop an ongoing operation.

    [MobileFFmpeg cancel];
    
  5. Get media information for a file.

    MediaInformation *mediaInformation = [MobileFFmpeg getMediaInformation:@"<file path or uri>"];
    
  6. Record video and audio using iOS camera.

    [MobileFFmpeg execute: @"-f avfoundation -r 30 -video_size 1280x720 -pixel_format bgr0 -i 0:0 -vcodec h264_videotoolbox -vsync 2 -f h264 -t 00:00:05 %@", recordFilePath];
    
  7. List enabled external libraries.

    NASArray *externalLibraries = [MobileFFmpegConfig getExternalLibraries];
    
  8. Enable log callback.

    - (void)logCallback: (int)level :(NSString*)message {
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"%@", message);
        });
    }
    ...
    [MobileFFmpegConfig setLogDelegate:self];
    
  9. Enable statistics callback.

    - (void)statisticsCallback:(Statistics *)newStatistics {
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"frame: %d, time: %d\n", newStatistics.getVideoFrameNumber, newStatistics.getTime);
        });
    }
    ...
    [MobileFFmpegConfig setStatisticsDelegate:self];
    
  10. Set log level.

    [MobileFFmpegConfig setLogLevel:AV_LOG_FATAL];
    
  11. Register custom fonts directory.

    [MobileFFmpegConfig setFontDirectory:@"<folder with fonts>" with:nil];
    
Clone this wiki locally