Giter Site home page Giter Site logo

ffmpegwrapper's Introduction

FFmpegWrapper

FFmpegWrapper is a lightweight Objective-C wrapper for some FFmpeg libav functions.

Installation

Note: This project includes FFmpeg-iOS as submodule which you will need to build separately.

  1. Add this as a git submodule to your project.

     $ git submodule add Submodules/FFmpegWrapper https://github.com/OpenWatch/FFmpegWrapper.git
    
  2. Drag FFmpegWrapper.xcodeproj into your project's files.

  3. Add FFmpegWrapper to your target's Target Dependencies in Build Phases.

  4. Add libFFmpegWrapper.a to your target's Link Binary with Libraries in Build Phases.

Usage

FFmpegWrapper.h contains the latest documentation so it would be advisable to check there first as this document may be out of date due to rapid development.

Converts file at inputPath to a new file at outputPath using the parameters specified in the options dictionary. The two optional callbacks are for monitoring the progress and completion of a queued task and are always called on the main thread. All calls to this function are currently queued in a synchronous internal dispatch queue.

- (void) convertInputPath:(NSString*)inputPath outputPath:(NSString*)outputPath options:(NSDictionary*)options progressBlock:(FFmpegWrapperProgressBlock)progressBlock completionBlock:(FFmpegWrapperCompletionBlock)completionBlock;

License

Like FFmpeg itself, this library is LGPL 2.1+.

FFmpegWrapper

Created by Christopher Ballinger on 9/14/13.
Copyright (c) 2013 OpenWatch, Inc. All rights reserved.

FFmpegWrapper is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

FFmpegWrapper is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with FFmpegWrapper; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

ffmpegwrapper's People

Contributors

chrisballinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ffmpegwrapper's Issues

Fails when compiling

I'm receiving the following error during compilation.
Any ideas on how to go about fixing this?

Libtool /Users/idobn/Library/Developer/Xcode/DerivedData/M4ATestSix-gioieygmkoyfcgeictkobsfmvnmd/Build/Products/Debug-iphonesimulator/libFFmpegWrapper.a normal x86_64
cd /Users/idobn/dev/ios_code/M4ATestSix/Submodules/FFmpegWrapper
export IPHONEOS_DEPLOYMENT_TARGET=9.3
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -L/Users/idobn/Library/Developer/Xcode/DerivedData/M4ATestSix-gioieygmkoyfcgeictkobsfmvnmd/Build/Products/Debug-iphonesimulator -L/Users/chrisbal/FFmpegWrapper/Submodules/FFmpeg-iOS/dependencies/lib -filelist /Users/idobn/Library/Developer/Xcode/DerivedData/M4ATestSix-gioieygmkoyfcgeictkobsfmvnmd/Build/Intermediates/FFmpegWrapper.build/Debug-iphonesimulator/FFmpegWrapper.build/Objects-normal/x86_64/FFmpegWrapper.LinkFileList -lavcodec -lavutil -lswscale -lavdevice -lavfilter -lavformat -lswresample -lavutil -lavfilter -framework Foundation -lavdevice -lswscale -lavformat -lswresample -lavcodec -o /Users/idobn/Library/Developer/Xcode/DerivedData/M4ATestSix-gioieygmkoyfcgeictkobsfmvnmd/Build/Products/Debug-iphonesimulator/libFFmpegWrapper.a

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavcodec
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavcodec is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavutil
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavutil is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lswscale
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lswscale is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavdevice
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavdevice is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavfilter
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavfilter is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavformat
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavformat is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lswresample
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lswresample is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavutil
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavutil is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavfilter
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavfilter is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavdevice
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavdevice is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lswscale
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lswscale is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavformat
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavformat is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lswresample
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lswresample is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lavcodec
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lavcodec is not an object file (not allowed in a library)

ios11 AVMediaType conflict

ios11 system enum AVMediaType
avutil.h
enum AVMediaType {
AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse
AVMEDIA_TYPE_NB
};
conflict

I am unable to integrate FFmpegWrapper

Can somebody please give me a step-by-step description how i can integrate this FFmpegWrapper into a new xcode project. I am unable to get it done. i cannot get FFmpeg-iOS to work.

Remote file

Guys,

We need to process a remote file.
The code actually checks for the file on the local filesystem.

Any way we can fix it?

Thanks

Drop first audio frame

Hey, i'm using your code to convert mp4 from AVAssetWriter to .ts, but i found that the first frame don't have audio, do you know why ?

FFOutputFile writeTrailerWithError doesn't output last segment

Hey guys,
I'm currently using this library to transcode media on the device, specifically .mp4 to .ts segments. This is all well and good, as the output file appears to output the .m3u8 file, along with .ts files over the course of writing, but when writeTrailerWithError is called, the last segment isn't output to the directory. In log form:

********* START RECORDING *********
2014-11-24 19:21:23.630 Present[907:175823] codec not found: h264
[mpegts @ 0x18189c00] muxrate VBR, pcr every 3 pkts, sdt every 200, pat/pmt every 40 pkts
( ) ( ) ( ) ( ) ( ) Directory did change ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) Directory did change ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) Directory did change ( ) ( ) ( ) ( ) ( )
********* STOP RECORDING *********
********* HLSWriter did finish writing *********
The movie writing group has finished successfully!

There should be another ( ) ( ) ( ) ( ) ( ) Directory did change ( ) ( ) ( ) ( ) ( ) log after the ********* HLSWriter did finish writing ********* log, as that is logged immediately after the writeTrailerWithError method is called, but that is not the case.

Undefined symbols in architecture x86_64/arm64

