網(wǎng)站首頁 編程語言 正文
FFmpeg?Principle分析Out?put?File?數(shù)據(jù)結(jié)構(gòu)_Android
作者:Loken1 ? 更新時(shí)間: 2022-12-03 編程語言struct OutputFile
struct OutputFile
?是單個(gè)輸出文件的管理器。之前在?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
?全局變量是一個(gè)數(shù)組,里面的成員正是?OutputFile
,所以你在二次開發(fā)?ffmpeg.exe
?的時(shí)候,可以通過?output_files
?全局變量獲取到所有的輸出文件的信息。
OutputFile **output_files = NULL; int nb_output_files = 0;
我們接下來仔細(xì)學(xué)習(xí)一下?struct OutputFile
?的結(jié)構(gòu),如下:
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ù)結(jié)構(gòu)的字段簡直太少了,讀起來太爽了。
struct OutputFile?字段解析
1, AVFormatContext *ctx
,容器上下文,也叫容器實(shí)例。
2, AVDictionary *opts
,容器格式的參數(shù),是從?OptionsContext
?里面 的?OptionGroup
?的?format_opts
?復(fù)制過來的,如下:
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
,輸出文件的第一個(gè)流在?output_streams
?數(shù)組里面的索引,output_streams
?數(shù)組是一個(gè)全局變量,里面包含所有輸出文件的所有輸出流。你二次開發(fā)?ffmpeg.exe
?的時(shí)候,可以使用?output_streams
?數(shù)組,獲取到所有的輸出流。
4, int64_t recording_time
,命令行選項(xiàng)?-t
?的值,設(shè)置輸出文件的時(shí)長,單位是微秒,具體的功能是通過?trim
?濾鏡來實(shí)現(xiàn)的。
5, int64_t start_time
,標(biāo)記輸出文件的開始時(shí)間,例如一個(gè)輸入文件本來是 6 分鐘的,你可以用?-ss 120
?指定?start_time
,這樣,輸出文件就會裁剪成 第 2 ~ 6分鐘 的視頻,前面 2 分鐘丟棄。
6, uint64_t limit_filesize
,限制輸出文件的大小,一旦達(dá)到這個(gè)大小,輸出文件立即結(jié)束。
7, int shortest
,命令行選項(xiàng)?-shortest
?的值,當(dāng)最短的輸出流結(jié)束的時(shí)候,整個(gè)文件就結(jié)束了,例如一個(gè)輸出文件里面有 音頻流 跟 視頻流,視頻流 3 分鐘,音頻流 5 分鐘。如果啟用了這個(gè)選項(xiàng),音頻流就會被裁剪成 3 分鐘。
8, int header_written
,是否已經(jīng)調(diào)用了?avformat_write_header()
?函數(shù),往輸出文件寫入了頭部信息。
原文鏈接:https://juejin.cn/post/7159422966650896415
相關(guān)推薦
- 2022-04-18 Go中g(shù)routine通信與context控制實(shí)例詳解_Golang
- 2022-10-24 Winform控件優(yōu)化之圓角按鈕2_C#教程
- 2023-08-01 elementui中Table切換分頁保存多選框選中的數(shù)據(jù)
- 2022-10-04 Qt實(shí)現(xiàn)右擊菜單項(xiàng)_C 語言
- 2022-03-26 C++缺省參數(shù)的具體使用_C 語言
- 2022-04-24 Python元素集合的列表切片_python
- 2022-09-18 ASP.NET?Core實(shí)現(xiàn)文件上傳和下載_實(shí)用技巧
- 2022-11-14 Redis主從復(fù)制分步講解使用_Redis
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支