[FFmpeg-user] How to add padding silence for MP4 container?

Paul B Mahol onemda at gmail.com
Sat May 25 15:28:18 CEST 2013


On 5/25/13, Paul B Mahol <onemda at gmail.com> wrote:
> On 5/25/13, Francois Visagie <francois.visagie at gmail.com> wrote:
>> Hi All,
>>
>>
>>
>> I'm trying to help someone who needs to delay his audio stream by 2s: he
>> got
>> given a .mp4 file containing only video and a .aac file with audio which
>> he
>> needs to mux together delaying the audio by 2s.
>>
>>
>>
>> This works perfectly for MKV:
>>
>>
>>
>>                 ffmpeg -i invideo.mp4 -itsoffset 00:00:02.000 -i
>> inaudio.aac
>> -codec:v copy -codec:a copy out.mkv
>>
>>
>>
>> However, he'd prefer the MP4 container format. Although the ffmpeg
>> command
>> completes perfectly, no player on my machine respects the MP4 timestamps
>> and
>> I've seen this reported elsewhere also.
>>
>>
>>
>> So instead of using timestamps with MP4, is there a way to tell ffmpeg to
>> insert 2s of silence at the beginning of the audio?
>
> ffmpeg -i input -af aresample=firts_pts=X
>
> where X is 2 * sample_rate of your audio stream.
>
> you can't use -codec:a copy to insert real silence.

Well, you actually can, and that is "complicated" way, that others
have mentioned.

Note that in such case: creating silence, encoding silence into aac,
and than concatenating
silence and audio into another stream without transcoding, you can not
have always exact
precision, so 2s delay may be possible or may not (i never tried so dunno).


More information about the ffmpeg-user mailing list