[英]How to encode series of images into VP8 using WebM VP8 Encoder API? (C/C++)
[英]How to pass VP8 encoder option programmatically in ffmpeg based program
我正在基於標准ffmpeg轉碼器示例使用ffmpeg庫構建程序。 我的目標是建立視頻轉碼器,將任何合適的視頻(即ffmpeg可以讀取)編碼為WEBM格式。 問題是如何將選項傳遞給VP8編碼器以控制輸出視頻質量和其他參數? 我的意思是通過C ++代碼傳遞這些選項。
使用以下代碼:
AVDictionary *options = NULL;
AVCodec *codec = avcodec_find_encoder(AVCODEC_ID_VP8);
AVCodecContext *ctx = avcodec_alloc_context3(codec);
av_dict_set(&options, "option", "value", 0);
int res = avcodec_open2(ctx, codec, &options);
if (res < 0)
error();
while (..) {
res = avcodec_encode_video2(ctx, ..);
if (res < 0)
error();
}
avcodec_close(ctx);
avcodec_free_context(ctx);
相關的“選項” /“值”對可以從FFmpeg Wiki的vp8編碼指南中獲得。 例如,要將比特率設置為1 mbps(Wiki中的第一個示例),請使用:
av_dict_set_int(&options, "b", 1024 * 1024, 0);
要么
av_dict_set(&options, "b", "1M", 0);
我建議使用VP9而不是VP8,使用VP8不會獲得很好的質量,但這顯然是您的選擇。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.