-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
v2_CN_hevc
winlin edited this page Nov 14, 2021
·
6 revisions
支持hevc编码的协议:
- rtmp
- httpflv
- hls
- srt: 具体见srt codec wiki
因为rtmp在2012年后,协议没有更新,对hevc编码格式的支持在rtmp协议官方文档中没有明确定义。
国内cdn厂商通过修改<video_file_format_spec_v10_1>中CodecID的定义,将flv中的hevc codecid定义为12。
Field | Type | Comment |
---|---|---|
Frame Type | UB [4] | Frame Type Type of video frame. The following values are defined: 1 = key frame (for AVC and HEVC, a seekable frame) 2 = inter frame (for AVC and HEVC, a non-seekable frame) 3 = disposable inter frame (H.263 only) 4 = generated key frame (reserved for server use only) 5 = video info/command frame |
CodecID | UB [4] | Codec Identifier. The following values are defined: 2 = Sorenson H.263 3 = Screen video 4 = On2 VP6 5 = On2 VP6 with alpha channel 6 = Screen video version 2 7 = AVC 12=HEVC |
HVCPacketType | IF CodecID == 12 UI8 |
The following values are defined: 0 = HEVC sequence header 1 = HEVC NALU 2 = HEVC end of sequence (lower level NALU sequence ender is not required or supported |
CompositionTime | IF CodecID==7 OR CodecID == 12 SI24 |
IF AVCPacketType == 1 OR HVCPacketType == 1 Composition time offset ELSE 0 See ISO 14496-12, 8.15.3 for an explanation of composition times. The offset in an FLV file is always in milliseconds. |
VideoTagBody | IF FrameType == 5 UI8 ELSE ( IF CodecID == 2 H263VIDEOPACKET IF CodecID == 3 SCREENVIDEOPACKET IF CodecID == 4 VP6FLVVIDEOPACKET IF CodecID == 5 VP6FLVALPHAVIDEOPACKET IF CodecID == 6 SCREENV2VIDEOPACKET IF CodecID == 7 AVCVIDEOPACKET IF CodecID == 12 HVCVIDEOPACKET ) |
Video frame payload or frame info If FrameType == 5, instead of a video payload, the Video Data Body contains a UI8 with the following meaning: 0 = Start of client-side seeking video frame sequence 1 = End of client-side seeking video frame sequence For all but AVCVIDEOPACKET or HVCVIDEOPACKET, see the SWF File Format Specification for details |
因为当前官方ffmpeg的rtmp推/拉流默认不支持hevc的编码,所以需要重新对ffmpeg进行hevc in flv的自定义修改。
需要修改3个文件即可:
- libavformat/flv.h 新增hevc类型定义:
enum { FLV_CODECID_H263 = 2, FLV_CODECID_SCREEN = 3, FLV_CODECID_VP6 = 4, FLV_CODECID_VP6A = 5, FLV_CODECID_SCREEN2 = 6, FLV_CODECID_H264 = 7, FLV_CODECID_REALH263= 8, FLV_CODECID_MPEG4 = 9, FLV_CODECID_HEVC = 12, };
- libavformat/flvdec.c
支持hevc编码的flv解封装 - libavformat/flvenc.c
支持hevc编码的flv封装
如何编译支持hevc in flv的ffmpeg,请参考ffmpeg supports hevc in flv
在完成支持hevc in flv的定制化ffmpeg编译后,rtmp推流hevc视频编码,如下:
ffmpeg -re -i source.flv -c:v libx265 -c:a copy -f flv rtmp://127.0.0.1/live/livestream
rtmp拉流hevc视频编码格式,如下:
ffmpeg -i rtmp://127.0.0.1/live/livestream -f flv -y livestream.flv
播放:
ffplay rtmp://127.0.0.1/live/livestream
Runner365 2020.5
Welcome to SRS wiki!
Please select your language:
Please select your language:
Please select your language:
Please select your language:
Please select your language: