[FFmpeg-user] Delaying audio and video stream

Ladislav Józsa l.jozsa at gmail.com
Fri Sep 23 20:47:52 CEST 2011


Hi guys,

I have a video file with one audio track already attached to it and its
perfectly in sync with video. Then I have another audio track which I need
to add to the video as second audio track. But this audio track is ahead of
the audio/video stream so I need to delay it. When I use the following
command

ffmpeg -threads 4 -y -i ./DriveAng_CZE_2.pal.flac -itsoffset 1.2 -i
./DriveAngry_3D.mpg -map 1:0 -map 0:0 -vcodec mpeg2video -b 8192k -minrate
8192k -maxrate 8192k -bufsize 1835k -acodec mp2 -ab 192k -metadata:s:0
language=ces -acodec ac3 -ab 192k -metadata:s:0 language=eng
./DriveAngry_3D.mixed.ts

I get second audio track perfectly synced with the video but the first audio
track which originally came with video is out of sync. It is ahead of video.
Apparently, the command above has delayed only the video stream. Then I
tried

ffmpeg -threads 4 -y -i ./DriveAng_CZE_2.pal.flac -itsoffset 1.2 -i
./DriveAngry_3D.mpg -itsoffset 1.2 -i ./DriveAngry_3D.mpg -map 1:0 -map 0:0
-map 2:1 -vcodec mpeg2video -b 8192k -minrate 8192k -maxrate 8192k -bufsize
1835k -acodec mp2 -ab 192k -metadata:s:0 language=ces -acodec ac3 -ab 192k
-metadata:s:0 language=eng ./DriveAngry_3D.mixed.ts

but it didn't help. My ffmpeg version is

ffmpeg version N-32816-g3f7dc48, Copyright (c) 2000-2011 the FFmpeg
developers
  built on Sep 23 2011 19:42:22 with gcc 4.6.1
  configuration: --enable-filter=movie
  libavutil    51. 17. 0 / 51. 17. 0
  libavcodec   53. 17. 0 / 53. 17. 0
  libavformat  53. 13. 0 / 53. 13. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 3 /  2. 43. 3
  libswscale    2.  1. 0 /  2.  1. 0

Is there a way how to delay audio and video file at once? Or do I need to
separate the video first and go for two pass audio sync (first sync Czech
audio with the delayed video only and then add original audio stream)?

Thanks
Ladislav


More information about the ffmpeg-user mailing list