Rtmp中video包介绍

转载请注明出处

Rtmp中video包介绍

Message type id: 9表示视频

第一个rtmp body: avc sequence header

首先看看包video data

184752_Q19p_2326611.png

注释:

使用ffmpeg推流,分析key frame每个字节的内容

rtmp body每个字节表示的含义

字节1:高四位表示key frame,低四位表示视频类型

字节2:0表示AVC sequence header

字节3,4,5:0表示composition time

字节6:1表示version

字节7:0x64表示profile

字节8:0表示profile compat

字节9:0x1f表示level

字节10:0xff,6 bits reserved (111111) + 2 bits nal size length - 1 (11)

字节11:0xe1,3 bits reserved (111) + 5 bits number of sps (00001)

字节12,13:0x1e,nal size

字节14:0x67,nal type,其中7表示sps

字节44:1表示number of pps。其中字节44为0x1e+nal type的地址

字节45,46:5表示pps size

ffmpeg对应生成第一个包代码的调用关系

358	static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par) {
(gdb) bt
#0  flv_write_codec_header (s=<value optimized out>, par=<value optimized out>) at libavformat/flvenc.c:358
#1  0x000000000061adde in flv_write_header (s=0x27706e0) at libavformat/flvenc.c:528
#2  0x0000000000687fae in write_header_internal (s=0x27706e0, options=<value optimized out>) at libavformat/mux.c:484
#3  avformat_write_header (s=0x27706e0, options=<value optimized out>) at libavformat/mux.c:538
#4  0x000000000048aeba in check_init_output_file (of=0x2769540, file_index=0) at ffmpeg.c:2771
#5  0x000000000048bb7d in init_output_stream () at ffmpeg.c:3102
#6  transcode_init () at ffmpeg.c:3481
#7  0x0000000000492874 in transcode (argc=<value optimized out>, argv=0x7fffffffe438) at ffmpeg.c:4357
#8  main (argc=<value optimized out>, argv=0x7fffffffe438) at ffmpeg.c:4591

第二个rtmp body: AVC NALU

首先看看包video data

185054_T2rr_2326611.png

注释:

body size 为870,包括两个NAL。

另外封装的时候去掉了H264的start code prefix 00 00 01,或者00 00 00 01,该body包括两个NAL,第一个nal的大小为0x02af,nal type值为6表示SEI,第二个nal的大小为0xaa,nal type值为5,表示IDR

ffmpeg对应生成第二个包代码的调用关系

#0  ff_avc_parse_nal_units (pb=0x28c6dc0, buf_in=<value optimized out>, size=865) at libavformat/avc.c:79
#1  0x00000000007267f9 in ff_avc_parse_nal_units_buf (buf_in=0x2832070 "", buf=0x7fffffffd940, size=0x7fffffffd94c) at libavformat/avc.c:99
#2  0x000000000061a3c5 in flv_write_packet (s=0x27706e0, pkt=0x7fffffffda40) at libavformat/flvenc.c:651
#3  0x00000000006886b5 in write_packet (s=0x27706e0, pkt=0x7fffffffda40) at libavformat/mux.c:772
#4  0x0000000000688dd9 in av_interleaved_write_frame (s=0x27706e0, pkt=0x0) at libavformat/mux.c:1271
#5  0x000000000048a69c in write_packet (of=<value optimized out>, pkt=0x7fffffffdcf0, ost=0x284b9e0) at ffmpeg.c:764
#6  0x000000000048d820 in do_video_out (of=0x2769540, ost=0x284b9e0, next_picture=0x34af4a0, sync_ipts=<value optimized out>) at ffmpeg.c:1282
#7  0x000000000048e6d7 in reap_filters (flush=0) at ffmpeg.c:1450
#8  0x0000000000492e8c in transcode_step (argc=<value optimized out>, argv=<value optimized out>) at ffmpeg.c:4342
#9  transcode (argc=<value optimized out>, argv=<value optimized out>) at ffmpeg.c:4386
#10 main (argc=<value optimized out>, argv=<value optimized out>) at ffmpeg.c:4591

 

注释:

rtmp body第一个video data包括sps和pps信息;第二个video data包括SEI和IDR信息

 

转载于:https://my.oschina.net/u/2326611/blog/854463

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值