编码一个文件, 用av_dump_format 打印出了如下信息, 到底是什么意思呢?
Output #0, hls, to 'playlist.m3u8':
Stream #0:0: Video: h264, yuv420p(tv, progressive), 640x480 [SAR 4:3 DAR 16:9], q=2-31, 2000 kb/s, 25 fps, 90k tbn
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.134.100 aac
下面具体分析一下:
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
-----------------------------------------------------------------------------------
Output #0, hls, to 'playlist.m3u8':
编码时, is_output 为true , 打印 "Output" "to" 字符串
0 : index, 代表第一个编码文件.
hls : ic->oformat->name , 输出格式名称
playlist.m3u8 : url , 输出文件名
后面的信息是流信息,用以下函数形成的.
static void dump_stream_format(const AVFormatContext *ic, int i, int index, int is_output)
------------------------------------------------------------------------------------------
i: 是流的index, 例如第一个流是视频流,第二个流是音频流等, 从0开始. ic->streams[i]就是AVStream 流.
index: 是文件index, 例如第一个文件是输出0,第二个文件是输出1等. 从0开始.
它调用了:
avcodec_string(buf, sizeof(buf), avctx, is_output);
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
------------------------------------------------------------------------------------------
1. 从AVFormatContext ic 可以得到AVCodecContext avctx, 参数从流参数中得到.
avctx = avcodec_alloc_context3(NULL);
ret = avcodec_parameters_to_context(avctx, st->codecpar); //还有未导入的参数,可以手工导入.
2. 字符串意义解释:
$8 = "Video: h264, 1 reference frame, yuv420p(tv, progressive, left), 640x480 (0x0) [SAR 4:3 DAR 16:9], 0/1, q=2-31, 2000 kb/s
AVCodecContext *enc,
codec_type = av_get_media_type_string(enc->codec_type); // Video(AVMEDIA_TYPE_VIDEO) 编码类型
codec_name = avcodec_get_name(enc->codec_id); // h264(AV_CODEC_ID_H264) 编码ID
&nb

本文详细解读了AVDumpFormat输出的M3U8文件中视频流和音频流的编码格式、参数及含义,包括H264视频编码、AAC音频编码,以及关键属性如分辨率、比特率、帧率等。
1586

被折叠的 条评论
为什么被折叠?



