日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

FFMPEG AVDictionary 配置参数

發布時間:2024/9/30 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 FFMPEG AVDictionary 配置参数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

AVDictionary 的用法簡介

AVDictionary 所在的頭文件在 libavutil/dict.h,其定義如下:

struct AVDictionary { int count; AVDictionaryEntry *elems; };

其中,AVDictionaryEntry 的定義如下:

typedef struct AVDictionaryEntry { char *key; char *value; } AVDictionaryEntry;

下面就用示例的方式簡單介紹下用法

創建一個字典

AVDictionary *d = NULL;

銷毀一個字典

av_dict_free(&d);

添加一對 key-value

av_dict_set(&d, "name", "jhuster", 0); av_dict_set_int(&d, "age", "29", 0);

獲取 key 的值

AVDictionaryEntry *t = NULL;t = av_dict_get(d, "name", NULL, AV_DICT_IGNORE_SUFFIX); av_log(NULL, AV_LOG_DEBUG, "name: %s", t->value);t = av_dict_get(d, "age", NULL, AV_DICT_IGNORE_SUFFIX); av_log(NULL, AV_LOG_DEBUG, "age: %d", (int) (*t->value));

遍歷字典

AVDictionaryEntry *t = NULL; while ((t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX))) {av_log(NULL, AV_LOG_DEBUG, "%s: %s", t->key, t->value); }

ffmpeg 參數的傳遞

ffmpeg 中很多 API 都是靠 AVDictionary 來傳遞參數的,比如常用的:

int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options);

最后一個參數就是 AVDictionary,我們可以在打開碼流前指定各種參數,比如:探測時間、超時時間、最大延時、支持的協議的白名單等等,例如:

AVDictionary *options = NULL; av_dict_set(&options, “probesize”,4096", 0); av_dict_set(&options, “max_delay”,5000000, 0); AVFormatContext *ic = avformat_alloc_context(); if (avformat_open_input(&ic, url, NULL, &options) < 0) {LOGE("could not open source %s", url);return -1; }

那么,我們怎么知道 ffmpeg 的這個 API 支持哪些可配置的參數呢 ?

我們可以查看 ffmpeg 源碼,比如 avformat_open_input 是結構體 AVFormatContext 提供的 API,在 libavformat/options_table.h 中定義了 AVFormatContext 所有支持的 options 選項,如下所示:
https://www.ffmpeg.org/doxygen/trunk/libavformat_2options__table_8h-source.html

同理,AVCodec 相關 API 支持的 options 選項則可以在 libavcodec/options_table.h 文件中找到,如下所示:

https://www.ffmpeg.org/doxygen/3.1/libavcodec_2options__table_8h_source.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的FFMPEG AVDictionary 配置参数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。