[FFmpeg-user] Audio and video desynchronized in clips.
R. Clayton
rvclayton at verizon.net
Fri Mar 25 18:00:38 CET 2011
I've written a shell script that cuts a media file into a sequence of clips
using ffmpeg commands that look like this:
ffmpeg -i failure.mp4 -vcodec copy -acodec copy -ss 00:40:00 -t 00:10:00 \
-y clip04.mp4
This command works fine for .flv files, but the clips produced for .mp4 files
become progressively more desynchronized. The first clip is fine, but in the
second clip the audio lags the video by a second or so, and the lag grows
larger for successive clips (the source is synchronized throughout).
All possible combinations of the options -async 1 and -copyts have no effect.
What are the incantations I can use to produce synchronized .mp4 clips?
For the thorough, here's failure.mp4 information:
$ ffprobe failure.mp4
FFprobe version git-6a7e074, Copyright (c) 2007-2011 the FFmpeg developers
built on Mar 8 2011 10:38:12 with gcc 4.5.2
configuration: --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc'
--enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis
--enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc
--enable-x11grab --enable-libgsm --enable-libtheora
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264
--enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter
--enable-libdirac --disable-decoder=libdirac --enable-libschroedinger
--disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg
--enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec
--disable-armv5te --disable-armv6 --disable-vis
libavutil 50. 39. 0 / 50. 39. 0
libavcodec 52.113. 2 / 52.113. 2
libavformat 52.102. 0 / 52.102. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1. 76. 0 / 1. 76. 0
libswscale 0. 12. 0 / 0. 12. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'failure.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2010-03-06 01:44:18
Duration: 00:53:00.36, start: 0.000000, bitrate: 581 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 472 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc
Metadata:
creation_time : 2010-03-06 01:44:18
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 105 kb/s
Metadata:
creation_time : 2010-03-06 01:45:36
$
and here's information on the last clip:
$ ffprobe clip05.mp4
FFprobe version git-6a7e074, Copyright (c) 2007-2011 the FFmpeg developers
built on Mar 8 2011 10:38:12 with gcc 4.5.2
configuration: --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc'
--enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis
--enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc
--enable-x11grab --enable-libgsm --enable-libtheora
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264
--enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter
--enable-libdirac --disable-decoder=libdirac --enable-libschroedinger
--disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg
--enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec
--disable-armv5te --disable-armv6 --disable-vis
libavutil 50. 39. 0 / 50. 39. 0
libavcodec 52.113. 2 / 52.113. 2
libavformat 52.102. 0 / 52.102. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1. 76. 0 / 1. 76. 0
libswscale 0. 12. 0 / 0. 12. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clip05.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.102.0
Duration: 00:03:00.34, start: 0.000000, bitrate: 413 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 335 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 73 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
$
More information about the ffmpeg-user
mailing list