mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-23 11:19:55 +00:00
lavf/flvenc: add automatic bitstream filtering
add automatic bitstream filtering when mux AAC Reported-by: Yabo Wei weiyabogeijing@gmail.com Reviewed-by: Steven Liu<lq@onvideo.cn> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
parent
ff5ea59f7b
commit
053d33b46b
@ -653,11 +653,9 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int flv_write_header(AVFormatContext *s)
|
||||
static int flv_init(struct AVFormatContext *s)
|
||||
{
|
||||
int i;
|
||||
AVIOContext *pb = s->pb;
|
||||
FLVContext *flv = s->priv_data;
|
||||
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
@ -736,6 +734,15 @@ static int flv_write_header(AVFormatContext *s)
|
||||
|
||||
flv->delay = AV_NOPTS_VALUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int flv_write_header(AVFormatContext *s)
|
||||
{
|
||||
int i;
|
||||
AVIOContext *pb = s->pb;
|
||||
FLVContext *flv = s->priv_data;
|
||||
|
||||
avio_write(pb, "FLV", 3);
|
||||
avio_w8(pb, 1);
|
||||
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!flv->audio_par +
|
||||
@ -1074,6 +1081,18 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return pb->error;
|
||||
}
|
||||
|
||||
static int flv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
|
||||
{
|
||||
int ret = 1;
|
||||
AVStream *st = s->streams[pkt->stream_index];
|
||||
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
|
||||
if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
|
||||
ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const AVOption options[] = {
|
||||
{ "flvflags", "FLV muxer flags", offsetof(FLVContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
|
||||
{ "aac_seq_header_detect", "Put AAC sequence header based on stream data", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_AAC_SEQ_HEADER_DETECT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
|
||||
@ -1099,9 +1118,11 @@ AVOutputFormat ff_flv_muxer = {
|
||||
.priv_data_size = sizeof(FLVContext),
|
||||
.audio_codec = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_ADPCM_SWF,
|
||||
.video_codec = AV_CODEC_ID_FLV1,
|
||||
.init = flv_init,
|
||||
.write_header = flv_write_header,
|
||||
.write_packet = flv_write_packet,
|
||||
.write_trailer = flv_write_trailer,
|
||||
.check_bitstream= flv_check_bitstream,
|
||||
.codec_tag = (const AVCodecTag* const []) {
|
||||
flv_video_codec_ids, flv_audio_codec_ids, 0
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user