@ -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
} ,