av_dump_format参数分析与使用

简介: av_dump_format参数分析与使用
void av_dump_format(AVFormatContext *ic,
                    int index,
                    const char *url,
                    int is_output);


此函数调用与否并不会影响程序,它是一个打印日志信息的函数,它通过调用av_log将信息打印在控制台,打印的是ic->streams[index]流的流信息。

其中index是指打印哪个流通道的信息,如果有视频和音频,那么还要加以区分。其中is_output区别打印输入流还是输出流,0是输入流,1是输出流。

区分方式如下:

//打印音频流信息
int audio_index = -1;
for (int i = 0; i < ic_a->nb_streams; i++)
{
    if (ic_a->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) //AVMEDIA_TYPE_VIDEO
    {
        // ic->streams[i]->codecpar
        audio_index = i;
    }
}
if (audio_index == -1)
{
    printf("找不到视频流\n");
}
av_dump_format(ic, audio_index, URL, 0);


其打印是Metadata的内容,如下:


Input #22, mpegts, from

‘srt://127.0.0.1:8080?streamid=live.sls.com/live/test’: Duration:

N/A, start: 0.000000, bitrate: N/A Program 1

Metadata:

service_name : Service01

service_provider: FFmpeg

Stream #22:0[0x100]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 130 kb/s

Stream #22:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080, 25 fps, 25

tbr, 90k tbn, 50 tbc


其中:tbr是帧率的时间基,tbn是流的时间基,tbc是编解码器的时间基。


相关文章
|
10月前
|
编解码
av_read_frame返回值为-5 Input/output error
av_read_frame返回值为-5 Input/output error
106 0
perhaps your file is in a different file format and youneed to use a different restore operator?
perhaps your file is in a different file format and youneed to use a different restore operator?
114 0
解决办法:av_interleaved_write_frame()返回-22 错误
解决办法:av_interleaved_write_frame()返回-22 错误
100 0
|
SQL
format函数
format函数
115 0