X
X
xiaose2011-10-13 18:48:21
Data synchronization
xiaose, 2011-10-13 18:48:21

FFmpeg: out of sync audio and video

What to do when audio and video are out of sync?

An example with this file: http://ge.tt/9ID9Jk8 I try to cut a piece from there: as a result I get this desynchronized file http://ge.tt/9ZVLKk8 a piece of video: I cut out an operational piece of audio: I compiled it into a file for playback: It seems to me that the result of http://ge.tt/9GnBLk8 turned out even worse :( PS. well, with the help and on what I did all these experiments:

ffmpeg -i summertime.mp4
...
Seems stream 1 codec frame rate differs from container frame rate: 60000.00 (60000/1) -> 29.97 (30000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'summertime.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isomavc1mp42
Duration: 00:09:05.94, start: 0.000000, bitrate: 517 kb/s
Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16, 125 kb/s
Stream #0.1(und): Video: h264, yuv420p, 480x352 [PAR 1:1 DAR 15:11], 389 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 60k tbc
At least one output file must be specified


ffmpeg -i summertime.mp4 -y -vcodec copy -sameq -acodec copy -ss 00:00:30 -t 00:00:30 pv.mp4

ffmpeg -i pv.mp4
...
[aac @ 0x9d348f0]Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. If you heard an audible artifact, please submit the sample to the FFmpeg developers.

Seems stream 0 codec frame rate differs from container frame rate: 60000.00 (60000/1) -> 29.97 (30000/1001)
Last message repeated 1 times
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pv.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf52.64.2
Duration: 00:00:30.00, start: 0.000000, bitrate: 657 kb/s
Stream #0.0(und): Video: h264, yuv420p, 480x352 [PAR 1:1 DAR 15:11], 535 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 60k tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 125 kb/s
At least one output file must be specified




ffmpeg -i summertime.mp4 -vcodec copy -sameq -y -an video.mp4
ffmpeg -i summertime.mp4 -acodec copy -sameq -y -vn audio.aac


ffmpeg -i video.mp4 -y -vcodec copy -sameq -ss 00:00:30 -t 00:00:30 pv.mp4 && ffmpeg -i pv.mp4 -sameq -y pv.mpg && rm -f pv.mp4


ffmpeg -i audio.aac -y -sameq -ss 00:00:30 -t 00:00:30 pa.wav


ffmpeg -i pa.wav -i pv.mpg -vcodec copy -sameq -y res.mpg



ffmpeg -version
FFmpeg version 0.6.2-4:0.6.2-1ubuntu1.1, Copyright © 2000-2010 the Libav developers
built on Sep 16 2011 16:57:46 with gcc 4.5.2
...
...
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0

FFmpeg 0.6.2-4:0.6.2-1ubuntu1.1
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0

uname -a
Linux base 2.6.38-11-generic-pae #50-Ubuntu SMP Mon Sep 12...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question