FFmpeg?Principle分析Out?put?File?數(shù)據(jù)結構
struct OutputFile
struct OutputFile
是單個輸出文件的管理器。之前在 parse_optgroup()
處理好的 OptionsContext o
變量,有一部分字段會賦值給 OutputFile
管理器
如下:
OptionsContext o
變量的另一部分字段,會在 open_output_file()
里面?zhèn)鬟f給 API 函數(shù),例如:avformat_write_header()
,或者賦值給 OutputStream
的一些字段。
ret = avformat_write_header(of->ctx, &of->opts);
output_files
全局變量是一個數(shù)組,里面的成員正是 OutputFile
,所以你在二次開發(fā) ffmpeg.exe
的時候,可以通過 output_files
全局變量獲取到所有的輸出文件的信息。
OutputFile **output_files = NULL; int nb_output_files = 0;
我們接下來仔細學習一下 struct OutputFile
的結構,如下:
typedef struct OutputFile { AVFormatContext *ctx; AVDictionary *opts; int ost_index; /* index of the first stream in output_streams */ 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 uint64_t limit_filesize; /* filesize limit expressed in bytes */ int shortest; int header_written; } OutputFile;
相比 InputFile
,OutputFile
數(shù)據(jù)結構的字段簡直太少了,讀起來太爽了。
struct OutputFile 字段解析
1, AVFormatContext *ctx
,容器上下文,也叫容器實例。
2, AVDictionary *opts
,容器格式的參數(shù),是從 OptionsContext
里面 的 OptionGroup
的 format_opts
復制過來的,如下:
av_dict_copy(&of->opts, o->g->format_opts, 0);
opts
會傳遞給 avformat_write_header()
函數(shù),如下:
ret = avformat_write_header(of->ctx, &of->opts);
3, int ost_index
,輸出文件的第一個流在 output_streams
數(shù)組里面的索引,output_streams
數(shù)組是一個全局變量,里面包含所有輸出文件的所有輸出流。你二次開發(fā) ffmpeg.exe
的時候,可以使用 output_streams
數(shù)組,獲取到所有的輸出流。
4, int64_t recording_time
,命令行選項 -t
的值,設置輸出文件的時長,單位是微秒,具體的功能是通過 trim
濾鏡來實現(xiàn)的。
5, int64_t start_time
,標記輸出文件的開始時間,例如一個輸入文件本來是 6 分鐘的,你可以用 -ss 120
指定 start_time
,這樣,輸出文件就會裁剪成 第 2 ~ 6分鐘 的視頻,前面 2 分鐘丟棄。
6, uint64_t limit_filesize
,限制輸出文件的大小,一旦達到這個大小,輸出文件立即結束。
7, int shortest
,命令行選項 -shortest
的值,當最短的輸出流結束的時候,整個文件就結束了,例如一個輸出文件里面有 音頻流 跟 視頻流,視頻流 3 分鐘,音頻流 5 分鐘。如果啟用了這個選項,音頻流就會被裁剪成 3 分鐘。
8, int header_written
,是否已經(jīng)調(diào)用了 avformat_write_header()
函數(shù),往輸出文件寫入了頭部信息。
以上就是FFmpeg Principle分析Out put File 數(shù)據(jù)結構的詳細內(nèi)容,更多關于Out put File 數(shù)據(jù)結構的資料請關注腳本之家其它相關文章!
相關文章
Android自定義View實現(xiàn)圓環(huán)帶數(shù)字百分比進度條
這篇文章主要為大家詳細介紹了Android自定義View實現(xiàn)圓環(huán)帶數(shù)字百分比進度條,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-12-12Android項目實戰(zhàn)之Glide 高斯模糊效果的實例代碼
這篇文章主要介紹了Android項目實戰(zhàn)之Glide 高斯模糊效果的實例代碼,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-06-06Android Studio查看Android 5.x源碼的步驟詳解
Google為Android開發(fā)者帶來Android Studio,用來取代Eclipse。從Android Studio出現(xiàn)起,整機開發(fā)和Android源碼閱讀和編輯一定能用上它。這篇文章小編就帶大家學習下如何使用Android Studio查看Android 5.x源碼,有需要的可以參考借鑒。2016-09-09Android Activity啟動模式之singleTop實例詳解
這篇文章主要介紹了Android Activity啟動模式之singleTop,結合實例形式較為詳細的分析了singleTop模式的功能、使用方法與相關注意事項,需要的朋友可以參考下2016-01-01Android Activity之間的數(shù)據(jù)傳遞方法總結
這篇文章主要給大家總結介紹了關于Android Activity之間的數(shù)據(jù)傳遞方法,文中通過示例代碼介紹的非常詳細,對各位Android開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-06-06