[FFmpeg-devel] [PATCH] h264/aac in flv

Baptiste Coudurier baptiste.coudurier
Tue May 6 15:42:40 CEST 2008


Michael Niedermayer wrote:
>>>> [...]
>>>>
>>>>      put_be24(pb,size + flags_size);
>>>> -    put_be24(pb,pkt->pts);
>>>> -    put_byte(pb,pkt->pts >> 24);
>>>> +    put_be24(pb,ts);
>>>> +    put_byte(pb,ts >> 24);
>>>>      put_be24(pb,flv->reserved);
>>>>      put_byte(pb,flags);
>>>>      if (enc->codec_id == CODEC_ID_VP6)
>>>>          put_byte(pb,0);
>>>>      if (enc->codec_id == CODEC_ID_VP6F)
>>>>          put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
>>>> +    else if (enc->codec_id == CODEC_ID_AAC)
>>>> +        put_byte(pb,1); // AAC raw
>>>> +    else if (enc->codec_id == CODEC_ID_H264) {
>>>> +        put_byte(pb,1); // AVC NALU
>>>> +        put_be24(pb,pkt->pts - (int)pkt->dts);
>>> why the cast ?
>> Because truncate_ts will make them positive :/
>> Attached patch may solve the issue.
> 
> int can be 64bit, int32_t would be more correct.

Ok.

> [...]
>> Index: libavformat/utils.c
>> ===================================================================
>> --- libavformat/utils.c	(revision 13010)
>> +++ libavformat/utils.c	(working copy)
>> @@ -2401,8 +2401,10 @@
>>  static void truncate_ts(AVStream *st, AVPacket *pkt){
>>      int64_t pts_mask = (2LL << (st->pts_wrap_bits-1)) - 1;
>>  
>> -//    if(pkt->dts < 0)
>> -//        pkt->dts= 0;  //this happens for low_delay=0 and B-frames, FIXME, needs further investigation about what we should do here
>> +    /* negative dts happens for low_delay=0 and B-frames
>> +     * must not truncate because wrap bits < 64 will not get them */
>> +    if(pkt->dts < 0)
>> +        return;
> 
> Iam against this change.

Can you please give a reason ?
Every muxer not using 64 bit pts will have to cast to get the correct
value. This seems a bit odd.

Anyway patch updated.

> [...]
>> @@ -49,11 +52,15 @@
>>      offset_t duration_offset;
>>      offset_t filesize_offset;
>>      int64_t duration;
>> +    int delay; ///< first dts delay for AVC
>>  } FLVContext;
>>  
>>  static int get_audio_flags(AVCodecContext *enc){
>>      int flags = (enc->bits_per_sample == 16) ? FLV_SAMPLESSIZE_16BIT : FLV_SAMPLESSIZE_8BIT;
>>  
> 
>> +    if (enc->codec_id == CODEC_ID_AAC) // specs force these parameters
>> +        return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
> 
> Is this also correct for AAC streams for which these arent true? Or are
> such streams just not supported?
> 

Streams are supported (like mp3 48khz btw), and play well. Like written,
specs mandates these values.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Smartjog USA Inc.                                http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: h264_aac_flv_mux.patch
Type: text/x-diff
Size: 5546 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080506/d0fcee6a/attachment.patch>



More information about the ffmpeg-devel mailing list