ffmpeg av_dump_format 信息分析

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

编码一个文件, 用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值