我的C++应用程序加载一个原始的音频和视频文件,并将它们保存为Mpeg格式。目前音视频的PID值是固定的。
我想要使用C++的音频和视频PID值。如果有人能告诉我怎么做,我真的很感激。
发布于 2015-03-20 13:50:41
@aergistal你使用AVDictionary做这件事是正确的。但是avio_open2 ()方法不起作用。您必须将其传递给write header方法,而不是avio_open2 ()方法
AVDictionary *d = NULL;
av_dict_set(&d, "mpegts_start_pid", "0x0050", 0);
//Write file header
if (avformat_write_header(ofmt_ctx, &d) < 0) {
printf("Error occurred when opening output file\n");
return false;
}这个方法是有效的。
谢谢。
发布于 2015-03-18 21:18:58
设置MPEG-TS复用器的mpegts_start_pid AVOption。
例如:
int avio_open2 (AVIOContext **s,
const char * url,
int flags,
const AVIOInterruptCB * int_cb,
AVDictionary ** options
) 使用options parameter。
更新:如何设置字典条目
AVDictionary *d = NULL; // "create" an empty dictionary
av_dict_set(&d, "foo", "bar", 0); // add an entry这里有一个完整的重新复用示例:enter link description here,但它使用了avio_open。
https://stackoverflow.com/questions/29121520
复制相似问题