parent
35b99c02f8
commit
6f5a7b4ff4
@ -0,0 +1,27 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>AvailableLibraries</key> |
||||
<array> |
||||
<dict> |
||||
<key>BinaryPath</key> |
||||
<string>ffmpegkit.framework/ffmpegkit</string> |
||||
<key>LibraryIdentifier</key> |
||||
<string>ios-arm64</string> |
||||
<key>LibraryPath</key> |
||||
<string>ffmpegkit.framework</string> |
||||
<key>SupportedArchitectures</key> |
||||
<array> |
||||
<string>arm64</string> |
||||
</array> |
||||
<key>SupportedPlatform</key> |
||||
<string>ios</string> |
||||
</dict> |
||||
</array> |
||||
<key>CFBundlePackageType</key> |
||||
<string>XFWK</string> |
||||
<key>XCFrameworkFormatVersion</key> |
||||
<string>1.0</string> |
||||
</dict> |
||||
</plist> |
@ -0,0 +1,55 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_ABSTRACT_SESSION_H |
||||
#define FFMPEG_KIT_ABSTRACT_SESSION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "Session.h" |
||||
|
||||
/**
|
||||
* Defines how long default "getAll" methods wait, in milliseconds. |
||||
*/ |
||||
extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
||||
|
||||
/**
|
||||
* Abstract session implementation which includes common features shared by <code>FFmpeg</code>, |
||||
* <code>FFprobe</code> and <code>MediaInformation</code> sessions. |
||||
*/ |
||||
@interface AbstractSession : NSObject<Session> |
||||
|
||||
/**
|
||||
* Creates a new abstract session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param logCallback session specific log callback |
||||
* @param logRedirectionStrategy session specific log redirection strategy |
||||
*/ |
||||
- (instancetype)init:(NSArray*)arguments withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; |
||||
|
||||
/**
|
||||
* Waits for all asynchronous messages to be transmitted until the given timeout. |
||||
* |
||||
* @param timeout wait timeout in milliseconds |
||||
*/ |
||||
- (void)waitForAsynchronousMessagesInTransmit:(int)timeout; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_ABSTRACT_SESSION_H
|
@ -0,0 +1,46 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_ARCH_DETECT_H |
||||
#define FFMPEG_KIT_ARCH_DETECT_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
/**
|
||||
* Detects the running architecture. |
||||
*/ |
||||
@interface ArchDetect : NSObject |
||||
|
||||
/**
|
||||
* Returns architecture name of the cpu running. |
||||
* |
||||
* @return architecture name of the cpu running |
||||
*/ |
||||
+ (NSString*)getCpuArch; |
||||
|
||||
/**
|
||||
* Returns architecture name loaded. |
||||
* |
||||
* @return architecture name loaded |
||||
*/ |
||||
+ (NSString*)getArch; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_ARCH_DETECT_H
|
@ -0,0 +1,38 @@ |
||||
/*
|
||||
* Copyright (c) 2020-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_ATOMIC_LONG_H |
||||
#define FFMPEG_KIT_ATOMIC_LONG_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
/**
|
||||
* Represents an atomic long data type. |
||||
*/ |
||||
@interface AtomicLong : NSObject |
||||
|
||||
- (instancetype)initWithValue:(long)value; |
||||
|
||||
- (long)incrementAndGet; |
||||
|
||||
- (long)getAndIncrement; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_ATOMIC_LONG_H
|
@ -0,0 +1,84 @@ |
||||
/*
|
||||
* Copyright (c) 2021-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_CHAPTER_H |
||||
#define FFMPEG_KIT_CHAPTER_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
extern NSString* const ChapterKeyId; |
||||
extern NSString* const ChapterKeyTimeBase; |
||||
extern NSString* const ChapterKeyStart; |
||||
extern NSString* const ChapterKeyStartTime; |
||||
extern NSString* const ChapterKeyEnd; |
||||
extern NSString* const ChapterKeyEndTime; |
||||
extern NSString* const ChapterKeyTags; |
||||
|
||||
/**
|
||||
* Chapter class. |
||||
*/ |
||||
@interface Chapter : NSObject |
||||
|
||||
- (instancetype)init:(NSDictionary*)chapterDictionary; |
||||
|
||||
- (NSNumber*)getId; |
||||
|
||||
- (NSString*)getTimeBase; |
||||
|
||||
- (NSNumber*)getStart; |
||||
|
||||
- (NSString*)getStartTime; |
||||
|
||||
- (NSNumber*)getEnd; |
||||
|
||||
- (NSString*)getEndTime; |
||||
|
||||
- (NSDictionary*)getTags; |
||||
|
||||
/**
|
||||
* Returns the chapter property associated with the key. |
||||
* |
||||
* @return chapter property as string or nil if the key is not found |
||||
*/ |
||||
- (NSString*)getStringProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the chapter property associated with the key. |
||||
* |
||||
* @return chapter property as number or nil if the key is not found |
||||
*/ |
||||
- (NSNumber*)getNumberProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the chapter property associated with the key. |
||||
* |
||||
* @return chapter property as id or nil if the key is not found |
||||
*/ |
||||
- (id)getProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns all chapter properties defined. |
||||
* |
||||
* @return all chapter properties in a dictionary or nil if no properties are defined |
||||
*/ |
||||
- (NSDictionary*)getAllProperties; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_CHAPTER_H
|
@ -0,0 +1,200 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_H |
||||
#define FFMPEG_KIT_H |
||||
|
||||
#import <string.h> |
||||
#import <stdlib.h> |
||||
#import <Foundation/Foundation.h> |
||||
#import "LogCallback.h" |
||||
#import "FFmpegSession.h" |
||||
#import "StatisticsCallback.h" |
||||
|
||||
/**
|
||||
* <p>Main class to run <code>FFmpeg</code> commands. Supports executing commands both synchronously and |
||||
* asynchronously. |
||||
* <pre> |
||||
* FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v libxvid file1.avi"]; |
||||
* |
||||
* FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withCompleteCallback:completeCallback]; |
||||
* </pre> |
||||
* <p>Provides overloaded <code>execute</code> methods to define session specific callbacks. |
||||
* <pre> |
||||
* FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; |
||||
* </pre> |
||||
*/ |
||||
@interface FFmpegKit : NSObject |
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFmpeg with arguments provided. |
||||
* |
||||
* @param arguments FFmpeg command options/arguments as string array |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeWithArguments:(NSArray*)arguments; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFmpeg command options/arguments as string array |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFmpeg command options/arguments as string array |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param statisticsCallback callback that will receive statistics |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFmpeg command options/arguments as string array |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFmpeg command options/arguments as string array |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param statisticsCallback callback that will receive statistics |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFmpeg command provided. Space character is used to split command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside |
||||
* your command. |
||||
* |
||||
* @param command FFmpeg command |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)execute:(NSString*)command; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFmpeg command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFmpeg command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param statisticsCallback callback that will receive statistics |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFmpeg command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFmpeg command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param statisticsCallback callback that will receive statistics |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFmpeg session created for this execution |
||||
*/ |
||||
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Cancels all running sessions. |
||||
* |
||||
* <p>This method does not wait for termination to complete and returns immediately. |
||||
*/ |
||||
+ (void)cancel; |
||||
|
||||
/**
|
||||
* <p>Cancels the session specified with <code>sessionId</code>. |
||||
* |
||||
* <p>This method does not wait for termination to complete and returns immediately. |
||||
* |
||||
* @param sessionId id of the session that will be cancelled |
||||
*/ |
||||
+ (void)cancel:(long)sessionId; |
||||
|
||||
/**
|
||||
* <p>Lists all FFmpeg sessions in the session history. |
||||
* |
||||
* @return all FFmpeg sessions in the session history |
||||
*/ |
||||
+ (NSArray*)listSessions; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_H
|
@ -0,0 +1,462 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_CONFIG_H |
||||
#define FFMPEG_KIT_CONFIG_H |
||||
|
||||
#import <stdio.h> |
||||
#import <pthread.h> |
||||
#import <unistd.h> |
||||
#import <Foundation/Foundation.h> |
||||
#import "FFmpegSession.h" |
||||
#import "FFprobeSession.h" |
||||
#import "LogCallback.h" |
||||
#import "MediaInformationSession.h" |
||||
#import "StatisticsCallback.h" |
||||
|
||||
/** Global library version */ |
||||
extern NSString* const FFmpegKitVersion; |
||||
|
||||
typedef NS_ENUM(NSUInteger, Signal) { |
||||
SignalInt = 2, |
||||
SignalQuit = 3, |
||||
SignalPipe = 13, |
||||
SignalTerm = 15, |
||||
SignalXcpu = 24 |
||||
}; |
||||
|
||||
/**
|
||||
* <p>Configuration class of <code>FFmpegKit</code> library. Allows customizing the global library |
||||
* options. Provides helper methods to support additional resources. |
||||
*/ |
||||
@interface FFmpegKitConfig : NSObject |
||||
|
||||
/**
|
||||
* <p>Enables log and statistics redirection. |
||||
* |
||||
* <p>When redirection is enabled FFmpeg/FFprobe logs are redirected to NSLog and sessions |
||||
* collect log and statistics entries for the executions. It is possible to define global or |
||||
* session specific log/statistics callbacks as well. |
||||
* |
||||
* <p>Note that redirection is enabled by default. If you do not want to use its functionality |
||||
* please use disableRedirection method to disable it. |
||||
*/ |
||||
+ (void)enableRedirection; |
||||
|
||||
/**
|
||||
* <p>Disables log and statistics redirection. |
||||
* |
||||
* <p>When redirection is disabled logs are printed to stderr, all logs and statistics |
||||
* callbacks are disabled and <code>FFprobe</code>'s <code>getMediaInformation</code> methods |
||||
* do not work. |
||||
*/ |
||||
+ (void)disableRedirection; |
||||
|
||||
/**
|
||||
* <p>Sets and overrides <code>fontconfig</code> configuration directory. |
||||
* |
||||
* @param path directory that contains fontconfig configuration (fonts.conf) |
||||
* @return zero on success, non-zero on error |
||||
*/ |
||||
+ (int)setFontconfigConfigurationPath:(NSString*)path; |
||||
|
||||
/**
|
||||
* <p>Registers the fonts inside the given path, so they become available to use in FFmpeg |
||||
* filters. |
||||
* |
||||
* <p>Note that you need to build <code>FFmpegKit</code> with <code>fontconfig</code> |
||||
* enabled or use a prebuilt package with <code>fontconfig</code> inside to be able to use |
||||
* fonts in <code>FFmpeg</code>. |
||||
* |
||||
* @param fontDirectoryPath directory that contains fonts (.ttf and .otf files) |
||||
* @param fontNameMapping custom font name mappings, useful to access your fonts with more |
||||
* friendly names |
||||
*/ |
||||
+ (void)setFontDirectory:(NSString*)fontDirectoryPath with:(NSDictionary*)fontNameMapping; |
||||
|
||||
/**
|
||||
* <p>Registers the fonts inside the given array of font directories, so they become available |
||||
* to use in FFmpeg filters. |
||||
* |
||||
* <p>Note that you need to build <code>FFmpegKit</code> with <code>fontconfig</code> |
||||
* enabled or use a prebuilt package with <code>fontconfig</code> inside to be able to use |
||||
* fonts in <code>FFmpeg</code>. |
||||
* |
||||
* @param fontDirectoryList array of directories that contain fonts (.ttf and .otf files) |
||||
* @param fontNameMapping custom font name mappings, useful to access your fonts with more |
||||
* friendly names |
||||
*/ |
||||
+ (void)setFontDirectoryList:(NSArray*)fontDirectoryList with:(NSDictionary*)fontNameMapping; |
||||
|
||||
/**
|
||||
* <p>Creates a new named pipe to use in <code>FFmpeg</code> operations. |
||||
* |
||||
* <p>Please note that creator is responsible of closing created pipes. |
||||
* |
||||
* @return the full path of the named pipe |
||||
*/ |
||||
+ (NSString*)registerNewFFmpegPipe; |
||||
|
||||
/**
|
||||
* <p>Closes a previously created <code>FFmpeg</code> pipe. |
||||
* |
||||
* @param ffmpegPipePath full path of the FFmpeg pipe |
||||
*/ |
||||
+ (void)closeFFmpegPipe:(NSString*)ffmpegPipePath; |
||||
|
||||
/**
|
||||
* <p>Returns the version of FFmpeg bundled within <code>FFmpegKit</code> library. |
||||
* |
||||
* @return the version of FFmpeg |
||||
*/ |
||||
+ (NSString*)getFFmpegVersion; |
||||
|
||||
/**
|
||||
* Returns FFmpegKit library version. |
||||
* |
||||
* @return FFmpegKit version |
||||
*/ |
||||
+ (NSString*)getVersion; |
||||
|
||||
/**
|
||||
* <p>Returns whether FFmpegKit release is a Long Term Release or not. |
||||
* |
||||
* @return true/yes or false/no |
||||
*/ |
||||
+ (int)isLTSBuild; |
||||
|
||||
/**
|
||||
* Returns FFmpegKit library build date. |
||||
* |
||||
* @return FFmpegKit library build date |
||||
*/ |
||||
+ (NSString*)getBuildDate; |
||||
|
||||
/**
|
||||
* <p>Sets an environment variable. |
||||
* |
||||
* @param variableName environment variable name |
||||
* @param variableValue environment variable value |
||||
* @return zero on success, non-zero on error |
||||
*/ |
||||
+ (int)setEnvironmentVariable:(NSString*)variableName value:(NSString*)variableValue; |
||||
|
||||
/**
|
||||
* <p>Registers a new ignored signal. Ignored signals are not handled by <code>FFmpegKit</code> |
||||
* library. |
||||
* |
||||
* @param signal signal to be ignored |
||||
*/ |
||||
+ (void)ignoreSignal:(Signal)signal; |
||||
|
||||
/**
|
||||
* <p>Synchronously executes the FFmpeg session provided. |
||||
* |
||||
* @param ffmpegSession FFmpeg session which includes command options/arguments |
||||
*/ |
||||
+ (void)ffmpegExecute:(FFmpegSession*)ffmpegSession; |
||||
|
||||
/**
|
||||
* <p>Synchronously executes the FFprobe session provided. |
||||
* |
||||
* @param ffprobeSession FFprobe session which includes command options/arguments |
||||
*/ |
||||
+ (void)ffprobeExecute:(FFprobeSession*)ffprobeSession; |
||||
|
||||
/**
|
||||
* <p>Synchronously executes the media information session provided. |
||||
* |
||||
* @param mediaInformationSession media information session which includes command options/arguments |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
*/ |
||||
+ (void)getMediaInformationExecute:(MediaInformationSession*)mediaInformationSession withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution for the given session. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param ffmpegSession FFmpeg session which includes command options/arguments |
||||
*/ |
||||
+ (void)asyncFFmpegExecute:(FFmpegSession*)ffmpegSession; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFmpeg execution for the given session. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFmpegSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param ffmpegSession FFmpeg session which includes command options/arguments |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
*/ |
||||
+ (void)asyncFFmpegExecute:(FFmpegSession*)ffmpegSession onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given session. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param ffprobeSession FFprobe session which includes command options/arguments |
||||
*/ |
||||
+ (void)asyncFFprobeExecute:(FFprobeSession*)ffprobeSession; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given session. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param ffprobeSession FFprobe session which includes command options/arguments |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
*/ |
||||
+ (void)asyncFFprobeExecute:(FFprobeSession*)ffprobeSession onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given media information session. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param mediaInformationSession media information session which includes command options/arguments |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
*/ |
||||
+ (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given media information session. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param mediaInformationSession media information session which includes command options/arguments |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
*/ |
||||
+ (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Sets a global log callback to redirect FFmpeg/FFprobe logs. |
||||
* |
||||
* @param logCallback log callback or nil to disable a previously defined log callback |
||||
*/ |
||||
+ (void)enableLogCallback:(LogCallback)logCallback; |
||||
|
||||
/**
|
||||
* <p>Sets a global statistics callback to redirect FFmpeg statistics. |
||||
* |
||||
* @param statisticsCallback statistics callback or nil to disable a previously defined statistics callback |
||||
*/ |
||||
+ (void)enableStatisticsCallback:(StatisticsCallback)statisticsCallback; |
||||
|
||||
/**
|
||||
* <p>Sets a global FFmpegSessionCompleteCallback to receive execution results for FFmpeg sessions. |
||||
* |
||||
* @param ffmpegSessionCompleteCallback complete callback or nil to disable a previously defined callback |
||||
*/ |
||||
+ (void)enableFFmpegSessionCompleteCallback:(FFmpegSessionCompleteCallback)ffmpegSessionCompleteCallback; |
||||
|
||||
/**
|
||||
* <p>Returns the global FFmpegSessionCompleteCallback set. |
||||
* |
||||
* @return global FFmpegSessionCompleteCallback or nil if it is not set |
||||
*/ |
||||
+ (FFmpegSessionCompleteCallback)getFFmpegSessionCompleteCallback; |
||||
|
||||
/**
|
||||
* <p>Sets a global FFprobeSessionCompleteCallback to receive execution results for FFprobe sessions. |
||||
* |
||||
* @param ffprobeSessionCompleteCallback complete callback or nil to disable a previously defined callback |
||||
*/ |
||||
+ (void)enableFFprobeSessionCompleteCallback:(FFprobeSessionCompleteCallback)ffprobeSessionCompleteCallback; |
||||
|
||||
/**
|
||||
* <p>Returns the global FFprobeSessionCompleteCallback set. |
||||
* |
||||
* @return global FFprobeSessionCompleteCallback or nil if it is not set |
||||
*/ |
||||
+ (FFprobeSessionCompleteCallback)getFFprobeSessionCompleteCallback; |
||||
|
||||
/**
|
||||
* <p>Sets a global MediaInformationSessionCompleteCallback to receive execution results for MediaInformation sessions. |
||||
* |
||||
* @param mediaInformationSessionCompleteCallback complete callback or nil to disable a previously defined |
||||
* callback |
||||
*/ |
||||
+ (void)enableMediaInformationSessionCompleteCallback:(MediaInformationSessionCompleteCallback)mediaInformationSessionCompleteCallback; |
||||
|
||||
/**
|
||||
* <p>Returns the global MediaInformationSessionCompleteCallback set. |
||||
* |
||||
* @return global MediaInformationSessionCompleteCallback or nil if it is not set |
||||
*/ |
||||
+ (MediaInformationSessionCompleteCallback)getMediaInformationSessionCompleteCallback; |
||||
|
||||
/**
|
||||
* Returns the current log level. |
||||
* |
||||
* @return current log level |
||||
*/ |
||||
+ (int)getLogLevel; |
||||
|
||||
/**
|
||||
* Sets the log level. |
||||
* |
||||
* @param level new log level |
||||
*/ |
||||
+ (void)setLogLevel:(int)level; |
||||
|
||||
/**
|
||||
* Converts int log level to string. |
||||
* |
||||
* @param level value |
||||
* @return string value |
||||
*/ |
||||
+ (NSString*)logLevelToString:(int)level; |
||||
|
||||
/**
|
||||
* Returns the session history size. |
||||
* |
||||
* @return session history size |
||||
*/ |
||||
+ (int)getSessionHistorySize; |
||||
|
||||
/**
|
||||
* Sets the session history size. |
||||
* |
||||
* @param sessionHistorySize session history size, should be smaller than 1000 |
||||
*/ |
||||
+ (void)setSessionHistorySize:(int)sessionHistorySize; |
||||
|
||||
/**
|
||||
* Returns the session specified with <code>sessionId</code> from the session history. |
||||
* |
||||
* @param sessionId session identifier |
||||
* @return session specified with sessionId or nil if it is not found in the history |
||||
*/ |
||||
+ (id<Session>)getSession:(long)sessionId; |
||||
|
||||
/**
|
||||
* Returns the last session created from the session history. |
||||
* |
||||
* @return the last session created or nil if session history is empty |
||||
*/ |
||||
+ (id<Session>)getLastSession; |
||||
|
||||
/**
|
||||
* Returns the last session completed from the session history. |
||||
* |
||||
* @return the last session completed. If there are no completed sessions in the history this |
||||
* method will return nil |
||||
*/ |
||||
+ (id<Session>)getLastCompletedSession; |
||||
|
||||
/**
|
||||
* <p>Returns all sessions in the session history. |
||||
* |
||||
* @return all sessions in the session history |
||||
*/ |
||||
+ (NSArray*)getSessions; |
||||
|
||||
/**
|
||||
* <p>Clears all, including ongoing, sessions in the session history. |
||||
* <p>Note that callbacks cannot be triggered for deleted sessions. |
||||
*/ |
||||
+ (void)clearSessions; |
||||
|
||||
/**
|
||||
* <p>Returns all FFmpeg sessions in the session history. |
||||
* |
||||
* @return all FFmpeg sessions in the session history |
||||
*/ |
||||
+ (NSArray*)getFFmpegSessions; |
||||
|
||||
/**
|
||||
* <p>Returns all FFprobe sessions in the session history. |
||||
* |
||||
* @return all FFprobe sessions in the session history |
||||
*/ |
||||
+ (NSArray*)getFFprobeSessions; |
||||
|
||||
/**
|
||||
* <p>Returns all MediaInformation sessions in the session history. |
||||
* |
||||
* @return all MediaInformation sessions in the session history |
||||
*/ |
||||
+ (NSArray*)getMediaInformationSessions; |
||||
|
||||
/**
|
||||
* <p>Returns sessions that have the given state. |
||||
* |
||||
* @return sessions that have the given state from the session history |
||||
*/ |
||||
+ (NSArray*)getSessionsByState:(SessionState)state; |
||||
|
||||
/**
|
||||
* Returns the active log redirection strategy. |
||||
* |
||||
* @return log redirection strategy |
||||
*/ |
||||
+ (LogRedirectionStrategy)getLogRedirectionStrategy; |
||||
|
||||
/**
|
||||
* <p>Sets the log redirection strategy |
||||
* |
||||
* @param logRedirectionStrategy log redirection strategy |
||||
*/ |
||||
+ (void)setLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; |
||||
|
||||
/**
|
||||
* <p>Returns the number of async messages that are not transmitted to the callbacks for |
||||
* this session. |
||||
* |
||||
* @param sessionId id of the session |
||||
* @return number of async messages that are not transmitted to the callbacks for this session |
||||
*/ |
||||
+ (int)messagesInTransmit:(long)sessionId; |
||||
|
||||
/**
|
||||
* Converts session state to string. |
||||
* |
||||
* @param state session state |
||||
* @return string value |
||||
*/ |
||||
+ (NSString*)sessionStateToString:(SessionState)state; |
||||
|
||||
/**
|
||||
* <p>Parses the given command into arguments. Uses space character to split the arguments. |
||||
* Supports single and double quote characters. |
||||
* |
||||
* @param command string command |
||||
* @return array of arguments |
||||
*/ |
||||
+ (NSArray*)parseArguments:(NSString*)command; |
||||
|
||||
/**
|
||||
* <p>Concatenates arguments into a string adding a space character between two arguments. |
||||
* |
||||
* @param arguments arguments |
||||
* @return concatenated string containing all arguments |
||||
*/ |
||||
+ (NSString*)argumentsToString:(NSArray*)arguments; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_CONFIG_H
|
@ -0,0 +1,132 @@ |
||||
/*
|
||||
* Copyright (c) 2021-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_FFMPEG_SESSION_H |
||||
#define FFMPEG_KIT_FFMPEG_SESSION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "AbstractSession.h" |
||||
#import "StatisticsCallback.h" |
||||
#import "FFmpegSessionCompleteCallback.h" |
||||
|
||||
/**
|
||||
* <p>An FFmpeg session. |
||||
*/ |
||||
@interface FFmpegSession : AbstractSession |
||||
|
||||
/**
|
||||
* Builds a new FFmpeg session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments; |
||||
|
||||
/**
|
||||
* Builds a new FFmpeg session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* Builds a new FFmpeg session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @param logCallback session specific log callback |
||||
* @param statisticsCallback session specific statistics callback |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; |
||||
|
||||
/**
|
||||
* Builds a new FFmpeg session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @param logCallback session specific log callback |
||||
* @param statisticsCallback session specific statistics callback |
||||
* @param logRedirectionStrategy session specific log redirection strategy |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; |
||||
|
||||
/**
|
||||
* Returns the session specific statistics callback. |
||||
* |
||||
* @return session specific statistics callback |
||||
*/ |
||||
- (StatisticsCallback)getStatisticsCallback; |
||||
|
||||
/**
|
||||
* Returns the session specific complete callback. |
||||
* |
||||
* @return session specific complete callback |
||||
*/ |
||||
- (FFmpegSessionCompleteCallback)getCompleteCallback; |
||||
|
||||
/**
|
||||
* Returns all statistics entries generated for this session. If there are asynchronous |
||||
* messages that are not delivered yet, this method waits for them until the given timeout. |
||||
* |
||||
* @param waitTimeout wait timeout for asynchronous messages in milliseconds |
||||
* @return list of statistics entries generated for this session |
||||
*/ |
||||
- (NSArray*)getAllStatisticsWithTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* Returns all statistics entries generated for this session. If there are asynchronous |
||||
* messages that are not delivered yet, this method waits for them until |
||||
* AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit expires. |
||||
* |
||||
* @return list of statistics entries generated for this session |
||||
*/ |
||||
- (NSArray*)getAllStatistics; |
||||
|
||||
/**
|
||||
* Returns all statistics entries delivered for this session. Note that if there are |
||||
* asynchronous messages that are not delivered yet, this method will not wait for |
||||
* them and will return immediately. |
||||
* |
||||
* @return list of statistics entries received for this session |
||||
*/ |
||||
- (NSArray*)getStatistics; |
||||
|
||||
/**
|
||||
* Returns the last received statistics entry. |
||||
* |
||||
* @return the last received statistics entry or nil if there are not any statistics entries |
||||
* received |
||||
*/ |
||||
- (Statistics*)getLastReceivedStatistics; |
||||
|
||||
/**
|
||||
* Adds a new statistics entry for this session. It is invoked internally by <code>FFmpegKit</code> library methods. |
||||
* Must not be used by user applications. |
||||
* |
||||
* @param statistics statistics entry |
||||
*/ |
||||
- (void)addStatistics:(Statistics*)statistics; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_FFMPEG_SESSION_H
|
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* Copyright (c) 2020-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_FFMPEG_SESSION_COMPLETE_CALLBACK_H |
||||
#define FFMPEG_KIT_FFMPEG_SESSION_COMPLETE_CALLBACK_H |
||||
|
||||
@class FFmpegSession; |
||||
|
||||
/**
|
||||
* <p>Callback function that is invoked when an asynchronous <code>FFmpeg</code> session has ended. |
||||
* <p>Session has either SessionStateCompleted or SessionStateFailed state when |
||||
* the callback is invoked. |
||||
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to |
||||
* see the execution result. |
||||
* <p>If <code>getState</code> returns SessionStateFailed then |
||||
* <code>getFailStackTrace</code> should be used to get the failure reason. |
||||
* <pre> |
||||
* switch ([session getState]) { |
||||
* case SessionStateCompleted: |
||||
* ReturnCode *returnCode = [session getReturnCode]; |
||||
* break; |
||||
* case SessionStateFailed: |
||||
* NSString *failStackTrace = [session getFailStackTrace]; |
||||
* break; |
||||
* } |
||||
* </pre> |
||||
* |
||||
* @param session session of the completed execution |
||||
*/ |
||||
typedef void (^FFmpegSessionCompleteCallback)(FFmpegSession* session); |
||||
|
||||
#import "FFmpegSession.h" |
||||
|
||||
#endif // FFMPEG_KIT_FFMPEG_SESSION_COMPLETE_CALLBACK_H
|
@ -0,0 +1,302 @@ |
||||
/*
|
||||
* Copyright (c) 2020-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFPROBE_KIT_H |
||||
#define FFPROBE_KIT_H |
||||
|
||||
#import <string.h> |
||||
#import <stdlib.h> |
||||
#import <Foundation/Foundation.h> |
||||
#import "FFprobeSession.h" |
||||
#import "MediaInformationJsonParser.h" |
||||
|
||||
/**
|
||||
* <p>Main class to run <code>FFprobe</code> commands. Supports executing commands both synchronously and |
||||
* asynchronously. |
||||
* <pre> |
||||
* FFprobeSession *session = [FFprobeKit execute:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4"]; |
||||
* |
||||
* FFprobeSession *asyncSession = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withCompleteCallback:completeCallback]; |
||||
* </pre> |
||||
* <p>Provides overloaded <code>execute</code> methods to define session specific callbacks. |
||||
* <pre> |
||||
* FFprobeSession *session = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withCompleteCallback:completeCallback withLogCallback:logCallback]; |
||||
* </pre> |
||||
* <p>It can extract media information for a file or a url, using getMediaInformation method. |
||||
* <pre> |
||||
* MediaInformationSession *session = [FFprobeKit getMediaInformation:@"file1.mp4"]; |
||||
* </pre> |
||||
*/ |
||||
@interface FFprobeKit : NSObject |
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFprobe with arguments provided. |
||||
* |
||||
* @param arguments FFprobe command options/arguments as string array |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeWithArguments:(NSArray*)arguments; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFprobe command options/arguments as string array |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFprobe command options/arguments as string array |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFprobe command options/arguments as string array |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution with arguments provided. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. |
||||
* You must use an FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFprobe command options/arguments as string array |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFprobe command provided. Space character is used to split command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside |
||||
* your command. |
||||
* |
||||
* @param command FFprobe command |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)execute:(NSString*)command; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFprobe command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFprobe command |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFprobe command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command |
||||
* into arguments. You can use single or double quote characters to specify arguments inside your command. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* FFprobeSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFprobe command |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return FFprobe session created for this execution |
||||
*/ |
||||
+ (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Extracts media information for the file specified with path. |
||||
* |
||||
* @param path path or uri of a media file |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformation:(NSString*)path; |
||||
|
||||
/**
|
||||
* <p>Extracts media information for the file specified with path. |
||||
* |
||||
* @param path path or uri of a media file |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformation:(NSString*)path withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param path path or uri of a media file |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param path path or uri of a media file |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param path path or uri of a media file |
||||
* @param completeCallback callback that will be called when the execution has completed |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param path path or uri of a media file |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Extracts media information using the command provided asynchronously. |
||||
* |
||||
* @param command FFprobe command that prints media information for a file in JSON format |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationFromCommand:(NSString*)command; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution to extract media information using a command. The command passed to |
||||
* this method must generate the output in JSON format in order to successfully extract media information from it. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param command FFprobe command that prints media information for a file in JSON format |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Starts an asynchronous FFprobe execution to extract media information using command arguments. The command |
||||
* passed to this method must generate the output in JSON format in order to successfully extract media information |
||||
* from it. |
||||
* |
||||
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an |
||||
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
||||
* |
||||
* @param arguments FFprobe command that prints media information for a file in JSON format |
||||
* @param completeCallback callback that will be notified when execution has completed |
||||
* @param logCallback callback that will receive logs |
||||
* @param queue dispatch queue that will be used to run this asynchronous operation |
||||
* @param waitTimeout max time to wait until media information is transmitted |
||||
* @return media information session created for this execution |
||||
*/ |
||||
+ (MediaInformationSession*)getMediaInformationFromCommandArgumentsAsync:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* <p>Lists all FFprobe sessions in the session history. |
||||
* |
||||
* @return all FFprobe sessions in the session history |
||||
*/ |
||||
+ (NSArray*)listFFprobeSessions; |
||||
|
||||
/**
|
||||
* <p>Lists all MediaInformation sessions in the session history. |
||||
* |
||||
* @return all MediaInformation sessions in the session history |
||||
*/ |
||||
+ (NSArray*)listMediaInformationSessions; |
||||
|
||||
@end |
||||
|
||||
#endif // FFPROBE_KIT_H
|
@ -0,0 +1,79 @@ |
||||
/*
|
||||
* Copyright (c) 2021-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_FFPROBE_SESSION_H |
||||
#define FFMPEG_KIT_FFPROBE_SESSION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "AbstractSession.h" |
||||
#import "FFprobeSessionCompleteCallback.h" |
||||
|
||||
/**
|
||||
* <p>An FFprobe session. |
||||
*/ |
||||
@interface FFprobeSession : AbstractSession |
||||
|
||||
/**
|
||||
* Builds a new FFprobe session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments; |
||||
|
||||
/**
|
||||
* Builds a new FFprobe session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* Builds a new FFprobe session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @param logCallback session specific log callback |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; |
||||
|
||||
/**
|
||||
* Builds a new FFprobe session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @param logCallback session specific log callback |
||||
* @param logRedirectionStrategy session specific log redirection strategy |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; |
||||
|
||||
/**
|
||||
* Returns the session specific complete callback. |
||||
* |
||||
* @return session specific complete callback |
||||
*/ |
||||
- (FFprobeSessionCompleteCallback)getCompleteCallback; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_FFPROBE_SESSION_H
|
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* Copyright (c) 2020-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_FFPROBE_SESSION_COMPLETE_CALLBACK_H |
||||
#define FFMPEG_KIT_FFPROBE_SESSION_COMPLETE_CALLBACK_H |
||||
|
||||
@class FFprobeSession; |
||||
|
||||
/**
|
||||
* <p>Callback function that is invoked when an asynchronous <code>FFprobe</code> session has ended. |
||||
* <p>Session has either SessionStateCompleted or SessionStateFailed state when |
||||
* the callback is invoked. |
||||
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to |
||||
* see the execution result. |
||||
* <p>If <code>getState</code> returns SessionStateFailed then |
||||
* <code>getFailStackTrace</code> should be used to get the failure reason. |
||||
* <pre> |
||||
* switch ([session getState]) { |
||||
* case SessionStateCompleted: |
||||
* ReturnCode *returnCode = [session getReturnCode]; |
||||
* break; |
||||
* case SessionStateFailed: |
||||
* NSString *failStackTrace = [session getFailStackTrace]; |
||||
* break; |
||||
* } |
||||
* </pre> |
||||
* |
||||
* @param session session of the completed execution |
||||
*/ |
||||
typedef void (^FFprobeSessionCompleteCallback)(FFprobeSession* session); |
||||
|
||||
#import "FFprobeSession.h" |
||||
|
||||
#endif // FFMPEG_KIT_FFPROBE_SESSION_COMPLETE_CALLBACK_H
|
@ -0,0 +1,85 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_LEVEL_H |
||||
#define FFMPEG_KIT_LEVEL_H |
||||
|
||||
/**
|
||||
* <p>Enumeration type for log levels. |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, Level) { |
||||
|
||||
/**
|
||||
* This log level is defined by FFmpegKit. It is used to specify logs printed to stderr by |
||||
* FFmpeg. Logs that has this level are not filtered and always redirected. |
||||
*/ |
||||
LevelAVLogStdErr = -16, |
||||
|
||||
/**
|
||||
* Print no output. |
||||
*/ |
||||
LevelAVLogQuiet = -8, |
||||
|
||||
/**
|
||||
* Something went really wrong and we will crash now. |
||||
*/ |
||||
LevelAVLogPanic = 0, |
||||
|
||||
/**
|
||||
* Something went wrong and recovery is not possible. |
||||
* For example, no header was found for a format which depends |
||||
* on headers or an illegal combination of parameters is used. |
||||
*/ |
||||
LevelAVLogFatal = 8, |
||||
|
||||
/**
|
||||
* Something went wrong and cannot losslessly be recovered. |
||||
* However, not all future data is affected. |
||||
*/ |
||||
LevelAVLogError = 16, |
||||
|
||||
/**
|
||||
* Something somehow does not look correct. This may or may not |
||||
* lead to problems. An example would be the use of '-vstrict -2'. |
||||
*/ |
||||
LevelAVLogWarning = 24, |
||||
|
||||
/**
|
||||
* Standard information. |
||||
*/ |
||||
LevelAVLogInfo = 32, |
||||
|
||||
/**
|
||||
* Detailed information. |
||||
*/ |
||||
LevelAVLogVerbose = 40, |
||||
|
||||
/**
|
||||
* Stuff which is only useful for libav* developers. |
||||
*/ |
||||
LevelAVLogDebug = 48, |
||||
|
||||
/**
|
||||
* Extremely verbose debugging, useful for libav* development. |
||||
*/ |
||||
LevelAVLogTrace = 56 |
||||
|
||||
}; |
||||
|
||||
#endif // FFMPEG_KIT_LEVEL_H
|
@ -0,0 +1,40 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_LOG_H |
||||
#define FFMPEG_KIT_LOG_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
/**
|
||||
* <p>Log entry for an <code>FFmpegKit</code> session. |
||||
*/ |
||||
@interface Log : NSObject |
||||
|
||||
- (instancetype)init:(long)sessionId :(int)level :(NSString*)message; |
||||
|
||||
- (long)getSessionId; |
||||
|
||||
- (int)getLevel; |
||||
|
||||
- (NSString*)getMessage; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_LOG_H
|
@ -0,0 +1,33 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_LOG_CALLBACK_H |
||||
#define FFMPEG_KIT_LOG_CALLBACK_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "Log.h" |
||||
|
||||
/**
|
||||
* <p>Callback that receives logs generated for <code>FFmpegKit</code> sessions. |
||||
* |
||||
* @param log log entry |
||||
*/ |
||||
typedef void (^LogCallback)(Log* log); |
||||
|
||||
#endif // FFMPEG_KIT_LOG_CALLBACK_H
|
@ -0,0 +1,31 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_LOG_REDIRECTION_STRATEGY_H |
||||
#define FFMPEG_KIT_LOG_REDIRECTION_STRATEGY_H |
||||
|
||||
typedef NS_ENUM(NSUInteger, LogRedirectionStrategy) { |
||||
LogRedirectionStrategyAlwaysPrintLogs, |
||||
LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined, |
||||
LogRedirectionStrategyPrintLogsWhenGlobalCallbackNotDefined, |
||||
LogRedirectionStrategyPrintLogsWhenSessionCallbackNotDefined, |
||||
LogRedirectionStrategyNeverPrintLogs |
||||
}; |
||||
|
||||
#endif // FFMPEG_KIT_LOG_REDIRECTION_STRATEGY_H
|
@ -0,0 +1,172 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_MEDIA_INFORMATION_H |
||||
#define FFMPEG_KIT_MEDIA_INFORMATION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "Chapter.h" |
||||
#import "StreamInformation.h" |
||||
|
||||
extern NSString* const MediaKeyMediaProperties; |
||||
extern NSString* const MediaKeyFilename; |
||||
extern NSString* const MediaKeyFormat; |
||||
extern NSString* const MediaKeyFormatLong; |
||||
extern NSString* const MediaKeyStartTime; |
||||
extern NSString* const MediaKeyDuration; |
||||
extern NSString* const MediaKeySize; |
||||
extern NSString* const MediaKeyBitRate; |
||||
extern NSString* const MediaKeyTags; |
||||
|
||||
/**
|
||||
* Media information class. |
||||
*/ |
||||
@interface MediaInformation : NSObject |
||||
|
||||
- (instancetype)init:(NSDictionary*)mediaDictionary withStreams:(NSArray*)streams withChapters:(NSArray*)chapters; |
||||
|
||||
/**
|
||||
* Returns file name. |
||||
* |
||||
* @return media file name |
||||
*/ |
||||
- (NSString*)getFilename; |
||||
|
||||
/**
|
||||
* Returns format. |
||||
* |
||||
* @return media format |
||||
*/ |
||||
- (NSString*)getFormat; |
||||
|
||||
/**
|
||||
* Returns long format. |
||||
* |
||||
* @return media long format |
||||
*/ |
||||
- (NSString*)getLongFormat; |
||||
|
||||
/**
|
||||
* Returns duration. |
||||
* |
||||
* @return media duration in "seconds.microseconds" format |
||||
*/ |
||||
- (NSString*)getDuration; |
||||
|
||||
/**
|
||||
* Returns start time. |
||||
* |
||||
* @return media start time in milliseconds |
||||
*/ |
||||
- (NSString*)getStartTime; |
||||
|
||||
/**
|
||||
* Returns size. |
||||
* |
||||
* @return media size in bytes |
||||
*/ |
||||
- (NSString*)getSize; |
||||
|
||||
/**
|
||||
* Returns bitrate. |
||||
* |
||||
* @return media bitrate in kb/s |
||||
*/ |
||||
- (NSString*)getBitrate; |
||||
|
||||
/**
|
||||
* Returns all tags. |
||||
* |
||||
* @return tags dictionary |
||||
*/ |
||||
- (NSDictionary*)getTags; |
||||
|
||||
/**
|
||||
* Returns all streams. |
||||
* |
||||
* @return streams array |
||||
*/ |
||||
- (NSArray*)getStreams; |
||||
|
||||
/**
|
||||
* Returns all chapters. |
||||
* |
||||
* @return chapters array |
||||
*/ |
||||
- (NSArray*)getChapters; |
||||
|
||||
/**
|
||||
* Returns the property associated with the key. |
||||
* |
||||
* @return property as string or nil if the key is not found |
||||
*/ |
||||
- (NSString*)getStringProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the property associated with the key. |
||||
* |
||||
* @return property as number or nil if the key is not found |
||||
*/ |
||||
- (NSNumber*)getNumberProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the property associated with the key. |
||||
* |
||||
* @return property as id or nil if the key is not found |
||||
*/ |
||||
- (id)getProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the format property associated with the key. |
||||
* |
||||
* @return format property as string or nil if the key is not found |
||||
*/ |
||||
- (NSString*)getStringFormatProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the format property associated with the key. |
||||
* |
||||
* @return format property as number or nil if the key is not found |
||||
*/ |
||||
- (NSNumber*)getNumberFormatProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the format property associated with the key. |
||||
* |
||||
* @return format property as id or nil if the key is not found |
||||
*/ |
||||
- (id)getFormatProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns all format properties defined. |
||||
* |
||||
* @return all format properties in a dictionary or nil if no format properties are defined |
||||
*/ |
||||
- (NSDictionary*)getFormatProperties; |
||||
|
||||
/**
|
||||
* Returns all properties defined. |
||||
* |
||||
* @return all properties in a dictionary or nil if no properties are defined |
||||
*/ |
||||
- (NSDictionary*)getAllProperties; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_MEDIA_INFORMATION_H
|
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_MEDIA_INFORMATION_PARSER_H |
||||
#define FFMPEG_KIT_MEDIA_INFORMATION_PARSER_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "MediaInformation.h" |
||||
|
||||
/**
|
||||
* A parser that constructs MediaInformation from FFprobe's json output. |
||||
*/ |
||||
@interface MediaInformationJsonParser : NSObject |
||||
|
||||
/**
|
||||
* Extracts <code>MediaInformation</code> from the given FFprobe json output. |
||||
* |
||||
* @param ffprobeJsonOutput FFprobe json output |
||||
* @return created MediaInformation instance of nil if a parsing error occurs |
||||
*/ |
||||
+ (MediaInformation*)from:(NSString*)ffprobeJsonOutput; |
||||
|
||||
/**
|
||||
* Extracts <code>MediaInformation</code> from the given FFprobe json output. If a parsing error occurs an NSException |
||||
* is thrown. |
||||
* |
||||
* @param ffprobeJsonOutput FFprobe json output |
||||
* @return created MediaInformation instance |
||||
*/ |
||||
+ (MediaInformation*)fromWithError:(NSString*)ffprobeJsonOutput; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_MEDIA_INFORMATION_PARSER_H
|
@ -0,0 +1,85 @@ |
||||
/*
|
||||
* Copyright (c) 2021-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H |
||||
#define FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "AbstractSession.h" |
||||
#import "MediaInformation.h" |
||||
#import "MediaInformationSessionCompleteCallback.h" |
||||
|
||||
/**
|
||||
* <p>A custom FFprobe session, which produces a <code>MediaInformation</code> object using the |
||||
* FFprobe output. |
||||
*/ |
||||
@interface MediaInformationSession : AbstractSession |
||||
|
||||
/**
|
||||
* Creates a new media information session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments; |
||||
|
||||
/**
|
||||
* Creates a new media information session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback; |
||||
|
||||
/**
|
||||
* Creates a new media information session. |
||||
* |
||||
* @param arguments command arguments |
||||
* @param completeCallback session specific complete callback |
||||
* @param logCallback session specific log callback |
||||
* @return created session |
||||
*/ |
||||
+ (instancetype)create:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; |
||||
|
||||
/**
|
||||
* Returns the media information extracted in this session. |
||||
* |
||||
* @return media information extracted or nil if the command failed or the output can not be |
||||
* parsed |
||||
*/ |
||||
- (MediaInformation*)getMediaInformation; |
||||
|
||||
/**
|
||||
* Sets the media information extracted in this session. |
||||
* |
||||
* @param mediaInformation media information extracted |
||||
*/ |
||||
- (void)setMediaInformation:(MediaInformation*)mediaInformation; |
||||
|
||||
/**
|
||||
* Returns the session specific complete callback. |
||||
* |
||||
* @return session specific complete callback |
||||
*/ |
||||
- (MediaInformationSessionCompleteCallback)getCompleteCallback; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H
|
@ -0,0 +1,51 @@ |
||||
/*
|
||||
* Copyright (c) 2020-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_MEDIA_INFORMATION_SESSION_COMPLETE_CALLBACK_H |
||||
#define FFMPEG_KIT_MEDIA_INFORMATION_SESSION_COMPLETE_CALLBACK_H |
||||
|
||||
@class MediaInformationSession; |
||||
|
||||
/**
|
||||
* <p>Callback function that is invoked when an asynchronous <code>MediaInformation</code> session |
||||
* has ended. |
||||
* <p>Session has either SessionStateCompleted or SessionStateFailed state when |
||||
* the callback is invoked. |
||||
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to |
||||
* see the execution result. |
||||
* <p>If <code>getState</code> returns SessionStateFailed then |
||||
* <code>getFailStackTrace</code> should be used to get the failure reason. |
||||
* <pre> |
||||
* switch ([session getState]) { |
||||
* case SessionStateCompleted: |
||||
* ReturnCode *returnCode = [session getReturnCode]; |
||||
* break; |
||||
* case SessionStateFailed: |
||||
* NSString *failStackTrace = [session getFailStackTrace]; |
||||
* break; |
||||
* } |
||||
* </pre> |
||||
* |
||||
* @param session session of the completed execution |
||||
*/ |
||||
typedef void (^MediaInformationSessionCompleteCallback)(MediaInformationSession* session); |
||||
|
||||
#import "MediaInformationSession.h" |
||||
|
||||
#endif // FFMPEG_KIT_MEDIA_INFORMATION_SESSION_COMPLETE_CALLBACK_H
|
@ -0,0 +1,46 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_PACKAGES_H |
||||
#define FFMPEG_KIT_PACKAGES_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
/**
|
||||
* <p>Helper class to extract binary package information. |
||||
*/ |
||||
@interface Packages : NSObject |
||||
|
||||
/**
|
||||
* Returns the FFmpegKit binary package name. |
||||
* |
||||
* @return predicted FFmpegKit binary package name |
||||
*/ |
||||
+ (NSString*)getPackageName; |
||||
|
||||
/**
|
||||
* Returns enabled external libraries by FFmpeg. |
||||
* |
||||
* @return enabled external libraries |
||||
*/ |
||||
+ (NSArray*)getExternalLibraries; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_PACKAGES_H
|
@ -0,0 +1,48 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_RETURN_CODE_H |
||||
#define FFMPEG_KIT_RETURN_CODE_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
typedef NS_ENUM(NSUInteger, ReturnCodeEnum) { |
||||
ReturnCodeSuccess = 0, |
||||
ReturnCodeCancel = 255 |
||||
}; |
||||
|
||||
@interface ReturnCode : NSObject |
||||
|
||||
- (instancetype)init:(int)value; |
||||
|
||||
+ (BOOL)isSuccess:(ReturnCode*)value; |
||||
|
||||
+ (BOOL)isCancel:(ReturnCode*)value; |
||||
|
||||
- (int)getValue; |
||||
|
||||
- (BOOL)isValueSuccess; |
||||
|
||||
- (BOOL)isValueError; |
||||
|
||||
- (BOOL)isValueCancel; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_RETURN_CODE_H
|
@ -0,0 +1,255 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_SESSION_H |
||||
#define FFMPEG_KIT_SESSION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "Log.h" |
||||
#import "LogCallback.h" |
||||
#import "LogRedirectionStrategy.h" |
||||
#import "ReturnCode.h" |
||||
#import "SessionState.h" |
||||
|
||||
/**
|
||||
* <p>Common interface for all <code>FFmpegKit</code> sessions. |
||||
*/ |
||||
@protocol Session |
||||
|
||||
@required |
||||
|
||||
/**
|
||||
* Returns the session specific log callback. |
||||
* |
||||
* @return session specific log callback |
||||
*/ |
||||
- (LogCallback)getLogCallback; |
||||
|
||||
/**
|
||||
* Returns the session identifier. |
||||
* |
||||
* @return session identifier |
||||
*/ |
||||
- (long)getSessionId; |
||||
|
||||
/**
|
||||
* Returns session create time. |
||||
* |
||||
* @return session create time |
||||
*/ |
||||
- (NSDate*)getCreateTime; |
||||
|
||||
/**
|
||||
* Returns session start time. |
||||
* |
||||
* @return session start time |
||||
*/ |
||||
- (NSDate*)getStartTime; |
||||
|
||||
/**
|
||||
* Returns session end time. |
||||
* |
||||
* @return session end time |
||||
*/ |
||||
- (NSDate*)getEndTime; |
||||
|
||||
/**
|
||||
* Returns the time taken to execute this session. |
||||
* |
||||
* @return time taken to execute this session in milliseconds or zero (0) if the session is |
||||
* not over yet |
||||
*/ |
||||
- (long)getDuration; |
||||
|
||||
/**
|
||||
* Returns command arguments as an array. |
||||
* |
||||
* @return command arguments as an array |
||||
*/ |
||||
- (NSArray*)getArguments; |
||||
|
||||
/**
|
||||
* Returns command arguments as a concatenated string. |
||||
* |
||||
* @return command arguments as a concatenated string |
||||
*/ |
||||
- (NSString*)getCommand; |
||||
|
||||
/**
|
||||
* Returns all log entries generated for this session. If there are asynchronous |
||||
* messages that are not delivered yet, this method waits for them until the given timeout. |
||||
* |
||||
* @param waitTimeout wait timeout for asynchronous messages in milliseconds |
||||
* @return list of log entries generated for this session |
||||
*/ |
||||
- (NSArray*)getAllLogsWithTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* Returns all log entries generated for this session. If there are asynchronous |
||||
* messages that are not delivered yet, this method waits for them. |
||||
* |
||||
* @return list of log entries generated for this session |
||||
*/ |
||||
- (NSArray*)getAllLogs; |
||||
|
||||
/**
|
||||
* Returns all log entries delivered for this session. Note that if there are asynchronous |
||||
* messages that are not delivered yet, this method will not wait for them and will return |
||||
* immediately. |
||||
* |
||||
* @return list of log entries received for this session |
||||
*/ |
||||
- (NSArray*)getLogs; |
||||
|
||||
/**
|
||||
* Returns all log entries generated for this session as a concatenated string. If there are |
||||
* asynchronous messages that are not delivered yet, this method waits for them until |
||||
* the given timeout. |
||||
* |
||||
* @param waitTimeout wait timeout for asynchronous messages in milliseconds |
||||
* @return all log entries generated for this session as a concatenated string |
||||
*/ |
||||
- (NSString*)getAllLogsAsStringWithTimeout:(int)waitTimeout; |
||||
|
||||
/**
|
||||
* Returns all log entries generated for this session as a concatenated string. If there are |
||||
* asynchronous messages that are not delivered yet, this method waits for them. |
||||
* |
||||
* @return all log entries generated for this session as a concatenated string |
||||
*/ |
||||
- (NSString*)getAllLogsAsString; |
||||
|
||||
/**
|
||||
* Returns all log entries delivered for this session as a concatenated string. Note that if |
||||
* there are asynchronous messages that are not delivered yet, this method will not wait |
||||
* for them and will return immediately. |
||||
* |
||||
* @return list of log entries received for this session |
||||
*/ |
||||
- (NSString*)getLogsAsString; |
||||
|
||||
/**
|
||||
* Returns the log output generated while running the session. |
||||
* |
||||
* @return log output generated |
||||
*/ |
||||
- (NSString*)getOutput; |
||||
|
||||
/**
|
||||
* Returns the state of the session. |
||||
* |
||||
* @return state of the session |
||||
*/ |
||||
- (SessionState)getState; |
||||
|
||||
/**
|
||||
* Returns the return code for this session. Note that return code is only set for sessions |
||||
* that end with SessionStateCompleted state. If a session is not started, still running or failed then |
||||
* this method returns nil. |
||||
* |
||||
* @return the return code for this session if the session has completed, nil if session is |
||||
* not started, still running or failed |
||||
*/ |
||||
- (ReturnCode*)getReturnCode; |
||||
|
||||
/**
|
||||
* Returns the stack trace of the exception received while executing this session. |
||||
* <p> |
||||
* The stack trace is only set for sessions that end with SessionStateFailed state. For sessions that has |
||||
* SessionStateCompleted state this method returns nil. |
||||
* |
||||
* @return stack trace of the exception received while executing this session, nil if session |
||||
* is not started, still running or completed |
||||
*/ |
||||
- (NSString*)getFailStackTrace; |
||||
|
||||
/**
|
||||
* Returns session specific log redirection strategy. |
||||
* |
||||
* @return session specific log redirection strategy |
||||
*/ |
||||
- (LogRedirectionStrategy)getLogRedirectionStrategy; |
||||
|
||||
/**
|
||||
* Returns whether there are still asynchronous messages being transmitted for this |
||||
* session or not. |
||||
* |
||||
* @return true if there are still asynchronous messages being transmitted, false |
||||
* otherwise |
||||
*/ |
||||
- (BOOL)thereAreAsynchronousMessagesInTransmit; |
||||
|
||||
/**
|
||||
* Adds a new log entry for this session. |
||||
* |
||||
* It is invoked internally by <code>FFmpegKit</code> library methods. Must not be used by user |
||||
* applications. |
||||
* |
||||
* @param log log entry |
||||
*/ |
||||
- (void)addLog:(Log*)log; |
||||
|
||||
/**
|
||||
* Starts running the session. |
||||
*/ |
||||
- (void)startRunning; |
||||
|
||||
/**
|
||||
* Completes running the session with the provided return code. |
||||
* |
||||
* @param returnCode return code of the execution |
||||
*/ |
||||
- (void)complete:(ReturnCode*)returnCode; |
||||
|
||||
/**
|
||||
* Ends running the session with a failure. |
||||
* |
||||
* @param exception execution received |
||||
*/ |
||||
- (void)fail:(NSException*)exception; |
||||
|
||||
/**
|
||||
* Returns whether it is an <code>FFmpeg</code> session or not. |
||||
* |
||||
* @return true if it is an <code>FFmpeg</code> session, false otherwise |
||||
*/ |
||||
- (BOOL)isFFmpeg; |
||||
|
||||
/**
|
||||
* Returns whether it is an <code>FFprobe</code> session or not. |
||||
* |
||||
* @return true if it is an <code>FFprobe</code> session, false otherwise |
||||
*/ |
||||
- (BOOL)isFFprobe; |
||||
|
||||
/**
|
||||
* Returns whether it is a <code>MediaInformation</code> session or not. |
||||
* |
||||
* @return true if it is a <code>MediaInformation</code> session, false otherwise |
||||
*/ |
||||
- (BOOL)isMediaInformation; |
||||
|
||||
/**
|
||||
* Cancels running the session. |
||||
*/ |
||||
- (void)cancel; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_SESSION_H
|
@ -0,0 +1,30 @@ |
||||
/*
|
||||
* Copyright (c) 2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Lesser General License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General License |
||||
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_SESSION_STATE_H |
||||
#define FFMPEG_KIT_SESSION_STATE_H |
||||
|
||||
typedef NS_ENUM(NSUInteger, SessionState) { |
||||
SessionStateCreated, |
||||
SessionStateRunning, |
||||
SessionStateFailed, |
||||
SessionStateCompleted |
||||
}; |
||||
|
||||
#endif // FFMPEG_KIT_SESSION_STATE_H
|
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_STATISTICS_H |
||||
#define FFMPEG_KIT_STATISTICS_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
/**
|
||||
* Statistics entry for an FFmpeg execute session. |
||||
*/ |
||||
@interface Statistics : NSObject |
||||
|
||||
- (instancetype)init:(long)sessionId videoFrameNumber:(int)videoFrameNumber videoFps:(float)videoFps videoQuality:(float)videoQuality size:(int64_t)size time:(double)time bitrate:(double)bitrate speed:(double)speed; |
||||
|
||||
- (long)getSessionId; |
||||
|
||||
- (int)getVideoFrameNumber; |
||||
|
||||
- (float)getVideoFps; |
||||
|
||||
- (float)getVideoQuality; |
||||
|
||||
- (long)getSize; |
||||
|
||||
- (double)getTime; |
||||
|
||||
- (double)getBitrate; |
||||
|
||||
- (double)getSpeed; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_STATISTICS_H
|
@ -0,0 +1,33 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_STATISTICS_CALLBACK_H |
||||
#define FFMPEG_KIT_STATISTICS_CALLBACK_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "Statistics.h" |
||||
|
||||
/**
|
||||
* <p>Callback that receives statistics generated for <code>FFmpegKit</code> sessions. |
||||
* |
||||
* @param statistics statistics entry |
||||
*/ |
||||
typedef void (^StatisticsCallback)(Statistics* statistics); |
||||
|
||||
#endif // FFMPEG_KIT_STATISTICS_CALLBACK_H
|
@ -0,0 +1,207 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_STREAM_INFORMATION_H |
||||
#define FFMPEG_KIT_STREAM_INFORMATION_H |
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
extern NSString* const StreamKeyIndex; |
||||
extern NSString* const StreamKeyType; |
||||
extern NSString* const StreamKeyCodec; |
||||
extern NSString* const StreamKeyCodecLong; |
||||
extern NSString* const StreamKeyFormat; |
||||
extern NSString* const StreamKeyWidth; |
||||
extern NSString* const StreamKeyHeight; |
||||
extern NSString* const StreamKeyBitRate; |
||||
extern NSString* const StreamKeySampleRate; |
||||
extern NSString* const StreamKeySampleFormat; |
||||
extern NSString* const StreamKeyChannelLayout; |
||||
extern NSString* const StreamKeySampleAspectRatio; |
||||
extern NSString* const StreamKeyDisplayAspectRatio; |
||||
extern NSString* const StreamKeyAverageFrameRate; |
||||
extern NSString* const StreamKeyRealFrameRate; |
||||
extern NSString* const StreamKeyTimeBase; |
||||
extern NSString* const StreamKeyCodecTimeBase; |
||||
extern NSString* const StreamKeyTags; |
||||
|
||||
/**
|
||||
* Stream information class. |
||||
*/ |
||||
@interface StreamInformation : NSObject |
||||
|
||||
- (instancetype)init:(NSDictionary*)streamDictionary; |
||||
|
||||
/**
|
||||
* Returns stream index. |
||||
* |
||||
* @return stream index, starting from zero |
||||
*/ |
||||
- (NSNumber*)getIndex; |
||||
|
||||
/**
|
||||
* Returns stream type. |
||||
* |
||||
* @return stream type; audio or video |
||||
*/ |
||||
- (NSString*)getType; |
||||
|
||||
/**
|
||||
* Returns stream codec. |
||||
* |
||||
* @return stream codec |
||||
*/ |
||||
- (NSString*)getCodec; |
||||
|
||||
/**
|
||||
* Returns stream codec in long format. |
||||
* |
||||
* @return stream codec with additional profile and mode information |
||||
*/ |
||||
- (NSString*)getCodecLong; |
||||
|
||||
/**
|
||||
* Returns stream format. |
||||
* |
||||
* @return stream format |
||||
*/ |
||||
- (NSString*)getFormat; |
||||
|
||||
/**
|
||||
* Returns width. |
||||
* |
||||
* @return width in pixels |
||||
*/ |
||||
- (NSNumber*)getWidth; |
||||
|
||||
/**
|
||||
* Returns height. |
||||
* |
||||
* @return height in pixels |
||||
*/ |
||||
- (NSNumber*)getHeight; |
||||
|
||||
/**
|
||||
* Returns bitrate. |
||||
* |
||||
* @return bitrate in kb/s |
||||
*/ |
||||
- (NSString*)getBitrate; |
||||
|
||||
/**
|
||||
* Returns sample rate. |
||||
* |
||||
* @return sample rate in hz |
||||
*/ |
||||
- (NSString*)getSampleRate; |
||||
|
||||
/**
|
||||
* Returns sample format. |
||||
* |
||||
* @return sample format |
||||
*/ |
||||
- (NSString*)getSampleFormat; |
||||
|
||||
/**
|
||||
* Returns channel layout. |
||||
* |
||||
* @return channel layout |
||||
*/ |
||||
- (NSString*)getChannelLayout; |
||||
|
||||
/**
|
||||
* Returns sample aspect ratio. |
||||
* |
||||
* @return sample aspect ratio |
||||
*/ |
||||
- (NSString*)getSampleAspectRatio; |
||||
|
||||
/**
|
||||
* Returns display aspect ratio. |
||||
* |
||||
* @return display aspect ratio |
||||
*/ |
||||
- (NSString*)getDisplayAspectRatio; |
||||
|
||||
/**
|
||||
* Returns average frame rate. |
||||
* |
||||
* @return average frame rate in fps |
||||
*/ |
||||
- (NSString*)getAverageFrameRate; |
||||
|
||||
/**
|
||||
* Returns real frame rate. |
||||
* |
||||
* @return real frame rate in tbr |
||||
*/ |
||||
- (NSString*)getRealFrameRate; |
||||
|
||||
/**
|
||||
* Returns time base. |
||||
* |
||||
* @return time base in tbn |
||||
*/ |
||||
- (NSString*)getTimeBase; |
||||
|
||||
/**
|
||||
* Returns codec time base. |
||||
* |
||||
* @return codec time base in tbc |
||||
*/ |
||||
- (NSString*)getCodecTimeBase; |
||||
|
||||
/**
|
||||
* Returns all tags. |
||||
* |
||||
* @return tags dictionary |
||||
*/ |
||||
- (NSDictionary*)getTags; |
||||
|
||||
/**
|
||||
* Returns the stream property associated with the key. |
||||
* |
||||
* @return stream property as string or nil if the key is not found |
||||
*/ |
||||
- (NSString*)getStringProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the stream property associated with the key. |
||||
* |
||||
* @return stream property as number or nil if the key is not found |
||||
*/ |
||||
- (NSNumber*)getNumberProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns the stream property associated with the key. |
||||
* |
||||
* @return stream property as id or nil if the key is not found |
||||
*/ |
||||
- (id)getProperty:(NSString*)key; |
||||
|
||||
/**
|
||||
* Returns all stream properties defined. |
||||
* |
||||
* @return all stream properties in a dictionary or nil if no properties are defined |
||||
*/ |
||||
- (NSDictionary*)getAllProperties; |
||||
|
||||
@end |
||||
|
||||
#endif // FFMPEG_KIT_STREAM_INFORMATION_H
|
@ -0,0 +1,29 @@ |
||||
/*
|
||||
* Copyright (c) 2018-2021 Taner Sener |
||||
* |
||||
* This file is part of FFmpegKit. |
||||
* |
||||
* FFmpegKit 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 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FFmpegKit 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 FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef FFMPEG_KIT_EXCEPTION_H |
||||
#define FFMPEG_KIT_EXCEPTION_H |
||||
|
||||
#include <stdio.h> |
||||
#include <setjmp.h> |
||||
|
||||
/** Holds information to implement exception handling. */ |
||||
extern __thread jmp_buf ex_buf__; |
||||
|
||||
#endif // FFMPEG_KIT_EXCEPTION_H
|
@ -0,0 +1,516 @@ |
||||
/*
|
||||
* Various utilities for command line tools |
||||
* copyright (c) 2003 Fabrice Bellard |
||||
* copyright (c) 2018-2022 Taner Sener |
||||
* copyright (c) 2023 ARTHENICA LTD |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of cmdutils.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries. |
||||
* |
||||
* ffmpeg-kit changes by ARTHENICA LTD |
||||
* |
||||
* 07.2023 |
||||
* -------------------------------------------------------- |
||||
* - FFmpeg 6.0 changes migrated |
||||
* |
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener |
||||
* |
||||
* 09.2022 |
||||
* -------------------------------------------------------- |
||||
* - config.h include added back |
||||
* |
||||
* 01.2020 |
||||
* -------------------------------------------------------- |
||||
* - ffprobe support added (variables used by ffprobe marked with "__thread" specifier) |
||||
* - AV_LOG_STDERR log level added |
||||
* |
||||
* 12.2019 |
||||
* -------------------------------------------------------- |
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads) |
||||
* |
||||
* 03.2019 |
||||
* -------------------------------------------------------- |
||||
* - config.h include removed |
||||
* |
||||
* 08.2018 |
||||
* -------------------------------------------------------- |
||||
* - fftools_ prefix added to file name and include guards |
||||
* |
||||
* 07.2018 |
||||
* -------------------------------------------------------- |
||||
* - include guards renamed |
||||
* - unused headers removed |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_CMDUTILS_H |
||||
#define FFTOOLS_CMDUTILS_H |
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include "config.h" |
||||
#include "libavcodec/avcodec.h" |
||||
#include "libavfilter/avfilter.h" |
||||
#include "libavformat/avformat.h" |
||||
#include "libswscale/swscale.h" |
||||
|
||||
#ifdef _WIN32 |
||||
#undef main /* We don't want SDL to override our main() */ |
||||
#endif |
||||
|
||||
/**
|
||||
* Defines logs printed to stderr by ffmpeg. They are not filtered and always redirected. |
||||
*/ |
||||
#define AV_LOG_STDERR -16 |
||||
|
||||
/**
|
||||
* program name, defined by the program for show_version(). |
||||
*/ |
||||
extern __thread char *program_name; |
||||
|
||||
/**
|
||||
* program birth year, defined by the program for show_banner() |
||||
*/ |
||||
extern __thread int program_birth_year; |
||||
|
||||
extern __thread AVDictionary *sws_dict; |
||||
extern __thread AVDictionary *swr_opts; |
||||
extern __thread AVDictionary *format_opts, *codec_opts; |
||||
extern __thread int hide_banner; |
||||
extern __thread int find_stream_info; |
||||
|
||||
/**
|
||||
* Register a program-specific cleanup routine. |
||||
*/ |
||||
void register_exit(void (*cb)(int ret)); |
||||
|
||||
/**
|
||||
* Reports an error corresponding to the provided |
||||
* AVERROR code and calls exit_program() with the |
||||
* corresponding POSIX error code. |
||||
* @note ret must be an AVERROR-value of a POSIX error code |
||||
* (i.e. AVERROR(EFOO) and not AVERROR_FOO). |
||||
* library functions can return both, so call this only |
||||
* with AVERROR(EFOO) of your own. |
||||
*/ |
||||
void report_and_exit(int ret) av_noreturn; |
||||
|
||||
/**
|
||||
* Wraps exit with a program-specific cleanup routine. |
||||
*/ |
||||
void exit_program(int ret) av_noreturn; |
||||
|
||||
/**
|
||||
* Initialize dynamic library loading |
||||
*/ |
||||
void init_dynload(void); |
||||
|
||||
/**
|
||||
* Uninitialize the cmdutils option system, in particular |
||||
* free the *_opts contexts and their contents. |
||||
*/ |
||||
void uninit_opts(void); |
||||
|
||||
/**
|
||||
* Trivial log callback. |
||||
* Only suitable for opt_help and similar since it lacks prefix handling. |
||||
*/ |
||||
void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); |
||||
|
||||
/**
|
||||
* Fallback for options that are not explicitly handled, these will be |
||||
* parsed through AVOptions. |
||||
*/ |
||||
int opt_default(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Limit the execution time. |
||||
*/ |
||||
int opt_timelimit(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Parse a string and return its corresponding value as a double. |
||||
* Exit from the application if the string cannot be correctly |
||||
* parsed or the corresponding value is invalid. |
||||
* |
||||
* @param context the context of the value to be set (e.g. the |
||||
* corresponding command line option name) |
||||
* @param numstr the string to be parsed |
||||
* @param type the type (OPT_INT64 or OPT_FLOAT) as which the |
||||
* string should be parsed |
||||
* @param min the minimum valid accepted value |
||||
* @param max the maximum valid accepted value |
||||
*/ |
||||
double parse_number_or_die(const char *context, const char *numstr, int type, |
||||
double min, double max); |
||||
|
||||
/**
|
||||
* Parse a string specifying a time and return its corresponding |
||||
* value as a number of microseconds. Exit from the application if |
||||
* the string cannot be correctly parsed. |
||||
* |
||||
* @param context the context of the value to be set (e.g. the |
||||
* corresponding command line option name) |
||||
* @param timestr the string to be parsed |
||||
* @param is_duration a flag which tells how to interpret timestr, if |
||||
* not zero timestr is interpreted as a duration, otherwise as a |
||||
* date |
||||
* |
||||
* @see av_parse_time() |
||||
*/ |
||||
int64_t parse_time_or_die(const char *context, const char *timestr, |
||||
int is_duration); |
||||
|
||||
typedef struct SpecifierOpt { |
||||
char *specifier; /**< stream/chapter/program/... specifier */ |
||||
union { |
||||
uint8_t *str; |
||||
int i; |
||||
int64_t i64; |
||||
uint64_t ui64; |
||||
float f; |
||||
double dbl; |
||||
} u; |
||||
} SpecifierOpt; |
||||
|
||||
typedef struct OptionDef { |
||||
const char *name; |
||||
int flags; |
||||
#define HAS_ARG 0x0001 |
||||
#define OPT_BOOL 0x0002 |
||||
#define OPT_EXPERT 0x0004 |
||||
#define OPT_STRING 0x0008 |
||||
#define OPT_VIDEO 0x0010 |
||||
#define OPT_AUDIO 0x0020 |
||||
#define OPT_INT 0x0080 |
||||
#define OPT_FLOAT 0x0100 |
||||
#define OPT_SUBTITLE 0x0200 |
||||
#define OPT_INT64 0x0400 |
||||
#define OPT_EXIT 0x0800 |
||||
#define OPT_DATA 0x1000 |
||||
#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only). |
||||
implied by OPT_OFFSET or OPT_SPEC */ |
||||
#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */ |
||||
#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt. |
||||
Implies OPT_OFFSET. Next element after the offset is |
||||
an int containing element count in the array. */ |
||||
#define OPT_TIME 0x10000 |
||||
#define OPT_DOUBLE 0x20000 |
||||
#define OPT_INPUT 0x40000 |
||||
#define OPT_OUTPUT 0x80000 |
||||
union { |
||||
void *dst_ptr; |
||||
int (*func_arg)(void *, const char *, const char *); |
||||
size_t off; |
||||
} u; |
||||
const char *help; |
||||
const char *argname; |
||||
} OptionDef; |
||||
|
||||
/**
|
||||
* Print help for all options matching specified flags. |
||||
* |
||||
* @param options a list of options |
||||
* @param msg title of this group. Only printed if at least one option matches. |
||||
* @param req_flags print only options which have all those flags set. |
||||
* @param rej_flags don't print options which have any of those flags set. |
||||
* @param alt_flags print only options that have at least one of those flags set |
||||
*/ |
||||
void show_help_options(const OptionDef *options, const char *msg, int req_flags, |
||||
int rej_flags, int alt_flags); |
||||
|
||||
/**
|
||||
* Show help for all options with given flags in class and all its |
||||
* children. |
||||
*/ |
||||
void show_help_children(const AVClass *clazz, int flags); |
||||
|
||||
/**
|
||||
* Per-fftool specific help handler. Implemented in each |
||||
* fftool, called by show_help(). |
||||
*/ |
||||
void show_help_default_ffmpeg(const char *opt, const char *arg); |
||||
void show_help_default_ffprobe(const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Parse the command line arguments. |
||||
* |
||||
* @param optctx an opaque options context |
||||
* @param argc number of command line arguments |
||||
* @param argv values of command line arguments |
||||
* @param options Array with the definitions required to interpret every |
||||
* option of the form: -option_name [argument] |
||||
* @param parse_arg_function Name of the function called to process every |
||||
* argument without a leading option name flag. NULL if such arguments do |
||||
* not have to be processed. |
||||
*/ |
||||
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, |
||||
void (* parse_arg_function)(void *optctx, const char*)); |
||||
|
||||
/**
|
||||
* Parse one given option. |
||||
* |
||||
* @return on success 1 if arg was consumed, 0 otherwise; negative number on error |
||||
*/ |
||||
int parse_option(void *optctx, const char *opt, const char *arg, |
||||
const OptionDef *options); |
||||
|
||||
/**
|
||||
* An option extracted from the commandline. |
||||
* Cannot use AVDictionary because of options like -map which can be |
||||
* used multiple times. |
||||
*/ |
||||
typedef struct Option { |
||||
const OptionDef *opt; |
||||
const char *key; |
||||
const char *val; |
||||
} Option; |
||||
|
||||
typedef struct OptionGroupDef { |
||||
/**< group name */ |
||||
const char *name; |
||||
/**
|
||||
* Option to be used as group separator. Can be NULL for groups which |
||||
* are terminated by a non-option argument (e.g. ffmpeg output files) |
||||
*/ |
||||
const char *sep; |
||||
/**
|
||||
* Option flags that must be set on each option that is |
||||
* applied to this group |
||||
*/ |
||||
int flags; |
||||
} OptionGroupDef; |
||||
|
||||
typedef struct OptionGroup { |
||||
const OptionGroupDef *group_def; |
||||
const char *arg; |
||||
|
||||
Option *opts; |
||||
int nb_opts; |
||||
|
||||
AVDictionary *codec_opts; |
||||
AVDictionary *format_opts; |
||||
AVDictionary *sws_dict; |
||||
AVDictionary *swr_opts; |
||||
} OptionGroup; |
||||
|
||||
/**
|
||||
* A list of option groups that all have the same group type |
||||
* (e.g. input files or output files) |
||||
*/ |
||||
typedef struct OptionGroupList { |
||||
const OptionGroupDef *group_def; |
||||
|
||||
OptionGroup *groups; |
||||
int nb_groups; |
||||
} OptionGroupList; |
||||
|
||||
typedef struct OptionParseContext { |
||||
OptionGroup global_opts; |
||||
|
||||
OptionGroupList *groups; |
||||
int nb_groups; |
||||
|
||||
/* parsing state */ |
||||
OptionGroup cur_group; |
||||
} OptionParseContext; |
||||
|
||||
/**
|
||||
* Parse an options group and write results into optctx. |
||||
* |
||||
* @param optctx an app-specific options context. NULL for global options group |
||||
* @param g option group |
||||
*/ |
||||
int parse_optgroup(void *optctx, OptionGroup *g); |
||||
|
||||
/**
|
||||
* Split the commandline into an intermediate form convenient for further |
||||
* processing. |
||||
* |
||||
* The commandline is assumed to be composed of options which either belong to a |
||||
* group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global |
||||
* (everything else). |
||||
* |
||||
* A group (defined by an OptionGroupDef struct) is a sequence of options |
||||
* terminated by either a group separator option (e.g. -i) or a parameter that |
||||
* is not an option (doesn't start with -). A group without a separator option |
||||
* must always be first in the supplied groups list. |
||||
* |
||||
* All options within the same group are stored in one OptionGroup struct in an |
||||
* OptionGroupList, all groups with the same group definition are stored in one |
||||
* OptionGroupList in OptionParseContext.groups. The order of group lists is the |
||||
* same as the order of group definitions. |
||||
*/ |
||||
int split_commandline(OptionParseContext *octx, int argc, char *argv[], |
||||
const OptionDef *options, |
||||
const OptionGroupDef *groups, int nb_groups); |
||||
|
||||
/**
|
||||
* Free all allocated memory in an OptionParseContext. |
||||
*/ |
||||
void uninit_parse_context(OptionParseContext *octx); |
||||
|
||||
/**
|
||||
* Find the '-loglevel' option in the command line args and apply it. |
||||
*/ |
||||
void parse_loglevel(int argc, char **argv, const OptionDef *options); |
||||
|
||||
/**
|
||||
* Return index of option opt in argv or 0 if not found. |
||||
*/ |
||||
int locate_option(int argc, char **argv, const OptionDef *options, |
||||
const char *optname); |
||||
|
||||
/**
|
||||
* Check if the given stream matches a stream specifier. |
||||
* |
||||
* @param s Corresponding format context. |
||||
* @param st Stream from s to be checked. |
||||
* @param spec A stream specifier of the [v|a|s|d]:[\<stream index\>] form. |
||||
* |
||||
* @return 1 if the stream matches, 0 if it doesn't, <0 on error |
||||
*/ |
||||
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec); |
||||
|
||||
/**
|
||||
* Filter out options for given codec. |
||||
* |
||||
* Create a new options dictionary containing only the options from |
||||
* opts which apply to the codec with ID codec_id. |
||||
* |
||||
* @param opts dictionary to place options in |
||||
* @param codec_id ID of the codec that should be filtered for |
||||
* @param s Corresponding format context. |
||||
* @param st A stream from s for which the options should be filtered. |
||||
* @param codec The particular codec for which the options should be filtered. |
||||
* If null, the default one is looked up according to the codec id. |
||||
* @return a pointer to the created dictionary |
||||
*/ |
||||
AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, |
||||
AVFormatContext *s, AVStream *st, const AVCodec *codec); |
||||
|
||||
/**
|
||||
* Setup AVCodecContext options for avformat_find_stream_info(). |
||||
* |
||||
* Create an array of dictionaries, one dictionary for each stream |
||||
* contained in s. |
||||
* Each dictionary will contain the options from codec_opts which can |
||||
* be applied to the corresponding stream codec context. |
||||
* |
||||
* @return pointer to the created array of dictionaries. |
||||
* Calls exit() on failure. |
||||
*/ |
||||
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, |
||||
AVDictionary *codec_opts); |
||||
|
||||
/**
|
||||
* Print an error message to stderr, indicating filename and a human |
||||
* readable description of the error code err. |
||||
* |
||||
* If strerror_r() is not available the use of this function in a |
||||
* multithreaded application may be unsafe. |
||||
* |
||||
* @see av_strerror() |
||||
*/ |
||||
void print_error(const char *filename, int err); |
||||
|
||||
/**
|
||||
* Print the program banner to stderr. The banner contents depend on the |
||||
* current version of the repository and of the libav* libraries used by |
||||
* the program. |
||||
*/ |
||||
void show_banner(int argc, char **argv, const OptionDef *options); |
||||
|
||||
/**
|
||||
* Return a positive value if a line read from standard input |
||||
* starts with [yY], otherwise return 0. |
||||
*/ |
||||
int read_yesno(void); |
||||
|
||||
/**
|
||||
* Get a file corresponding to a preset file. |
||||
* |
||||
* If is_path is non-zero, look for the file in the path preset_name. |
||||
* Otherwise search for a file named arg.ffpreset in the directories |
||||
* $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined |
||||
* at configuration time or in a "ffpresets" folder along the executable |
||||
* on win32, in that order. If no such file is found and |
||||
* codec_name is defined, then search for a file named |
||||
* codec_name-preset_name.avpreset in the above-mentioned directories. |
||||
* |
||||
* @param filename buffer where the name of the found filename is written |
||||
* @param filename_size size in bytes of the filename buffer |
||||
* @param preset_name name of the preset to search |
||||
* @param is_path tell if preset_name is a filename path |
||||
* @param codec_name name of the codec for which to look for the |
||||
* preset, may be NULL |
||||
*/ |
||||
FILE *get_preset_file(char *filename, size_t filename_size, |
||||
const char *preset_name, int is_path, const char *codec_name); |
||||
|
||||
/**
|
||||
* Realloc array to hold new_size elements of elem_size. |
||||
* Calls exit() on failure. |
||||
* |
||||
* @param array array to reallocate |
||||
* @param elem_size size in bytes of each element |
||||
* @param size new element count will be written here |
||||
* @param new_size number of elements to place in reallocated array |
||||
* @return reallocated array |
||||
*/ |
||||
void *grow_array(void *array, int elem_size, int *size, int new_size); |
||||
|
||||
/**
|
||||
* Atomically add a new element to an array of pointers, i.e. allocate |
||||
* a new entry, reallocate the array of pointers and make the new last |
||||
* member of this array point to the newly allocated buffer. |
||||
* Calls exit() on failure. |
||||
* |
||||
* @param array array of pointers to reallocate |
||||
* @param elem_size size of the new element to allocate |
||||
* @param nb_elems pointer to the number of elements of the array array; |
||||
* *nb_elems will be incremented by one by this function. |
||||
* @return pointer to the newly allocated entry |
||||
*/ |
||||
void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); |
||||
|
||||
#define GROW_ARRAY(array, nb_elems)\ |
||||
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1) |
||||
|
||||
#define ALLOC_ARRAY_ELEM(array, nb_elems)\ |
||||
allocate_array_elem(&array, sizeof(*array[0]), &nb_elems) |
||||
|
||||
#define GET_PIX_FMT_NAME(pix_fmt)\ |
||||
const char *name = av_get_pix_fmt_name(pix_fmt); |
||||
|
||||
#define GET_CODEC_NAME(id)\ |
||||
const char *name = avcodec_descriptor_get(id)->name; |
||||
|
||||
#define GET_SAMPLE_FMT_NAME(sample_fmt)\ |
||||
const char *name = av_get_sample_fmt_name(sample_fmt) |
||||
|
||||
#define GET_SAMPLE_RATE_NAME(rate)\ |
||||
char name[16];\
|
||||
snprintf(name, sizeof(name), "%d", rate); |
||||
|
||||
double get_rotation(int32_t *displaymatrix); |
||||
|
||||
#endif /* FFTOOLS_CMDUTILS_H */ |
@ -0,0 +1,912 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* Copyright (c) 2018-2022 Taner Sener |
||||
* Copyright (c) 2023 ARTHENICA LTD |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of ffmpeg.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries. |
||||
* |
||||
* ffmpeg-kit changes by ARTHENICA LTD |
||||
* |
||||
* 07.2023 |
||||
* -------------------------------------------------------- |
||||
* - FFmpeg 6.0 changes migrated |
||||
* - WARN_MULTIPLE_OPT_USAGE, MATCH_PER_STREAM_OPT, MATCH_PER_TYPE_OPT, SPECIFIER_OPT_FMT declarations migrated to |
||||
* ffmpeg_mux.h |
||||
* - "class" member field renamed as clazz |
||||
* - time field in set_report_callback updated as double |
||||
* |
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener |
||||
* |
||||
* 09.2022 |
||||
* -------------------------------------------------------- |
||||
* - config.h include added back |
||||
* - volatile dropped from thread local variables |
||||
* - dropped signatures of ffmpeg_opt.c methods called by both ffmpeg and ffprobe |
||||
* |
||||
* 06.2020 |
||||
* -------------------------------------------------------- |
||||
* - cancel_operation() method signature updated with id |
||||
* |
||||
* 12.2019 |
||||
* -------------------------------------------------------- |
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads, |
||||
* signatures of ffmpeg_opt.c methods called by both ffmpeg and ffprobe added) |
||||
* |
||||
* 03.2019 |
||||
* -------------------------------------------------------- |
||||
* - config.h include removed |
||||
* |
||||
* 08.2018 |
||||
* -------------------------------------------------------- |
||||
* - fftools_ prefix added to file name and include guards |
||||
* - set_report_callback() method declared |
||||
* - cancel_operation() method declared |
||||
* |
||||
* 07.2018 |
||||
* -------------------------------------------------------- |
||||
* - include guards renamed |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_FFMPEG_H |
||||
#define FFTOOLS_FFMPEG_H |
||||
|
||||
#include "config.h" |
||||
|
||||
#include <stdatomic.h> |
||||
#include <stdint.h> |
||||
#include <stdio.h> |
||||
#include <signal.h> |
||||
|
||||
#include "fftools_cmdutils.h" |
||||
#include "fftools_sync_queue.h" |
||||
|
||||
#include "libavformat/avformat.h" |
||||
#include "libavformat/avio.h" |
||||
|
||||
#include "libavcodec/avcodec.h" |
||||
#include "libavcodec/bsf.h" |
||||
|
||||
#include "libavfilter/avfilter.h" |
||||
|
||||
#include "libavutil/avutil.h" |
||||
#include "libavutil/dict.h" |
||||
#include "libavutil/eval.h" |
||||
#include "libavutil/fifo.h" |
||||
#include "libavutil/hwcontext.h" |
||||
#include "libavutil/pixfmt.h" |
||||
#include "libavutil/rational.h" |
||||
#include "libavutil/thread.h" |
||||
#include "libavutil/threadmessage.h" |
||||
|
||||
#include "libswresample/swresample.h" |
||||
|
||||
// deprecated features
|
||||
#define FFMPEG_OPT_PSNR 1 |
||||
#define FFMPEG_OPT_MAP_CHANNEL 1 |
||||
#define FFMPEG_OPT_MAP_SYNC 1 |
||||
#define FFMPEG_ROTATION_METADATA 1 |
||||
|
||||
enum VideoSyncMethod { |
||||
VSYNC_AUTO = -1, |
||||
VSYNC_PASSTHROUGH, |
||||
VSYNC_CFR, |
||||
VSYNC_VFR, |
||||
VSYNC_VSCFR, |
||||
VSYNC_DROP, |
||||
}; |
||||
|
||||
#define MAX_STREAMS 1024 /* arbitrary sanity check value */ |
||||
|
||||
enum HWAccelID { |
||||
HWACCEL_NONE = 0, |
||||
HWACCEL_AUTO, |
||||
HWACCEL_GENERIC, |
||||
}; |
||||
|
||||
typedef struct HWDevice { |
||||
const char *name; |
||||
enum AVHWDeviceType type; |
||||
AVBufferRef *device_ref; |
||||
} HWDevice; |
||||
|
||||
/* select an input stream for an output stream */ |
||||
typedef struct StreamMap { |
||||
int disabled; /* 1 is this mapping is disabled by a negative map */ |
||||
int file_index; |
||||
int stream_index; |
||||
char *linklabel; /* name of an output link, for mapping lavfi outputs */ |
||||
} StreamMap; |
||||
|
||||
#if FFMPEG_OPT_MAP_CHANNEL |
||||
typedef struct { |
||||
int file_idx, stream_idx, channel_idx; // input
|
||||
int ofile_idx, ostream_idx; // output
|
||||
} AudioChannelMap; |
||||
#endif |
||||
|
||||
typedef struct OptionsContext { |
||||
OptionGroup *g; |
||||
|
||||
/* input/output options */ |
||||
int64_t start_time; |
||||
int64_t start_time_eof; |
||||
int seek_timestamp; |
||||
const char *format; |
||||
|
||||
SpecifierOpt *codec_names; |
||||
int nb_codec_names; |
||||
SpecifierOpt *audio_ch_layouts; |
||||
int nb_audio_ch_layouts; |
||||
SpecifierOpt *audio_channels; |
||||
int nb_audio_channels; |
||||
SpecifierOpt *audio_sample_rate; |
||||
int nb_audio_sample_rate; |
||||
SpecifierOpt *frame_rates; |
||||
int nb_frame_rates; |
||||
SpecifierOpt *max_frame_rates; |
||||
int nb_max_frame_rates; |
||||
SpecifierOpt *frame_sizes; |
||||
int nb_frame_sizes; |
||||
SpecifierOpt *frame_pix_fmts; |
||||
int nb_frame_pix_fmts; |
||||
|
||||
/* input options */ |
||||
int64_t input_ts_offset; |
||||
int loop; |
||||
int rate_emu; |
||||
float readrate; |
||||
int accurate_seek; |
||||
int thread_queue_size; |
||||
int input_sync_ref; |
||||
int find_stream_info; |
||||
|
||||
SpecifierOpt *ts_scale; |
||||
int nb_ts_scale; |
||||
SpecifierOpt *dump_attachment; |
||||
int nb_dump_attachment; |
||||
SpecifierOpt *hwaccels; |
||||
int nb_hwaccels; |
||||
SpecifierOpt *hwaccel_devices; |
||||
int nb_hwaccel_devices; |
||||
SpecifierOpt *hwaccel_output_formats; |
||||
int nb_hwaccel_output_formats; |
||||
SpecifierOpt *autorotate; |
||||
int nb_autorotate; |
||||
|
||||
/* output options */ |
||||
StreamMap *stream_maps; |
||||
int nb_stream_maps; |
||||
#if FFMPEG_OPT_MAP_CHANNEL |
||||
AudioChannelMap *audio_channel_maps; /* one info entry per -map_channel */ |
||||
int nb_audio_channel_maps; /* number of (valid) -map_channel settings */ |
||||
#endif |
||||
const char **attachments; |
||||
int nb_attachments; |
||||
|
||||
int chapters_input_file; |
||||
|
||||
int64_t recording_time; |
||||
int64_t stop_time; |
||||
int64_t limit_filesize; |
||||
float mux_preload; |
||||
float mux_max_delay; |
||||
float shortest_buf_duration; |
||||
int shortest; |
||||
int bitexact; |
||||
|
||||
int video_disable; |
||||
int audio_disable; |
||||
int subtitle_disable; |
||||
int data_disable; |
||||
|
||||
/* indexed by output file stream index */ |
||||
int *streamid_map; |
||||
int nb_streamid_map; |
||||
|
||||
SpecifierOpt *metadata; |
||||
int nb_metadata; |
||||
SpecifierOpt *max_frames; |
||||
int nb_max_frames; |
||||
SpecifierOpt *bitstream_filters; |
||||
int nb_bitstream_filters; |
||||
SpecifierOpt *codec_tags; |
||||
int nb_codec_tags; |
||||
SpecifierOpt *sample_fmts; |
||||
int nb_sample_fmts; |
||||
SpecifierOpt *qscale; |
||||
int nb_qscale; |
||||
SpecifierOpt *forced_key_frames; |
||||
int nb_forced_key_frames; |
||||
SpecifierOpt *fps_mode; |
||||
int nb_fps_mode; |
||||
SpecifierOpt *force_fps; |
||||
int nb_force_fps; |
||||
SpecifierOpt *frame_aspect_ratios; |
||||
int nb_frame_aspect_ratios; |
||||
SpecifierOpt *display_rotations; |
||||
int nb_display_rotations; |
||||
SpecifierOpt *display_hflips; |
||||
int nb_display_hflips; |
||||
SpecifierOpt *display_vflips; |
||||
int nb_display_vflips; |
||||
SpecifierOpt *rc_overrides; |
||||
int nb_rc_overrides; |
||||
SpecifierOpt *intra_matrices; |
||||
int nb_intra_matrices; |
||||
SpecifierOpt *inter_matrices; |
||||
int nb_inter_matrices; |
||||
SpecifierOpt *chroma_intra_matrices; |
||||
int nb_chroma_intra_matrices; |
||||
SpecifierOpt *top_field_first; |
||||
int nb_top_field_first; |
||||
SpecifierOpt *metadata_map; |
||||
int nb_metadata_map; |
||||
SpecifierOpt *presets; |
||||
int nb_presets; |
||||
SpecifierOpt *copy_initial_nonkeyframes; |
||||
int nb_copy_initial_nonkeyframes; |
||||
SpecifierOpt *copy_prior_start; |
||||
int nb_copy_prior_start; |
||||
SpecifierOpt *filters; |
||||
int nb_filters; |
||||
SpecifierOpt *filter_scripts; |
||||
int nb_filter_scripts; |
||||
SpecifierOpt *reinit_filters; |
||||
int nb_reinit_filters; |
||||
SpecifierOpt *fix_sub_duration; |
||||
int nb_fix_sub_duration; |
||||
SpecifierOpt *fix_sub_duration_heartbeat; |
||||
int nb_fix_sub_duration_heartbeat; |
||||
SpecifierOpt *canvas_sizes; |
||||
int nb_canvas_sizes; |
||||
SpecifierOpt *pass; |
||||
int nb_pass; |
||||
SpecifierOpt *passlogfiles; |
||||
int nb_passlogfiles; |
||||
SpecifierOpt *max_muxing_queue_size; |
||||
int nb_max_muxing_queue_size; |
||||
SpecifierOpt *muxing_queue_data_threshold; |
||||
int nb_muxing_queue_data_threshold; |
||||
SpecifierOpt *guess_layout_max; |
||||
int nb_guess_layout_max; |
||||
SpecifierOpt *apad; |
||||
int nb_apad; |
||||
SpecifierOpt *discard; |
||||
int nb_discard; |
||||
SpecifierOpt *disposition; |
||||
int nb_disposition; |
||||
SpecifierOpt *program; |
||||
int nb_program; |
||||
SpecifierOpt *time_bases; |
||||
int nb_time_bases; |
||||
SpecifierOpt *enc_time_bases; |
||||
int nb_enc_time_bases; |
||||
SpecifierOpt *autoscale; |
||||
int nb_autoscale; |
||||
SpecifierOpt *bits_per_raw_sample; |
||||
int nb_bits_per_raw_sample; |
||||
SpecifierOpt *enc_stats_pre; |
||||
int nb_enc_stats_pre; |
||||
SpecifierOpt *enc_stats_post; |
||||
int nb_enc_stats_post; |
||||
SpecifierOpt *mux_stats; |
||||
int nb_mux_stats; |
||||
SpecifierOpt *enc_stats_pre_fmt; |
||||
int nb_enc_stats_pre_fmt; |
||||
SpecifierOpt *enc_stats_post_fmt; |
||||
int nb_enc_stats_post_fmt; |
||||
SpecifierOpt *mux_stats_fmt; |
||||
int nb_mux_stats_fmt; |
||||
} OptionsContext; |
||||
|
||||
typedef struct InputFilter { |
||||
AVFilterContext *filter; |
||||
struct InputStream *ist; |
||||
struct FilterGraph *graph; |
||||
uint8_t *name; |
||||
enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video
|
||||
|
||||
AVFifo *frame_queue; |
||||
|
||||
// parameters configured for this input
|
||||
int format; |
||||
|
||||
int width, height; |
||||
AVRational sample_aspect_ratio; |
||||
|
||||
int sample_rate; |
||||
AVChannelLayout ch_layout; |
||||
|
||||
AVBufferRef *hw_frames_ctx; |
||||
int32_t *displaymatrix; |
||||
|
||||
int eof; |
||||
} InputFilter; |
||||
|
||||
typedef struct OutputFilter { |
||||
AVFilterContext *filter; |
||||
struct OutputStream *ost; |
||||
struct FilterGraph *graph; |
||||
uint8_t *name; |
||||
|
||||
/* temporary storage until stream maps are processed */ |
||||
AVFilterInOut *out_tmp; |
||||
enum AVMediaType type; |
||||
|
||||
/* desired output stream properties */ |
||||
int width, height; |
||||
AVRational frame_rate; |
||||
int format; |
||||
int sample_rate; |
||||
AVChannelLayout ch_layout; |
||||
|
||||
// those are only set if no format is specified and the encoder gives us multiple options
|
||||
// They point directly to the relevant lists of the encoder.
|
||||
const int *formats; |
||||
const AVChannelLayout *ch_layouts; |
||||
const int *sample_rates; |
||||
} OutputFilter; |
||||
|
||||
typedef struct FilterGraph { |
||||
int index; |
||||
const char *graph_desc; |
||||
|
||||
AVFilterGraph *graph; |
||||
int reconfiguration; |
||||
// true when the filtergraph contains only meta filters
|
||||
// that do not modify the frame data
|
||||
int is_meta; |
||||
|
||||
InputFilter **inputs; |
||||
int nb_inputs; |
||||
OutputFilter **outputs; |
||||
int nb_outputs; |
||||
} FilterGraph; |
||||
|
||||
typedef struct InputStream { |
||||
int file_index; |
||||
AVStream *st; |
||||
int discard; /* true if stream data should be discarded */ |
||||
int user_set_discard; |
||||
int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ |
||||
#define DECODING_FOR_OST 1 |
||||
#define DECODING_FOR_FILTER 2 |
||||
int processing_needed; /* non zero if the packets must be processed */ |
||||
// should attach FrameData as opaque_ref after decoding
|
||||
int want_frame_data; |
||||
|
||||
/**
|
||||
* Codec parameters - to be used by the decoding/streamcopy code. |
||||
* st->codecpar should not be accessed, because it may be modified |
||||
* concurrently by the demuxing thread. |
||||
*/ |
||||
AVCodecParameters *par; |
||||
AVCodecContext *dec_ctx; |
||||
const AVCodec *dec; |
||||
AVFrame *decoded_frame; |
||||
AVPacket *pkt; |
||||
|
||||
AVRational framerate_guessed; |
||||
|
||||
int64_t prev_pkt_pts; |
||||
int64_t start; /* time when read started */ |
||||
/* predicted dts of the next packet read for this stream or (when there are
|
||||
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */ |
||||
int64_t next_dts; |
||||
int64_t first_dts; ///< dts of the first packet read for this stream (in AV_TIME_BASE units)
|
||||
int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
|
||||
|
||||
int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
|
||||
int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units)
|
||||
int wrap_correction_done; |
||||
|
||||
// the value of AVCodecParserContext.repeat_pict from the AVStream parser
|
||||
// for the last packet returned from ifile_get_packet()
|
||||
// -1 if unknown
|
||||
// FIXME: this is a hack, the avstream parser should not be used
|
||||
int last_pkt_repeat_pict; |
||||
|
||||
int64_t filter_in_rescale_delta_last; |
||||
|
||||
int64_t min_pts; /* pts with the smallest value in a current stream */ |
||||
int64_t max_pts; /* pts with the higher value in a current stream */ |
||||
|
||||
// when forcing constant input framerate through -r,
|
||||
// this contains the pts that will be given to the next decoded frame
|
||||
int64_t cfr_next_pts; |
||||
|
||||
int64_t nb_samples; /* number of samples in the last decoded audio frame before looping */ |
||||
|
||||
double ts_scale; |
||||
int saw_first_ts; |
||||
AVDictionary *decoder_opts; |
||||
AVRational framerate; /* framerate forced with -r */ |
||||
int top_field_first; |
||||
int guess_layout_max; |
||||
|
||||
int autorotate; |
||||
|
||||
int fix_sub_duration; |
||||
struct { /* previous decoded subtitle and related variables */ |
||||
int got_output; |
||||
int ret; |
||||
AVSubtitle subtitle; |
||||
} prev_sub; |
||||
|
||||
struct sub2video { |
||||
int64_t last_pts; |
||||
int64_t end_pts; |
||||
AVFifo *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFrame *frame; |
||||
int w, h; |
||||
unsigned int initialize; ///< marks if sub2video_update should force an initialization
|
||||
} sub2video; |
||||
|
||||
/* decoded data from this stream goes into all those filters
|
||||
* currently video and audio only */ |
||||
InputFilter **filters; |
||||
int nb_filters; |
||||
|
||||
int reinit_filters; |
||||
|
||||
/* hwaccel options */ |
||||
enum HWAccelID hwaccel_id; |
||||
enum AVHWDeviceType hwaccel_device_type; |
||||
char *hwaccel_device; |
||||
enum AVPixelFormat hwaccel_output_format; |
||||
|
||||
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame); |
||||
enum AVPixelFormat hwaccel_pix_fmt; |
||||
|
||||
/* stats */ |
||||
// combined size of all the packets read
|
||||
uint64_t data_size; |
||||
/* number of packets successfully read for this stream */ |
||||
uint64_t nb_packets; |
||||
// number of frames/samples retrieved from the decoder
|
||||
uint64_t frames_decoded; |
||||
uint64_t samples_decoded; |
||||
|
||||
int64_t *dts_buffer; |
||||
int nb_dts_buffer; |
||||
|
||||
int got_output; |
||||
} InputStream; |
||||
|
||||
typedef struct LastFrameDuration { |
||||
int stream_idx; |
||||
int64_t duration; |
||||
} LastFrameDuration; |
||||
|
||||
typedef struct InputFile { |
||||
int index; |
||||
|
||||
AVFormatContext *ctx; |
||||
int eof_reached; /* true if eof reached */ |
||||
int eagain; /* true if last read attempt returned EAGAIN */ |
||||
int64_t input_ts_offset; |
||||
int input_sync_ref; |
||||
/**
|
||||
* Effective format start time based on enabled streams. |
||||
*/ |
||||
int64_t start_time_effective; |
||||
int64_t ts_offset; |
||||
/**
|
||||
* Extra timestamp offset added by discontinuity handling. |
||||
*/ |
||||
int64_t ts_offset_discont; |
||||
int64_t last_ts; |
||||
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */ |
||||
int64_t recording_time; |
||||
|
||||
/* streams that ffmpeg is aware of;
|
||||
* there may be extra streams in ctx that are not mapped to an InputStream |
||||
* if new streams appear dynamically during demuxing */ |
||||
InputStream **streams; |
||||
int nb_streams; |
||||
|
||||
int rate_emu; |
||||
float readrate; |
||||
int accurate_seek; |
||||
|
||||
/* when looping the input file, this queue is used by decoders to report
|
||||
* the last frame duration back to the demuxer thread */ |
||||
AVThreadMessageQueue *audio_duration_queue; |
||||
int audio_duration_queue_size; |
||||
} InputFile; |
||||
|
||||
enum forced_keyframes_const { |
||||
FKF_N, |
||||
FKF_N_FORCED, |
||||
FKF_PREV_FORCED_N, |
||||
FKF_PREV_FORCED_T, |
||||
FKF_T, |
||||
FKF_NB |
||||
}; |
||||
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0) |
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1) |
||||
|
||||
enum EncStatsType { |
||||
ENC_STATS_LITERAL = 0, |
||||
ENC_STATS_FILE_IDX, |
||||
ENC_STATS_STREAM_IDX, |
||||
ENC_STATS_FRAME_NUM, |
||||
ENC_STATS_FRAME_NUM_IN, |
||||
ENC_STATS_TIMEBASE, |
||||
ENC_STATS_TIMEBASE_IN, |
||||
ENC_STATS_PTS, |
||||
ENC_STATS_PTS_TIME, |
||||
ENC_STATS_PTS_IN, |
||||
ENC_STATS_PTS_TIME_IN, |
||||
ENC_STATS_DTS, |
||||
ENC_STATS_DTS_TIME, |
||||
ENC_STATS_SAMPLE_NUM, |
||||
ENC_STATS_NB_SAMPLES, |
||||
ENC_STATS_PKT_SIZE, |
||||
ENC_STATS_BITRATE, |
||||
ENC_STATS_AVG_BITRATE, |
||||
}; |
||||
|
||||
typedef struct EncStatsComponent { |
||||
enum EncStatsType type; |
||||
|
||||
uint8_t *str; |
||||
size_t str_len; |
||||
} EncStatsComponent; |
||||
|
||||
typedef struct EncStats { |
||||
EncStatsComponent *components; |
||||
int nb_components; |
||||
|
||||
AVIOContext *io; |
||||
} EncStats; |
||||
|
||||
extern const char *const forced_keyframes_const_names[]; |
||||
|
||||
typedef enum { |
||||
ENCODER_FINISHED = 1, |
||||
MUXER_FINISHED = 2, |
||||
} OSTFinished ; |
||||
|
||||
enum { |
||||
KF_FORCE_SOURCE = 1, |
||||
KF_FORCE_SOURCE_NO_DROP = 2, |
||||
}; |
||||
|
||||
typedef struct KeyframeForceCtx { |
||||
int type; |
||||
|
||||
int64_t ref_pts; |
||||
|
||||
// timestamps of the forced keyframes, in AV_TIME_BASE_Q
|
||||
int64_t *pts; |
||||
int nb_pts; |
||||
int index; |
||||
|
||||
AVExpr *pexpr; |
||||
double expr_const_values[FKF_NB]; |
||||
|
||||
int dropped_keyframe; |
||||
} KeyframeForceCtx; |
||||
|
||||
typedef struct OutputStream { |
||||
const AVClass *clazz; |
||||
|
||||
int file_index; /* file index */ |
||||
int index; /* stream index in the output file */ |
||||
|
||||
/* input stream that is the source for this output stream;
|
||||
* may be NULL for streams with no well-defined source, e.g. |
||||
* attachments or outputs from complex filtergraphs */ |
||||
InputStream *ist; |
||||
|
||||
AVStream *st; /* stream in the output file */ |
||||
/* number of frames emitted by the video-encoding sync code */ |
||||
int64_t vsync_frame_number; |
||||
/* predicted pts of the next frame to be encoded
|
||||
* audio/video encoding only */ |
||||
int64_t next_pts; |
||||
/* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */ |
||||
int64_t last_mux_dts; |
||||
/* pts of the last frame received from the filters, in AV_TIME_BASE_Q */ |
||||
int64_t last_filter_pts; |
||||
|
||||
// timestamp from which the streamcopied streams should start,
|
||||
// in AV_TIME_BASE_Q;
|
||||
// everything before it should be discarded
|
||||
int64_t ts_copy_start; |
||||
|
||||
// the timebase of the packets sent to the muxer
|
||||
AVRational mux_timebase; |
||||
AVRational enc_timebase; |
||||
|
||||
AVCodecContext *enc_ctx; |
||||
AVFrame *filtered_frame; |
||||
AVFrame *last_frame; |
||||
AVFrame *sq_frame; |
||||
AVPacket *pkt; |
||||
int64_t last_dropped; |
||||
int64_t last_nb0_frames[3]; |
||||
|
||||
/* video only */ |
||||
AVRational frame_rate; |
||||
AVRational max_frame_rate; |
||||
enum VideoSyncMethod vsync_method; |
||||
int is_cfr; |
||||
int force_fps; |
||||
int top_field_first; |
||||
#if FFMPEG_ROTATION_METADATA |
||||
int rotate_overridden; |
||||
#endif |
||||
int autoscale; |
||||
int bitexact; |
||||
int bits_per_raw_sample; |
||||
#if FFMPEG_ROTATION_METADATA |
||||
double rotate_override_value; |
||||
#endif |
||||
|
||||
AVRational frame_aspect_ratio; |
||||
|
||||
KeyframeForceCtx kf; |
||||
|
||||
/* audio only */ |
||||
#if FFMPEG_OPT_MAP_CHANNEL |
||||
int *audio_channels_map; /* list of the channels id to pick from the source stream */ |
||||
int audio_channels_mapped; /* number of channels in audio_channels_map */ |
||||
#endif |
||||
|
||||
char *logfile_prefix; |
||||
FILE *logfile; |
||||
|
||||
OutputFilter *filter; |
||||
char *avfilter; |
||||
char *filters; ///< filtergraph associated to the -filter option
|
||||
char *filters_script; ///< filtergraph script associated to the -filter_script option
|
||||
|
||||
AVDictionary *encoder_opts; |
||||
AVDictionary *sws_dict; |
||||
AVDictionary *swr_opts; |
||||
char *apad; |
||||
OSTFinished finished; /* no more packets should be written for this stream */ |
||||
int unavailable; /* true if the steram is unavailable (possibly temporarily) */ |
||||
|
||||
// init_output_stream() has been called for this stream
|
||||
// The encoder and the bitstream filters have been initialized and the stream
|
||||
// parameters are set in the AVStream.
|
||||
int initialized; |
||||
|
||||
int inputs_done; |
||||
|
||||
const char *attachment_filename; |
||||
int streamcopy_started; |
||||
int copy_initial_nonkeyframes; |
||||
int copy_prior_start; |
||||
|
||||
int keep_pix_fmt; |
||||
|
||||
/* stats */ |
||||
// combined size of all the packets sent to the muxer
|
||||
uint64_t data_size_mux; |
||||
// combined size of all the packets received from the encoder
|
||||
uint64_t data_size_enc; |
||||
// number of packets send to the muxer
|
||||
atomic_uint_least64_t packets_written; |
||||
// number of frames/samples sent to the encoder
|
||||
uint64_t frames_encoded; |
||||
uint64_t samples_encoded; |
||||
// number of packets received from the encoder
|
||||
uint64_t packets_encoded; |
||||
|
||||
/* packet quality factor */ |
||||
int quality; |
||||
|
||||
/* packet picture type */ |
||||
int pict_type; |
||||
|
||||
/* frame encode sum of squared error values */ |
||||
int64_t error[4]; |
||||
|
||||
int sq_idx_encode; |
||||
int sq_idx_mux; |
||||
|
||||
EncStats enc_stats_pre; |
||||
EncStats enc_stats_post; |
||||
|
||||
/*
|
||||
* bool on whether this stream should be utilized for splitting |
||||
* subtitles utilizing fix_sub_duration at random access points. |
||||
*/ |
||||
unsigned int fix_sub_duration_heartbeat; |
||||
} OutputStream; |
||||
|
||||
typedef struct OutputFile { |
||||
const AVClass *clazz; |
||||
|
||||
int index; |
||||
|
||||
const AVOutputFormat *format; |
||||
const char *url; |
||||
|
||||
OutputStream **streams; |
||||
int nb_streams; |
||||
|
||||
SyncQueue *sq_encode; |
||||
|
||||
int64_t recording_time; ///< desired length of the resulting file in microseconds == AV_TIME_BASE units
|
||||
int64_t start_time; ///< start time in microseconds == AV_TIME_BASE units
|
||||
|
||||
int shortest; |
||||
int bitexact; |
||||
} OutputFile; |
||||
|
||||
extern __thread InputFile **input_files; |
||||
extern __thread int nb_input_files; |
||||
|
||||
extern __thread OutputFile **output_files; |
||||
extern __thread int nb_output_files; |
||||
|
||||
extern __thread FilterGraph **filtergraphs; |
||||
extern __thread int nb_filtergraphs; |
||||
|
||||
extern __thread char *vstats_filename; |
||||
extern __thread char *sdp_filename; |
||||
|
||||
extern __thread float audio_drift_threshold; |
||||
extern __thread float dts_delta_threshold; |
||||
extern __thread float dts_error_threshold; |
||||
|
||||
extern __thread enum VideoSyncMethod video_sync_method; |
||||
extern __thread float frame_drop_threshold; |
||||
extern __thread int do_benchmark; |
||||
extern __thread int do_benchmark_all; |
||||
extern __thread int do_hex_dump; |
||||
extern __thread int do_pkt_dump; |
||||
extern __thread int copy_ts; |
||||
extern __thread int start_at_zero; |
||||
extern __thread int copy_tb; |
||||
extern __thread int debug_ts; |
||||
extern __thread int exit_on_error; |
||||
extern __thread int abort_on_flags; |
||||
extern __thread int print_stats; |
||||
extern __thread int64_t stats_period; |
||||
extern __thread int qp_hist; |
||||
extern __thread int stdin_interaction; |
||||
extern __thread AVIOContext *progress_avio; |
||||
extern __thread float max_error_rate; |
||||
|
||||
extern __thread char *filter_nbthreads; |
||||
extern __thread int filter_complex_nbthreads; |
||||
extern __thread int vstats_version; |
||||
extern __thread int auto_conversion_filters; |
||||
|
||||
extern __thread const AVIOInterruptCB int_cb; |
||||
|
||||
extern __thread HWDevice *filter_hw_device; |
||||
|
||||
extern __thread unsigned nb_output_dumped; |
||||
extern __thread int main_ffmpeg_return_code; |
||||
|
||||
extern __thread int ignore_unknown_streams; |
||||
extern __thread int copy_unknown_streams; |
||||
|
||||
extern __thread int recast_media; |
||||
|
||||
#if FFMPEG_OPT_PSNR |
||||
extern __thread int do_psnr; |
||||
#endif |
||||
|
||||
void term_init(void); |
||||
void term_exit(void); |
||||
|
||||
void show_usage(void); |
||||
|
||||
void remove_avoptions(AVDictionary **a, AVDictionary *b); |
||||
void assert_avoptions(AVDictionary *m); |
||||
|
||||
void assert_file_overwrite(const char *filename); |
||||
char *file_read(const char *filename); |
||||
AVDictionary *strip_specifiers(const AVDictionary *dict); |
||||
const AVCodec *find_codec_or_die(void *logctx, const char *name, |
||||
enum AVMediaType type, int encoder); |
||||
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); |
||||
|
||||
int configure_filtergraph(FilterGraph *fg); |
||||
void check_filter_outputs(void); |
||||
int filtergraph_is_simple(FilterGraph *fg); |
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost); |
||||
int init_complex_filtergraph(FilterGraph *fg); |
||||
|
||||
void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub); |
||||
|
||||
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); |
||||
|
||||
int ffmpeg_parse_options(int argc, char **argv); |
||||
|
||||
void enc_stats_write(OutputStream *ost, EncStats *es, |
||||
const AVFrame *frame, const AVPacket *pkt, |
||||
uint64_t frame_num); |
||||
|
||||
HWDevice *hw_device_get_by_name(const char *name); |
||||
int hw_device_init_from_string(const char *arg, HWDevice **dev); |
||||
void hw_device_free_all(void); |
||||
|
||||
int hw_device_setup_for_decode(InputStream *ist); |
||||
int hw_device_setup_for_encode(OutputStream *ost); |
||||
int hw_device_setup_for_filter(FilterGraph *fg); |
||||
|
||||
int hwaccel_decode_init(AVCodecContext *avctx); |
||||
|
||||
/*
|
||||
* Initialize muxing state for the given stream, should be called |
||||
* after the codec/streamcopy setup has been done. |
||||
* |
||||
* Open the muxer once all the streams have been initialized. |
||||
*/ |
||||
int of_stream_init(OutputFile *of, OutputStream *ost); |
||||
int of_write_trailer(OutputFile *of); |
||||
int of_open(const OptionsContext *o, const char *filename); |
||||
void of_close(OutputFile **pof); |
||||
|
||||
void of_enc_stats_close(void); |
||||
|
||||
/*
|
||||
* Send a single packet to the output, applying any bitstream filters |
||||
* associated with the output stream. This may result in any number |
||||
* of packets actually being written, depending on what bitstream |
||||
* filters are applied. The supplied packet is consumed and will be |
||||
* blank (as if newly-allocated) when this function returns. |
||||
* |
||||
* If eof is set, instead indicate EOF to all bitstream filters and |
||||
* therefore flush any delayed packets to the output. A blank packet |
||||
* must be supplied in this case. |
||||
*/ |
||||
void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof); |
||||
int64_t of_filesize(OutputFile *of); |
||||
|
||||
int ifile_open(const OptionsContext *o, const char *filename); |
||||
void ifile_close(InputFile **f); |
||||
|
||||
/**
|
||||
* Get next input packet from the demuxer. |
||||
* |
||||
* @param pkt the packet is written here when this function returns 0 |
||||
* @return |
||||
* - 0 when a packet has been read successfully |
||||
* - 1 when stream end was reached, but the stream is looped; |
||||
* caller should flush decoders and read from this demuxer again |
||||
* - a negative error code on failure |
||||
*/ |
||||
int ifile_get_packet(InputFile *f, AVPacket **pkt); |
||||
|
||||
/* iterate over all input streams in all input files;
|
||||
* pass NULL to start iteration */ |
||||
InputStream *ist_iter(InputStream *prev); |
||||
|
||||
extern const char * const opt_name_codec_names[]; |
||||
extern const char * const opt_name_codec_tags[]; |
||||
extern const char * const opt_name_frame_rates[]; |
||||
extern const char * const opt_name_top_field_first[]; |
||||
|
||||
void set_report_callback(void (*callback)(int, float, float, int64_t, double, double, double)); |
||||
void cancel_operation(long id); |
||||
|
||||
#endif /* FFTOOLS_FFMPEG_H */ |
@ -0,0 +1,165 @@ |
||||
/*
|
||||
* Muxer internal APIs - should not be included outside of ffmpeg_mux* |
||||
* Copyright (c) 2023 ARTHENICA LTD |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of ffmpeg_mux.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop ffmpeg-kit library. |
||||
* |
||||
* ffmpeg-kit changes by ARTHENICA LTD |
||||
* |
||||
* 07.2023 |
||||
* -------------------------------------------------------- |
||||
* - FFmpeg 6.0 changes migrated |
||||
* - fftools header names updated |
||||
* - want_sdp made thread-local |
||||
* - EncStatsFile declaration migrated from ffmpeg_mux_init.c |
||||
* - WARN_MULTIPLE_OPT_USAGE, MATCH_PER_STREAM_OPT, MATCH_PER_TYPE_OPT, SPECIFIER_OPT_FMT declarations migrated from |
||||
* ffmpeg.h |
||||
* - ms_from_ost migrated to ffmpeg_mux.c |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_FFMPEG_MUX_H |
||||
#define FFTOOLS_FFMPEG_MUX_H |
||||
|
||||
#include <stdatomic.h> |
||||
#include <stdint.h> |
||||
|
||||
#include "fftools_thread_queue.h" |
||||
|
||||
#include "libavformat/avformat.h" |
||||
|
||||
#include "libavcodec/packet.h" |
||||
|
||||
#include "libavutil/dict.h" |
||||
#include "libavutil/fifo.h" |
||||
#include "libavutil/thread.h" |
||||
|
||||
#define SPECIFIER_OPT_FMT_str "%s" |
||||
#define SPECIFIER_OPT_FMT_i "%i" |
||||
#define SPECIFIER_OPT_FMT_i64 "%"PRId64 |
||||
#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64 |
||||
#define SPECIFIER_OPT_FMT_f "%f" |
||||
#define SPECIFIER_OPT_FMT_dbl "%lf" |
||||
|
||||
#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\ |
||||
{\
|
||||
char namestr[128] = "";\
|
||||
const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
|
||||
for (int _i = 0; opt_name_##name[_i]; _i++)\
|
||||
av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[_i], opt_name_##name[_i+1] ? (opt_name_##name[_i+2] ? ", " : " or ") : "");\
|
||||
av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
|
||||
namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
|
||||
} |
||||
|
||||
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ |
||||
{\
|
||||
int _ret, _matches = 0;\
|
||||
SpecifierOpt *so;\
|
||||
for (int _i = 0; _i < o->nb_ ## name; _i++) {\
|
||||
char *spec = o->name[_i].specifier;\
|
||||
if ((_ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
|
||||
outvar = o->name[_i].u.type;\
|
||||
so = &o->name[_i];\
|
||||
_matches++;\
|
||||
} else if (_ret < 0)\
|
||||
exit_program(1);\
|
||||
}\
|
||||
if (_matches > 1)\
|
||||
WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
|
||||
} |
||||
|
||||
#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\ |
||||
{\
|
||||
int i;\
|
||||
for (i = 0; i < o->nb_ ## name; i++) {\
|
||||
char *spec = o->name[i].specifier;\
|
||||
if (!strcmp(spec, mediatype))\
|
||||
outvar = o->name[i].u.type;\
|
||||
}\
|
||||
} |
||||
|
||||
typedef struct MuxStream { |
||||
OutputStream ost; |
||||
|
||||
// name used for logging
|
||||
char log_name[32]; |
||||
|
||||
/* the packets are buffered here until the muxer is ready to be initialized */ |
||||
AVFifo *muxing_queue; |
||||
|
||||
AVBSFContext *bsf_ctx; |
||||
|
||||
EncStats stats; |
||||
|
||||
int64_t max_frames; |
||||
|
||||
/*
|
||||
* The size of the AVPackets' buffers in queue. |
||||
* Updated when a packet is either pushed or pulled from the queue. |
||||
*/ |
||||
size_t muxing_queue_data_size; |
||||
|
||||
int max_muxing_queue_size; |
||||
|
||||
/* Threshold after which max_muxing_queue_size will be in effect */ |
||||
size_t muxing_queue_data_threshold; |
||||
|
||||
/* dts of the last packet sent to the muxer, in the stream timebase
|
||||
* used for making up missing dts values */ |
||||
int64_t last_mux_dts; |
||||
} MuxStream; |
||||
|
||||
typedef struct Muxer { |
||||
OutputFile of; |
||||
|
||||
// name used for logging
|
||||
char log_name[32]; |
||||
|
||||
AVFormatContext *fc; |
||||
|
||||
pthread_t thread; |
||||
ThreadQueue *tq; |
||||
|
||||
AVDictionary *opts; |
||||
|
||||
int thread_queue_size; |
||||
|
||||
/* filesize limit expressed in bytes */ |
||||
int64_t limit_filesize; |
||||
atomic_int_least64_t last_filesize; |
||||
int header_written; |
||||
|
||||
SyncQueue *sq_mux; |
||||
AVPacket *sq_pkt; |
||||
} Muxer; |
||||
|
||||
typedef struct EncStatsFile { |
||||
char *path; |
||||
AVIOContext *io; |
||||
} EncStatsFile; |
||||
|
||||
/* whether we want to print an SDP, set in of_open() */ |
||||
extern __thread int want_sdp; |
||||
|
||||
int mux_check_init(Muxer *mux); |
||||
|
||||
#endif /* FFTOOLS_FFMPEG_MUX_H */ |
@ -0,0 +1,79 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop the ffmpeg-kit library. |
||||
* |
||||
* ffmpeg-kit changes by Taner Sener |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_FOPEN_UTF8_H |
||||
#define FFTOOLS_FOPEN_UTF8_H |
||||
|
||||
#include <stdio.h> |
||||
|
||||
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||
* except that it doesn't set O_CLOEXEC, and that it isn't exported |
||||
* from a different library. (On Windows, each DLL might use a different |
||||
* CRT, and FILE* handles can't be shared across them.) */ |
||||
|
||||
#ifdef _WIN32 |
||||
#include "libavutil/wchar_filename.h" |
||||
|
||||
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode) |
||||
{ |
||||
wchar_t *path_w, *mode_w; |
||||
FILE *f; |
||||
|
||||
/* convert UTF-8 to wide chars */ |
||||
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */ |
||||
return NULL; |
||||
if (!path_w) |
||||
goto fallback; |
||||
|
||||
if (utf8towchar(mode, &mode_w)) |
||||
return NULL; |
||||
if (!mode_w) { |
||||
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||
* parameter. */ |
||||
av_freep(&path_w); |
||||
errno = EINVAL; |
||||
return NULL; |
||||
} |
||||
|
||||
f = _wfopen(path_w, mode_w); |
||||
av_freep(&path_w); |
||||
av_freep(&mode_w); |
||||
|
||||
return f; |
||||
fallback: |
||||
/* path may be in CP_ACP */ |
||||
return fopen(path_utf8, mode); |
||||
} |
||||
|
||||
#else |
||||
|
||||
static inline FILE *fopen_utf8(const char *path, const char *mode) |
||||
{ |
||||
return fopen(path, mode); |
||||
} |
||||
#endif |
||||
|
||||
#endif /* FFTOOLS_FOPEN_UTF8_H */ |
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* Copyright (c) 2023 ARTHENICA LTD |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of objpool.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop ffmpeg-kit library. |
||||
* |
||||
* ffmpeg-kit changes by ARTHENICA LTD |
||||
* |
||||
* 07.2023 |
||||
* -------------------------------------------------------- |
||||
* - FFmpeg 6.0 changes migrated |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_OBJPOOL_H |
||||
#define FFTOOLS_OBJPOOL_H |
||||
|
||||
typedef struct ObjPool ObjPool; |
||||
|
||||
typedef void* (*ObjPoolCBAlloc)(void); |
||||
typedef void (*ObjPoolCBReset)(void *); |
||||
typedef void (*ObjPoolCBFree)(void **); |
||||
|
||||
void objpool_free(ObjPool **op); |
||||
ObjPool *objpool_alloc(ObjPoolCBAlloc cb_alloc, ObjPoolCBReset cb_reset, |
||||
ObjPoolCBFree cb_free); |
||||
ObjPool *objpool_alloc_packets(void); |
||||
ObjPool *objpool_alloc_frames(void); |
||||
|
||||
int objpool_get(ObjPool *op, void **obj); |
||||
void objpool_release(ObjPool *op, void **obj); |
||||
|
||||
#endif // FFTOOLS_OBJPOOL_H
|
@ -0,0 +1,202 @@ |
||||
/*
|
||||
* Option handlers shared between the tools. |
||||
* Copyright (c) 2022 Taner Sener |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop the ffmpeg-kit library. |
||||
* |
||||
* ffmpeg-kit changes by Taner Sener |
||||
* |
||||
* 09.2022 |
||||
* -------------------------------------------------------- |
||||
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped |
||||
* - fftools_ prefix added to fftools headers |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_OPT_COMMON_H |
||||
#define FFTOOLS_OPT_COMMON_H |
||||
|
||||
#include "config.h" |
||||
|
||||
#include "fftools_cmdutils.h" |
||||
|
||||
#if CONFIG_AVDEVICE |
||||
/**
|
||||
* Print a listing containing autodetected sinks of the output device. |
||||
* Device name with options may be passed as an argument to limit results. |
||||
*/ |
||||
int show_sinks(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing autodetected sources of the input device. |
||||
* Device name with options may be passed as an argument to limit results. |
||||
*/ |
||||
int show_sources(void *optctx, const char *opt, const char *arg); |
||||
#endif |
||||
|
||||
/**
|
||||
* Print the license of the program to stdout. The license depends on |
||||
* the license of the libraries compiled into the program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_license(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Generic -h handler common to all fftools. |
||||
*/ |
||||
int show_help(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print the version of the program to stdout. The version message |
||||
* depends on the current versions of the repository and of the libav* |
||||
* libraries. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_version(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print the build configuration of the program to stdout. The contents |
||||
* depend on the definition of FFMPEG_CONFIGURATION. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_buildconf(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the formats supported by the |
||||
* program (including devices). |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_formats(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the muxers supported by the |
||||
* program (including devices). |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_muxers(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the |
||||
* program (including devices). |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_demuxers(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the devices supported by the |
||||
* program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_devices(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the codecs supported by the |
||||
* program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_codecs(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the decoders supported by the |
||||
* program. |
||||
*/ |
||||
int show_decoders(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the encoders supported by the |
||||
* program. |
||||
*/ |
||||
int show_encoders(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the bit stream filters supported by the |
||||
* program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_bsfs(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the protocols supported by the |
||||
* program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_protocols(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the filters supported by the |
||||
* program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_filters(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the pixel formats supported by the |
||||
* program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_pix_fmts(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the standard channel layouts supported by |
||||
* the program. |
||||
* This option processing function does not utilize the arguments. |
||||
*/ |
||||
int show_layouts(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the sample formats supported by the |
||||
* program. |
||||
*/ |
||||
int show_sample_fmts(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all supported stream dispositions. |
||||
*/ |
||||
int show_dispositions(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Print a listing containing all the color names and values recognized |
||||
* by the program. |
||||
*/ |
||||
int show_colors(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Set the libav* libraries log level. |
||||
*/ |
||||
int opt_loglevel(void *optctx, const char *opt, const char *arg); |
||||
|
||||
int opt_report(void *optctx, const char *opt, const char *arg); |
||||
int init_report(const char *env, FILE **file); |
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Override the cpuflags. |
||||
*/ |
||||
int opt_cpuflags(void *optctx, const char *opt, const char *arg); |
||||
|
||||
/**
|
||||
* Override the cpucount. |
||||
*/ |
||||
int opt_cpucount(void *optctx, const char *opt, const char *arg); |
||||
|
||||
#endif /* FFTOOLS_OPT_COMMON_H */ |
@ -0,0 +1,122 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* Copyright (c) 2023 ARTHENICA LTD |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of sync_queue.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop ffmpeg-kit library. |
||||
* |
||||
* ffmpeg-kit changes by ARTHENICA LTD |
||||
* |
||||
* 07.2023 |
||||
* -------------------------------------------------------- |
||||
* - FFmpeg 6.0 changes migrated |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_SYNC_QUEUE_H |
||||
#define FFTOOLS_SYNC_QUEUE_H |
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include "libavcodec/packet.h" |
||||
|
||||
#include "libavutil/frame.h" |
||||
|
||||
enum SyncQueueType { |
||||
SYNC_QUEUE_PACKETS, |
||||
SYNC_QUEUE_FRAMES, |
||||
}; |
||||
|
||||
typedef union SyncQueueFrame { |
||||
AVFrame *f; |
||||
AVPacket *p; |
||||
} SyncQueueFrame; |
||||
|
||||
#define SQFRAME(frame) ((SyncQueueFrame){ .f = (frame) }) |
||||
#define SQPKT(pkt) ((SyncQueueFrame){ .p = (pkt) }) |
||||
|
||||
typedef struct SyncQueue SyncQueue; |
||||
|
||||
/**
|
||||
* Allocate a sync queue of the given type. |
||||
* |
||||
* @param buf_size_us maximum duration that will be buffered in microseconds |
||||
*/ |
||||
SyncQueue *sq_alloc(enum SyncQueueType type, int64_t buf_size_us); |
||||
void sq_free(SyncQueue **sq); |
||||
|
||||
/**
|
||||
* Add a new stream to the sync queue. |
||||
* |
||||
* @param limiting whether the stream is limiting, i.e. no other stream can be |
||||
* longer than this one |
||||
* @return |
||||
* - a non-negative stream index on success |
||||
* - a negative error code on error |
||||
*/ |
||||
int sq_add_stream(SyncQueue *sq, int limiting); |
||||
|
||||
/**
|
||||
* Set the timebase for the stream with index stream_idx. Should be called |
||||
* before sending any frames for this stream. |
||||
*/ |
||||
void sq_set_tb(SyncQueue *sq, unsigned int stream_idx, AVRational tb); |
||||
|
||||
/**
|
||||
* Limit the number of output frames for stream with index stream_idx |
||||
* to max_frames. |
||||
*/ |
||||
void sq_limit_frames(SyncQueue *sq, unsigned int stream_idx, |
||||
uint64_t max_frames); |
||||
|
||||
/**
|
||||
* Submit a frame for the stream with index stream_idx. |
||||
* |
||||
* On success, the sync queue takes ownership of the frame and will reset the |
||||
* contents of the supplied frame. On failure, the frame remains owned by the |
||||
* caller. |
||||
* |
||||
* Sending a frame with NULL contents marks the stream as finished. |
||||
* |
||||
* @return |
||||
* - 0 on success |
||||
* - AVERROR_EOF when no more frames should be submitted for this stream |
||||
* - another a negative error code on failure |
||||
*/ |
||||
int sq_send(SyncQueue *sq, unsigned int stream_idx, SyncQueueFrame frame); |
||||
|
||||
/**
|
||||
* Read a frame from the queue. |
||||
* |
||||
* @param stream_idx index of the stream to read a frame for. May be -1, then |
||||
* try to read a frame from any stream that is ready for |
||||
* output. |
||||
* @param frame output frame will be written here on success. The frame is owned |
||||
* by the caller. |
||||
* |
||||
* @return |
||||
* - a non-negative index of the stream to which the returned frame belongs |
||||
* - AVERROR(EAGAIN) when more frames need to be submitted to the queue |
||||
* - AVERROR_EOF when no more frames will be available for this stream (for any |
||||
* stream if stream_idx is -1) |
||||
* - another negative error code on failure |
||||
*/ |
||||
int sq_receive(SyncQueue *sq, int stream_idx, SyncQueueFrame frame); |
||||
|
||||
#endif // FFTOOLS_SYNC_QUEUE_H
|
@ -0,0 +1,94 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* Copyright (c) 2023 ARTHENICA LTD |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/*
|
||||
* This file is the modified version of thread_queue.h file living in ffmpeg source code under the fftools folder. We |
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||
* by us to develop ffmpeg-kit library. |
||||
* |
||||
* ffmpeg-kit changes by ARTHENICA LTD |
||||
* |
||||
* 07.2023 |
||||
* -------------------------------------------------------- |
||||
* - FFmpeg 6.0 changes migrated |
||||
*/ |
||||
|
||||
#ifndef FFTOOLS_THREAD_QUEUE_H |
||||
#define FFTOOLS_THREAD_QUEUE_H |
||||
|
||||
#include <string.h> |
||||
|
||||
#include "fftools_objpool.h" |
||||
|
||||
typedef struct ThreadQueue ThreadQueue; |
||||
|
||||
/**
|
||||
* Allocate a queue for sending data between threads. |
||||
* |
||||
* @param nb_streams number of streams for which a distinct EOF state is |
||||
* maintained |
||||
* @param queue_size number of items that can be stored in the queue without |
||||
* blocking |
||||
* @param obj_pool object pool that will be used to allocate items stored in the |
||||
* queue; the pool becomes owned by the queue |
||||
* @param callback that moves the contents between two data pointers |
||||
*/ |
||||
ThreadQueue *tq_alloc(unsigned int nb_streams, size_t queue_size, |
||||
ObjPool *obj_pool, void (*obj_move)(void *dst, void *src)); |
||||
void tq_free(ThreadQueue **tq); |
||||
|
||||
/**
|
||||
* Send an item for the given stream to the queue. |
||||
* |
||||
* @param data the item to send, its contents will be moved using the callback |
||||
* provided to tq_alloc(); on failure the item will be left |
||||
* untouched |
||||
* @return |
||||
* - 0 the item was successfully sent |
||||
* - AVERROR(ENOMEM) could not allocate an item for writing to the FIFO |
||||
* - AVERROR(EINVAL) the sending side has previously been marked as finished |
||||
* - AVERROR_EOF the receiving side has marked the given stream as finished |
||||
*/ |
||||
int tq_send(ThreadQueue *tq, unsigned int stream_idx, void *data); |
||||
/**
|
||||
* Mark the given stream finished from the sending side. |
||||
*/ |
||||
void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx); |
||||
|
||||
/**
|
||||
* Read the next item from the queue. |
||||
* |
||||
* @param stream_idx the index of the stream that was processed or -1 will be |
||||
* written here |
||||
* @param data the data item will be written here on success using the |
||||
* callback provided to tq_alloc() |
||||
* @return |
||||
* - 0 a data item was successfully read; *stream_idx contains a non-negative |
||||
* stream index |
||||
* - AVERROR_EOF When *stream_idx is non-negative, this signals that the sending |
||||
* side has marked the given stream as finished. This will happen at most once |
||||
* for each stream. When *stream_idx is -1, all streams are done. |
||||
*/ |
||||
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data); |
||||
/**
|
||||
* Mark the given stream finished from the receiving side. |
||||
*/ |
||||
void tq_receive_finish(ThreadQueue *tq, unsigned int stream_idx); |
||||
|
||||
#endif // FFTOOLS_THREAD_QUEUE_H
|
@ -0,0 +1,32 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>en</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>ffmpegkit</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>com.arthenica.ffmpegkit.FFmpegKit</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>ffmpegkit</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>FMWK</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>MinimumOSVersion</key> |
||||
<string>12.1</string> |
||||
<key>CFBundleSupportedPlatforms</key> |
||||
<array> |
||||
<string>iPhoneOS</string> |
||||
</array> |
||||
<key>NSPrincipalClass</key> |
||||
<string></string> |
||||
</dict> |
||||
</plist> |
@ -0,0 +1,165 @@ |
||||
GNU LESSER GENERAL PUBLIC LICENSE |
||||
Version 3, 29 June 2007 |
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
||||
Everyone is permitted to copy and distribute verbatim copies |
||||
of this license document, but changing it is not allowed. |
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates |
||||
the terms and conditions of version 3 of the GNU General Public |
||||
License, supplemented by the additional permissions listed below. |
||||
|
||||
0. Additional Definitions. |
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser |
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU |
||||
General Public License. |
||||
|
||||
"The Library" refers to a covered work governed by this License, |
||||
other than an Application or a Combined Work as defined below. |
||||
|
||||
An "Application" is any work that makes use of an interface provided |
||||
by the Library, but which is not otherwise based on the Library. |
||||
Defining a subclass of a class defined by the Library is deemed a mode |
||||
of using an interface provided by the Library. |
||||
|
||||
A "Combined Work" is a work produced by combining or linking an |
||||
Application with the Library. The particular version of the Library |
||||
with which the Combined Work was made is also called the "Linked |
||||
Version". |
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the |
||||
Corresponding Source for the Combined Work, excluding any source code |
||||
for portions of the Combined Work that, considered in isolation, are |
||||
based on the Application, and not on the Linked Version. |
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the |
||||
object code and/or source code for the Application, including any data |
||||
and utility programs needed for reproducing the Combined Work from the |
||||
Application, but excluding the System Libraries of the Combined Work. |
||||
|
||||
1. Exception to Section 3 of the GNU GPL. |
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License |
||||
without being bound by section 3 of the GNU GPL. |
||||
|
||||
2. Conveying Modified Versions. |
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a |
||||
facility refers to a function or data to be supplied by an Application |
||||
that uses the facility (other than as an argument passed when the |
||||
facility is invoked), then you may convey a copy of the modified |
||||
version: |
||||
|
||||
a) under this License, provided that you make a good faith effort to |
||||
ensure that, in the event an Application does not supply the |
||||
function or data, the facility still operates, and performs |
||||
whatever part of its purpose remains meaningful, or |
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of |
||||
this License applicable to that copy. |
||||
|
||||
3. Object Code Incorporating Material from Library Header Files. |
||||
|
||||
The object code form of an Application may incorporate material from |
||||
a header file that is part of the Library. You may convey such object |
||||
code under terms of your choice, provided that, if the incorporated |
||||
material is not limited to numerical parameters, data structure |
||||
layouts and accessors, or small macros, inline functions and templates |
||||
(ten or fewer lines in length), you do both of the following: |
||||
|
||||
a) Give prominent notice with each copy of the object code that the |
||||
Library is used in it and that the Library and its use are |
||||
covered by this License. |
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license |
||||
document. |
||||
|
||||
4. Combined Works. |
||||
|
||||
You may convey a Combined Work under terms of your choice that, |
||||
taken together, effectively do not restrict modification of the |
||||
portions of the Library contained in the Combined Work and reverse |
||||
engineering for debugging such modifications, if you also do each of |
||||
the following: |
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that |
||||
the Library is used in it and that the Library and its use are |
||||
covered by this License. |
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license |
||||
document. |
||||
|
||||
c) For a Combined Work that displays copyright notices during |
||||
execution, include the copyright notice for the Library among |
||||
these notices, as well as a reference directing the user to the |
||||
copies of the GNU GPL and this license document. |
||||
|
||||
d) Do one of the following: |
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this |
||||
License, and the Corresponding Application Code in a form |
||||
suitable for, and under terms that permit, the user to |
||||
recombine or relink the Application with a modified version of |
||||
the Linked Version to produce a modified Combined Work, in the |
||||
manner specified by section 6 of the GNU GPL for conveying |
||||
Corresponding Source. |
||||
|
||||
1) Use a suitable shared library mechanism for linking with the |
||||
Library. A suitable mechanism is one that (a) uses at run time |
||||
a copy of the Library already present on the user's computer |
||||
system, and (b) will operate properly with a modified version |
||||
of the Library that is interface-compatible with the Linked |
||||
Version. |
||||
|
||||
e) Provide Installation Information, but only if you would otherwise |
||||
be required to provide such information under section 6 of the |
||||
GNU GPL, and only to the extent that such information is |
||||
necessary to install and execute a modified version of the |
||||
Combined Work produced by recombining or relinking the |
||||
Application with a modified version of the Linked Version. (If |
||||
you use option 4d0, the Installation Information must accompany |
||||
the Minimal Corresponding Source and Corresponding Application |
||||
Code. If you use option 4d1, you must provide the Installation |
||||
Information in the manner specified by section 6 of the GNU GPL |
||||
for conveying Corresponding Source.) |
||||
|
||||
5. Combined Libraries. |
||||
|
||||
You may place library facilities that are a work based on the |
||||
Library side by side in a single library together with other library |
||||
facilities that are not Applications and are not covered by this |
||||
License, and convey such a combined library under terms of your |
||||
choice, if you do both of the following: |
||||
|
||||
a) Accompany the combined library with a copy of the same work based |
||||
on the Library, uncombined with any other library facilities, |
||||
conveyed under the terms of this License. |
||||
|
||||
b) Give prominent notice with the combined library that part of it |
||||
is a work based on the Library, and explaining where to find the |
||||
accompanying uncombined form of the same work. |
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License. |
||||
|
||||
The Free Software Foundation may publish revised and/or new versions |
||||
of the GNU Lesser General Public License from time to time. Such new |
||||
versions will be similar in spirit to the present version, but may |
||||
differ in detail to address new problems or concerns. |
||||
|
||||
Each version is given a distinguishing version number. If the |
||||
Library as you received it specifies that a certain numbered version |
||||
of the GNU Lesser General Public License "or any later version" |
||||
applies to it, you have the option of following the terms and |
||||
conditions either of that published version or of any later version |
||||
published by the Free Software Foundation. If the Library as you |
||||
received it does not specify a version number of the GNU Lesser |
||||
General Public License, you may choose any version of the GNU Lesser |
||||
General Public License ever published by the Free Software Foundation. |
||||
|
||||
If the Library as you received it specifies that a proxy can decide |
||||
whether future versions of the GNU Lesser General Public License shall |
||||
apply, that proxy's public statement of acceptance of any version is |
||||
permanent authorization for you to choose that version for the |
||||
Library. |
@ -0,0 +1,32 @@ |
||||
framework module ffmpegkit { |
||||
|
||||
header "AbstractSession.h" |
||||
header "ArchDetect.h" |
||||
header "AtomicLong.h" |
||||
header "Chapter.h" |
||||
header "FFmpegKit.h" |
||||
header "FFmpegKitConfig.h" |
||||
header "FFmpegSession.h" |
||||
header "FFmpegSessionCompleteCallback.h" |
||||
header "FFprobeKit.h" |
||||
header "FFprobeSession.h" |
||||
header "FFprobeSessionCompleteCallback.h" |
||||
header "Level.h" |
||||
header "Log.h" |
||||
header "LogCallback.h" |
||||
header "LogRedirectionStrategy.h" |
||||
header "MediaInformation.h" |
||||
header "MediaInformationJsonParser.h" |
||||
header "MediaInformationSession.h" |
||||
header "MediaInformationSessionCompleteCallback.h" |
||||
header "Packages.h" |
||||
header "ReturnCode.h" |
||||
header "Session.h" |
||||
header "SessionState.h" |
||||
header "Statistics.h" |
||||
header "StatisticsCallback.h" |
||||
header "StreamInformation.h" |
||||
header "ffmpegkit_exception.h" |
||||
|
||||
export * |
||||
} |
@ -0,0 +1,14 @@ |
||||
The source code of "FFmpegKit", "FFmpeg" and external libraries enabled within |
||||
"FFmpeg" for this release can be downloaded from |
||||
https://github.com/arthenica/ffmpeg-kit/wiki/Source page. |
||||
|
||||
If you want to receive the source code on physical media submit your request |
||||
to "open-source@arthenica.com" email address. |
||||
|
||||
Your request should include "FFmpegKit" version, "FFmpegKit" platform, your |
||||
name, your company name, your mailing address, the phone number and the date |
||||
you started using "FFmpegKit". |
||||
|
||||
Note that we may charge you a fee to cover physical media printing and |
||||
shipping costs. Your request must be sent within the first three years of the |
||||
date you received "FFmpegKit" with "GPL v3.0" license. |
Binary file not shown.
@ -0,0 +1,62 @@ |
||||
################################################################################ |
||||
# |
||||
# Copyright 2015 Realm Inc. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
################################################################################ |
||||
|
||||
# This script strips all non-valid architectures from dynamic libraries in |
||||
# the application's `Frameworks` directory. |
||||
# |
||||
# The following environment variables are required: |
||||
# |
||||
# BUILT_PRODUCTS_DIR |
||||
# FRAMEWORKS_FOLDER_PATH |
||||
# VALID_ARCHS |
||||
# EXPANDED_CODE_SIGN_IDENTITY |
||||
|
||||
|
||||
# Signs a framework with the provided identity |
||||
code_sign() { |
||||
# Use the current code_sign_identitiy |
||||
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" |
||||
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements $1" |
||||
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" |
||||
} |
||||
|
||||
echo "Stripping frameworks" |
||||
cd "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}" |
||||
|
||||
for file in $(find . -type f -perm +111); do |
||||
# Skip non-dynamic libraries |
||||
if ! [[ "$(file "$file")" == *"dynamically linked shared library"* ]]; then |
||||
continue |
||||
fi |
||||
# Get architectures for current file |
||||
archs="$(lipo -info "${file}" | rev | cut -d ':' -f1 | rev)" |
||||
stripped="" |
||||
for arch in $archs; do |
||||
if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then |
||||
# Strip non-valid architectures in-place |
||||
lipo -remove "$arch" -output "$file" "$file" || exit 1 |
||||
stripped="$stripped $arch" |
||||
fi |
||||
done |
||||
if [[ "$stripped" != "" ]]; then |
||||
echo "Stripped $file of architectures:$stripped" |
||||
if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then |
||||
code_sign "${file}" |
||||
fi |
||||
fi |
||||
done |
@ -0,0 +1,31 @@ |
||||
Pod::Spec.new do |s| |
||||
s.name = 'ffmpeg-kit-ios-min' |
||||
s.version = '6.0.0' # 与编译版本严格对应 |
||||
s.summary = 'Minimal FFmpegKit build for iOS' |
||||
s.description = <<-DESC |
||||
Custom minimal build of FFmpegKit for iOS arm64 architecture. |
||||
Contains core ffmpeg libraries without external dependencies. |
||||
DESC |
||||
s.homepage = 'https://github.com/ZhuYilin10/ffmpeg-kit' |
||||
s.license = { |
||||
:type => 'LGPL-3.0', |
||||
:file => 'ffmpeg-kit-ios-min/ffmpegkit.xcframework/ios-arm64/ffmpegkit.framework/LICENSE' # 确保LICENSE文件存在于此路径 |
||||
} |
||||
s.author = { 'zhuyl' => 'zhuyl.cn' } |
||||
|
||||
# 平台配置 |
||||
s.platform = :ios |
||||
s.ios.deployment_target = '12.1' # 与你的编译目标一致 |
||||
s.requires_arc = true |
||||
|
||||
# 源码配置 |
||||
s.source = { |
||||
:git => 'https://github.com/ZhuYilin10/ffmpeg-kit.git', |
||||
:tag => s.version.to_s |
||||
} |
||||
|
||||
# 框架配置 |
||||
s.vendored_frameworks = [ |
||||
'ffmpeg-kit-ios-min/ffmpegkit.xcframework' # 指向xcframework根目录 |
||||
] |
||||
end |
Loading…
Reference in new issue