From 3b4c07df28e94b454a8008ba59b46e80e4c0b45a Mon Sep 17 00:00:00 2001 From: Travis Bader Date: Wed, 6 May 2015 22:04:01 -0700 Subject: [PATCH 1/4] fixing absolute path --- FFmpegWrapper.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FFmpegWrapper.xcodeproj/project.pbxproj b/FFmpegWrapper.xcodeproj/project.pbxproj index fda189f..0b47b72 100644 --- a/FFmpegWrapper.xcodeproj/project.pbxproj +++ b/FFmpegWrapper.xcodeproj/project.pbxproj @@ -609,11 +609,11 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/include", + "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/include/**", ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "/Users/chrisbal/FFmpegWrapper/Submodules/FFmpeg-iOS/dependencies/lib", + "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/lib", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -630,11 +630,11 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/include", + "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/include/**", ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "/Users/chrisbal/FFmpegWrapper/Submodules/FFmpeg-iOS/dependencies/lib", + "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/lib", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; From 9c8efe60bb3aba8f9826fe7027732d553ed19812 Mon Sep 17 00:00:00 2001 From: Travis Bader Date: Wed, 6 May 2015 22:53:31 -0700 Subject: [PATCH 2/4] Added in missing files --- FFmpegWrapper.xcodeproj/project.pbxproj | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/FFmpegWrapper.xcodeproj/project.pbxproj b/FFmpegWrapper.xcodeproj/project.pbxproj index 0b47b72..ec82b61 100644 --- a/FFmpegWrapper.xcodeproj/project.pbxproj +++ b/FFmpegWrapper.xcodeproj/project.pbxproj @@ -7,6 +7,17 @@ objects = { /* Begin PBXBuildFile section */ + 94FE4DA51AFB334700A4A49F /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94FE4DA21AFB334700A4A49F /* libcrypto.a */; }; + 94FE4DA61AFB334700A4A49F /* librtmp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94FE4DA31AFB334700A4A49F /* librtmp.a */; }; + 94FE4DA71AFB334700A4A49F /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94FE4DA41AFB334700A4A49F /* libssl.a */; }; + 94FE4DBC1AFB343200A4A49F /* FFBitstreamFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DAD1AFB343200A4A49F /* FFBitstreamFilter.m */; }; + 94FE4DBD1AFB343200A4A49F /* FFFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DAF1AFB343200A4A49F /* FFFile.m */; }; + 94FE4DBE1AFB343200A4A49F /* FFInputFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DB11AFB343200A4A49F /* FFInputFile.m */; }; + 94FE4DBF1AFB343200A4A49F /* FFInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DB31AFB343200A4A49F /* FFInputStream.m */; }; + 94FE4DC01AFB343200A4A49F /* FFOutputFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DB51AFB343200A4A49F /* FFOutputFile.m */; }; + 94FE4DC11AFB343200A4A49F /* FFOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DB71AFB343200A4A49F /* FFOutputStream.m */; }; + 94FE4DC21AFB343200A4A49F /* FFStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DB91AFB343200A4A49F /* FFStream.m */; }; + 94FE4DC31AFB343200A4A49F /* FFUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FE4DBB1AFB343200A4A49F /* FFUtilities.m */; }; D95F88DA17E8C259000ADE35 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D95F88D917E8C259000ADE35 /* Foundation.framework */; }; D95F88DF17E8C259000ADE35 /* FFmpegWrapper.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D95F88DE17E8C259000ADE35 /* FFmpegWrapper.h */; }; D95F88E117E8C259000ADE35 /* FFmpegWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = D95F88E017E8C259000ADE35 /* FFmpegWrapper.m */; }; @@ -49,6 +60,25 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 94FE4DA21AFB334700A4A49F /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libcrypto.a; sourceTree = ""; }; + 94FE4DA31AFB334700A4A49F /* librtmp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = librtmp.a; sourceTree = ""; }; + 94FE4DA41AFB334700A4A49F /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libssl.a; sourceTree = ""; }; + 94FE4DAC1AFB343200A4A49F /* FFBitstreamFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFBitstreamFilter.h; sourceTree = ""; }; + 94FE4DAD1AFB343200A4A49F /* FFBitstreamFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFBitstreamFilter.m; sourceTree = ""; }; + 94FE4DAE1AFB343200A4A49F /* FFFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFFile.h; sourceTree = ""; }; + 94FE4DAF1AFB343200A4A49F /* FFFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFFile.m; sourceTree = ""; }; + 94FE4DB01AFB343200A4A49F /* FFInputFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFInputFile.h; sourceTree = ""; }; + 94FE4DB11AFB343200A4A49F /* FFInputFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFInputFile.m; sourceTree = ""; }; + 94FE4DB21AFB343200A4A49F /* FFInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFInputStream.h; sourceTree = ""; }; + 94FE4DB31AFB343200A4A49F /* FFInputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFInputStream.m; sourceTree = ""; }; + 94FE4DB41AFB343200A4A49F /* FFOutputFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFOutputFile.h; sourceTree = ""; }; + 94FE4DB51AFB343200A4A49F /* FFOutputFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFOutputFile.m; sourceTree = ""; }; + 94FE4DB61AFB343200A4A49F /* FFOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFOutputStream.h; sourceTree = ""; }; + 94FE4DB71AFB343200A4A49F /* FFOutputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFOutputStream.m; sourceTree = ""; }; + 94FE4DB81AFB343200A4A49F /* FFStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFStream.h; sourceTree = ""; }; + 94FE4DB91AFB343200A4A49F /* FFStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFStream.m; sourceTree = ""; }; + 94FE4DBA1AFB343200A4A49F /* FFUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFUtilities.h; sourceTree = ""; }; + 94FE4DBB1AFB343200A4A49F /* FFUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFUtilities.m; sourceTree = ""; }; D95F88D617E8C259000ADE35 /* libFFmpegWrapper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFFmpegWrapper.a; sourceTree = BUILT_PRODUCTS_DIR; }; D95F88D917E8C259000ADE35 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D95F88DD17E8C259000ADE35 /* FFmpegWrapper-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FFmpegWrapper-Prefix.pch"; sourceTree = ""; }; @@ -151,7 +181,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 94FE4DA61AFB334700A4A49F /* librtmp.a in Frameworks */, D9CF4BA117E8CA1A00E7EE87 /* libavutil.a in Frameworks */, + 94FE4DA71AFB334700A4A49F /* libssl.a in Frameworks */, D9CF4B9F17E8CA1A00E7EE87 /* libavfilter.a in Frameworks */, D95F88DA17E8C259000ADE35 /* Foundation.framework in Frameworks */, D9CF4B9E17E8CA1A00E7EE87 /* libavdevice.a in Frameworks */, @@ -159,6 +191,7 @@ D9CF4BA017E8CA1A00E7EE87 /* libavformat.a in Frameworks */, D9CF4BA217E8CA1A00E7EE87 /* libswresample.a in Frameworks */, D9CF4B9D17E8CA1A00E7EE87 /* libavcodec.a in Frameworks */, + 94FE4DA51AFB334700A4A49F /* libcrypto.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -209,6 +242,22 @@ D95F88DB17E8C259000ADE35 /* FFmpegWrapper */ = { isa = PBXGroup; children = ( + 94FE4DAC1AFB343200A4A49F /* FFBitstreamFilter.h */, + 94FE4DAD1AFB343200A4A49F /* FFBitstreamFilter.m */, + 94FE4DAE1AFB343200A4A49F /* FFFile.h */, + 94FE4DAF1AFB343200A4A49F /* FFFile.m */, + 94FE4DB01AFB343200A4A49F /* FFInputFile.h */, + 94FE4DB11AFB343200A4A49F /* FFInputFile.m */, + 94FE4DB21AFB343200A4A49F /* FFInputStream.h */, + 94FE4DB31AFB343200A4A49F /* FFInputStream.m */, + 94FE4DB41AFB343200A4A49F /* FFOutputFile.h */, + 94FE4DB51AFB343200A4A49F /* FFOutputFile.m */, + 94FE4DB61AFB343200A4A49F /* FFOutputStream.h */, + 94FE4DB71AFB343200A4A49F /* FFOutputStream.m */, + 94FE4DB81AFB343200A4A49F /* FFStream.h */, + 94FE4DB91AFB343200A4A49F /* FFStream.m */, + 94FE4DBA1AFB343200A4A49F /* FFUtilities.h */, + 94FE4DBB1AFB343200A4A49F /* FFUtilities.m */, D95F88DE17E8C259000ADE35 /* FFmpegWrapper.h */, D95F88E017E8C259000ADE35 /* FFmpegWrapper.m */, D95F88DC17E8C259000ADE35 /* Supporting Files */, @@ -386,6 +435,9 @@ D9CF4B9517E8CA1A00E7EE87 /* lib */ = { isa = PBXGroup; children = ( + 94FE4DA21AFB334700A4A49F /* libcrypto.a */, + 94FE4DA31AFB334700A4A49F /* librtmp.a */, + 94FE4DA41AFB334700A4A49F /* libssl.a */, D9CF4B9617E8CA1A00E7EE87 /* libavcodec.a */, D9CF4B9717E8CA1A00E7EE87 /* libavdevice.a */, D9CF4B9817E8CA1A00E7EE87 /* libavfilter.a */, @@ -496,7 +548,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 94FE4DC11AFB343200A4A49F /* FFOutputStream.m in Sources */, + 94FE4DBF1AFB343200A4A49F /* FFInputStream.m in Sources */, + 94FE4DC31AFB343200A4A49F /* FFUtilities.m in Sources */, + 94FE4DBE1AFB343200A4A49F /* FFInputFile.m in Sources */, + 94FE4DBD1AFB343200A4A49F /* FFFile.m in Sources */, D95F88E117E8C259000ADE35 /* FFmpegWrapper.m in Sources */, + 94FE4DC21AFB343200A4A49F /* FFStream.m in Sources */, + 94FE4DC01AFB343200A4A49F /* FFOutputFile.m in Sources */, + 94FE4DBC1AFB343200A4A49F /* FFBitstreamFilter.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -614,6 +674,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/lib", + "$(PROJECT_DIR)/Submodules/FFmpeg-iOS/dependencies/lib", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -635,6 +696,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/Submodules/FFmpeg-iOS/dependencies/lib", + "$(PROJECT_DIR)/Submodules/FFmpeg-iOS/dependencies/lib", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; From 86afc27df51fa45217f1c60cd47f0921921bf2ed Mon Sep 17 00:00:00 2001 From: Travis Bader Date: Sat, 9 May 2015 15:03:36 -0700 Subject: [PATCH 3/4] Adding more options to the converter --- FFmpegWrapper/FFInputFile.h | 1 + FFmpegWrapper/FFInputFile.m | 15 ++++++++++++++- FFmpegWrapper/FFmpegWrapper.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/FFmpegWrapper/FFInputFile.h b/FFmpegWrapper/FFInputFile.h index 231a551..0cf3df1 100644 --- a/FFmpegWrapper/FFInputFile.h +++ b/FFmpegWrapper/FFInputFile.h @@ -9,6 +9,7 @@ #import "FFFile.h" @interface FFInputFile : FFFile + @property (nonatomic) BOOL endOfFileReached; @property (nonatomic) int64_t timestampOffset; @property (nonatomic) int64_t lastTimestamp; diff --git a/FFmpegWrapper/FFInputFile.m b/FFmpegWrapper/FFInputFile.m index 133d6e9..7905582 100644 --- a/FFmpegWrapper/FFInputFile.m +++ b/FFmpegWrapper/FFInputFile.m @@ -10,7 +10,9 @@ #import "FFInputStream.h" #import "FFUtilities.h" -NSString const *kFFmpegInputFormatKey = @"kFFmpegInputFormatKey"; +NSString* const kFFmpegInputFormatKey = @"kFFmpegInputFormatKey"; +NSString* const kFFmpegMovFlag = @"movflags"; +NSString* const kFFmpegCodecFlag = @"codec"; @implementation FFInputFile @synthesize endOfFileReached, timestampOffset, lastTimestamp, formatContext; @@ -24,12 +26,23 @@ - (AVFormatContext*) formatContextForInputPath:(NSString*)inputPath options:(NSD AVFormatContext *inputFormatContext = NULL; AVInputFormat *inputFormat = NULL; AVDictionary *inputOptions = NULL; + NSString *inputFormatString = [options objectForKey:kFFmpegInputFormatKey]; if (inputFormatString) { inputFormat = av_find_input_format([inputFormatString UTF8String]); } + NSString* movFlags = [options objectForKey:kFFmpegMovFlag]; + if (movFlags) { + av_dict_set(&inputOptions, "movflags", [movFlags UTF8String], 0); + } + + NSString* codec = [options objectForKey:kFFmpegCodecFlag]; + if (codec) { + av_dict_set(&inputOptions, "codec", [codec UTF8String], 0); + } + // It's possible to send more options to the parser // av_dict_set(&inputOptions, "video_size", "640x480", 0); // av_dict_set(&inputOptions, "pixel_format", "rgb24", 0); diff --git a/FFmpegWrapper/FFmpegWrapper.h b/FFmpegWrapper/FFmpegWrapper.h index e5a300a..f95c60e 100644 --- a/FFmpegWrapper/FFmpegWrapper.h +++ b/FFmpegWrapper/FFmpegWrapper.h @@ -52,6 +52,9 @@ typedef void(^FFmpegWrapperProgressBlock)(NSUInteger bytesRead, uint64_t totalBy */ extern NSString const *kFFmpegInputFormatKey; +extern NSString* const kFFmpegMovFlag; +extern NSString* const kFFmpegCodecFlag; + /** Required. This controls the type of container for the output format. Accepts NSString values like @"mp4", @"avi", @"mpegts". For a full list of supported formats please consult `$ ffmpeg -formats`. */ From 8cb76f2148c3562b22f0d46c89d7d05da0345e94 Mon Sep 17 00:00:00 2001 From: Travis Bader Date: Sat, 9 May 2015 21:49:25 -0700 Subject: [PATCH 4/4] Fixing compiler warning --- FFmpegWrapper/FFOutputFile.h | 1 + FFmpegWrapper/FFOutputFile.m | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/FFmpegWrapper/FFOutputFile.h b/FFmpegWrapper/FFOutputFile.h index 489a628..0cf51a9 100644 --- a/FFmpegWrapper/FFOutputFile.h +++ b/FFmpegWrapper/FFOutputFile.h @@ -15,6 +15,7 @@ @interface FFOutputFile : FFFile @property (nonatomic) int64_t startTime; + // No need to call this function directly, streams are automatically added when created - (void) addOutputStream:(FFOutputStream*)outputStream; diff --git a/FFmpegWrapper/FFOutputFile.m b/FFmpegWrapper/FFOutputFile.m index a8e8684..b43fda1 100644 --- a/FFmpegWrapper/FFOutputFile.m +++ b/FFmpegWrapper/FFOutputFile.m @@ -19,7 +19,7 @@ @interface FFOutputFile() @end @implementation FFOutputFile -@synthesize startTime, formatContext, bitstreamFilters; +@synthesize startTime, formatContext, bitstreamFilters, streams = _streams;; - (void) addBitstreamFilter:(FFBitstreamFilter *)bitstreamFilter { [bitstreamFilters addObject:bitstreamFilter];