前言
注意:flv是不支持h.265封装的。
$ make clean && make DEBUG=1 $ $ ./flv_mux_h264_aac Usage: ./flv_mux_h264_aac avfile/test1_856x480_24fps.h264 24 avfile/test1_44100_stereo.aac out1.flv ./flv_mux_h264_aac avfile/test2_960x544_25fps.h264 25 avfile/test2_44100_mono.aac out2.flv
【参考文章】
FLV格式详解_JT同学的博客-CSDN博客_flv格式**(推荐!!!)**
FLV封装格式介绍及解析 - 简书
音视频封装:FLV格式详解和打包H264、AAC方案(上) - 云+社区 - 腾讯云
音视频封装:FLV格式详解和打包H264、AAC方案(下) - 云+社区 - 腾讯云
【参考源码】
https://github.com/ImSjt/H.264toFLV.git
https://github.com/rainfly123/flvmuxer
【工具下载】
SpecialAAAC.exe:https://sourceforge.net/projects/aacstreamanalysis/
H264BSAnalyzer.exe:https://github.com/latelee/H264BSAnalyzer/tree/master/release
FlvParse.exe:https://github.com/ty6815/AvStackDocs/tree/master/media%20format/flv
$ tree . ├── aac_adts.c ├── aac_adts.h ├── avfile │ ├── out1.flv │ ├── out2.flv │ ├── test1_44100_stereo.aac │ ├── test1_856x480_24fps.h264 │ ├── test2_44100_mono.aac │ └── test2_960x544_25fps.h264 ├── docs │ ├── FLV封装格式介绍及解析 - 简书.mhtml │ ├── FLV格式详解_JT同学的博客-CSDN博客_flv格式.mhtml │ ├── 音视频封装:FLV格式详解和打包H264、AAC方案(上) - 云+社区 - 腾讯云.mhtml │ └── 音视频封装:FLV格式详解和打包H264、AAC方案(下) - 云+社区 - 腾讯云.mhtml ├── flv.c ├── flv_format.h ├── flv.h ├── h264_nalu.c ├── h264_nalu.h ├── main.c ├── Makefile ├── README.md ├── reference_code │ ├── flvmuxer-master.zip │ └── H.264toFLV-master.zip └── tools ├── FlvParse.exe ├── H264BSAnalyzer.exe └── SpecialAAAC.exe
/*************************************************************** * describe: Flv file format description(Mainly for H.264 & AAC) * author: linriming * e-mail: linriming20@163.com ***************************************************************/ #ifndef __FLV_FORMAT_H__ #define __FLV_FORMAT_H__ #include #define AUDIO_SUPPORT(x) (x << 2) /* bit[2] in flvheader's type_flag */ #define VIDEO_SUPPORT(x) (x << 0) /* bit[0] in flvheader's type_flag */ #define SIZE_FLV_HEADER sizeof(struct flvHeader) /* 9 Bytes */ #define SIZE_FLV_TAG_HEADER sizeof(struct flvTagHeader) /* 11 Bytes */ #define SIZE_PREVIOUS_TAG_SIZE sizeof(uint32_t) /* 4 Bytes */ /* FLV tag type */ typedef enum{ FLVTAG_TYPE_AUDIO = 0x08, FLVTAG_TYPE_VIDEO = 0x09, FLVTAG_TYPE_SCRIPT = 0x12, }flvTagType; /* AMF data type in