Hello,
I get this Linker Error while building for simulator or device.

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_FFBitstreamFilter", referenced from:
objc-class-ref in libFFmpegWrapper.a(FFmpegWrapper.o)
"OBJC_CLASS$_FFOutputFile", referenced from:
objc-class-ref in libFFmpegWrapper.a(FFmpegWrapper.o)
"OBJC_CLASS$_FFInputFile", referenced from:
objc-class-ref in libFFmpegWrapper.a(FFmpegWrapper.o)
"OBJC_CLASS$_FFOutputStream", referenced from:
objc-class-ref in libFFmpegWrapper.a(FFmpegWrapper.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have added the following frameworks & libraries
CoreMedia, VideoToolbox, libbz2, libbz, libiconv, libFFmpegWrapper.a

Please help.

A few tiny suggestions

Hi,

the wrapper looks awesome - generally all one should need on iOS for some tiny conversions!

I have two small tiny feature requests:

  1. Add a way to cancel the conversion. Either from the progressBlock (see -[NSArray enumerateObjectsUsingBlock:], where the block has another parameter BOOL *stop), or by adding a cancel method onto the FFmpegWrapper class, which would simply mark the instance as cancelled FFmpegWrapper would check in the while cycle whether the conversion is cancelled.

  2. Add support for multiple input files at once - most useful usecase for this would be merging a video and audio track together.

Thanks!

Charlie

No option to add video segment duration

I'm using this function in your wrapper class.

  • (void) convertInputPath:(NSString_)inputPath outputPath:(NSString_)outputPath options:(NSDictionary*)options progressBlock:(FFmpegWrapperProgressBlock)progressBlock completionBlock:(FFmpegWrapperCompletionBlock)completionBlock;

I need to set the video segment duration. Is there any option for that ?

FFmpeg-iOS 3.3

Has anyone updated the FFmpegWrapper to work with FFmpeg 3.3 ?

Documentation error for adding submodule?

I attempted to add the submodule per the read me:

git submodule add Submodules/FFmpegWrapper https://github.com/OpenWatch/FFmpegWrapper.git

However, that yielded this error:

repo URL: 'Submodules/FFmpegWrapper' must be absolute or begin with ./|../

Instead, I was able to do:

  cd <mymodule_dir>
  mkdir Submodules
  git submodule add https://github.com/OpenWatch/FFmpegWrapper.git Submodules/FFmpegWrapper

I'm using git version 1.8.1.

Hi guys! Please help me!

I have one question, is it possible with FFMpeg to record the phone screen on iOS, if so then any clue how to do it, I would be very grateful, thank you!

Codec not found mpeg4

I try to decode a video encoded using mpeg4 format (mp4v). When the library reaches the point where it searches for CODEC_ID_MPEG4, I get a message: "codec not found: mpeg4"

opus file to mp3 - opus codec not supported in WAVE format.

I try to convert opus file to mp3/wav file

But I get this error:
opus codec not supported in WAVE format.
for example I can

  1. convert opus file to ogg but not for mp3/wav
  2. convert mp3 file to wav file

My code, can you please advise what I am do wrong?

Thanks
override func viewDidLoad() {
super.viewDidLoad()

    input = Bundle.main.path(forResource: "example", ofType: "opus")
    
    let documents = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
    
    output = documents.appending("/result1.wav")
    
    self.convertAudio()

}

func convertAudio(){

    
    self.ff.convertInputPath(input, outputPath: output, options: nil, progressBlock: { (bytesRead :UInt, totalBytesRead : UInt64, totalBytesExpectedToRead : UInt64) in
        
        print("OK")
    }) { (value, error) in
        
        print(error ?? "")

    }
    
}

Library converts mkv -> mp4 incorrectly, file cannot be opened

Using the following code:

FFmpegWrapper *ffmpegWrapper = [[FFmpegWrapper alloc] init];
[ffmpegWrapper convertInputPath:mkvVideoFilePath outputPath:mp4VideoFilePath options:nil progressBlock:^(NSUInteger bytesRead, uint64_t totalBytesRead, uint64_t totalBytesExpectedToRead) {
    NSLog(@"Progress: %.2f", (float)totalBytesRead / totalBytesExpectedToRead);
} completionBlock:^(BOOL success, NSError *error) {
    if (success && !error) {
        // delete mp4 file
    } else {
        if (error) {
            DDLogError(@"MKV -> MP4 conversion: Error occured: %@", error.localizedDescription);
            // do something else with the error
        } else {
            DDLogError(@"MKV -> MP4 conversion: Unknown error occured.");
        }
        // check if mkv also needs to be deleted
}];

Problems:

  1. The video is unplayable.
  2. Output mp4 is 5 minutes long, while input mkv is 11 seconds long.
  3. Console is flooded with logs.
  4. Even though everything failed, the completionBlock is called with success = YES, error = nil.

My console looks like the linked gist file (FFmpegWrapper is basically spamming with logs, 30k lines generated for 11s .mkv movie, it's really long so I don't want to attach it here).

I'm using the version from:
pod 'FFmpegWrapper-up-to-date', '~> 1.2'

Can I use FFmpegWrapper to made player

Hi, the wrapper is very good.
But I see it's only use to convert video from one format to another format.
Can I use it to made a video player ?

Thanks.

Not Playing in Quicktime

Hi,

I set output options as follows.
NSDictionary *options = @{kFFmpegOutputFormatKey: @"mpegts"};
Then the output files not paying in QuickTime. Is it limitation in the library or is there anything I need to set to play output file in QuickTime player.

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.