[Ffmpeg-devel] corrupt audio when cut

Cyrus A lists
Tue Jan 16 03:22:00 CET 2007


Michael Niedermayer wrote:
> Hi
>
> On Fri, Jan 12, 2007 at 02:37:31PM -0500, Cyrus A wrote:
>   
>> Sometimes (say 5% of the time) when I use ffmepg -ss X -t Y to cut a 
>> smaller file out of a bigger file (in this case MPEG-4 avi with mp3), 
>> the audio will go corrupt. It's not the file because I can substitute 
>> different X and Y values in and it'll work fine (although still a 5-10% 
>> chance of corruption). Furthemore, if X and Y stay the same, the 
>> behavior is always the same, either corrupt or not corrupt.
>>
>> The orginial file is created with
>>
>> ffmpeg -v 0 -i /dev/video0 -async 1 -y -vcodec mpeg4 -acodec mp3 -t 3580 
>> -b 1750k -ab 192 -ar 44100 -s 480x384 -vtag DX50 'file.avi'
>>
>> The cut process is:
>>
>> ffmpeg -ss 60.0 -t 180.0 -y -vcodec copy -acodec copy -i file.avi 
>> cutfile.avi
>>
>> [cyrus at wkyt crontabs]$ /roosevelt/ffmpeg/ffmpeg -version
>> FFmpeg version SVN-r6849, Copyright (c) 2000-2006 Fabrice Bellard, et al.
>>     
>
> not latest svn
>
>
> [...]
>   
>> Thanks in advance for any help. To hear the corruption for yourself, 
>> http://wkyt.dynalias.com/test.flv
>>     
>
> useless, we of course need a source (avi) file and corresponding commandline
> which shows the corruption
>
> [...]
>   
>   
Switched to latest SVN. The same deal happens.

The original creation command is the same as before:

[cyrus at wkyt cyrus]$ ffmpeg -v 0 -i /dev/video0 -async 1 -y -vcodec mpeg4 
-acodec mp3 -t 85 -b 250k -ab 192 -ar 44100 -s 480x384 -vtag DX50 
'/usr/local/apache-tomcat/webapps/ROOT/test.avi'
FFmpeg version SVN-r7541, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-mp3lame
  libavutil version: 49.1.0
  libavcodec version: 51.28.0
  libavformat version: 51.7.0
  built on Jan 15 2007 19:52:27, gcc: 4.1.1 20060525 (Red Hat 4.1.1-1)
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding

The cutting process is:

ffmpeg -ss 48.0 -t 25.8 -y -vcodec copy -acodec copy -i test.avi cutfile.avi

The erroneous output is:
FFmpeg version SVN-r7541, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-mp3lame
  libavutil version: 49.1.0
  libavcodec version: 51.28.0
  libavformat version: 51.7.0
  built on Jan 15 2007 19:52:27, gcc: 4.1.1 20060525 (Red Hat 4.1.1-1)

Seems stream 0 codec frame rate differs from container frame rate: 
30000.00 (30000/1) -> 29.97 (30000/1001)
Input #0, avi, from 'test.avi':
  Duration: 00:29:40.0, start: 0.000000, bitrate: 1955 kb/s
  Stream #0.0: Video: mpeg4, yuv420p, 480x384, 29.97 fps(r)
  Stream #0.1: Audio: mp3, 44100 Hz, stereo, 192 kb/s
Output #0, avi, to 'cutfile.avi':
  Stream #0.0: Video: mpeg4, yuv420p, 480x384, q=2-31, 29.97 fps(c)
  Stream #0.1: Audio: mp3, 44100 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
error, non monotone timestamps -7 >= -7
error, non monotone timestamps -4 >= -4
error, non monotone timestamps -2 >= -2
error, non monotone timestamps 2 >= 2
error, non monotone timestamps 4 >= 4
[...]
error, non monotone timestamps 978 >= 978
error, non monotone timestamps 980 >= 980
error, non monotone timestamps 982 >= 982
error, non monotone timestamps 984 >= 984
frame=  780 q=0.0 Lsize=    5905kB time=25.8 bitrate=1875.5kbits/s   
video:5526kB audio:610kB global headers:0kB muxing overhead -3.759651%

HA! I did some testing and found out that if ((-ss value + 16) % 32) = 
0, the file will have the garbled audio. All other -ss values work fine, 
no matter what -t is. That's weird. (i.e. 16, 48, 80, 112... will create 
a corrupted file.) That's why 336.0 as the ss value was also a problem. 
To put it another way, if the -ss value / 16 is evenly divisible and 
odd, we've got problems.

Recorded file: http://wkyt.dynalias.com/test.avi
Cut file: http://wkyt.dynalias.com/cutfile.avi

Values for -ss that will break it: 16, 48, 80...

Thanks.
Cyrus




More information about the ffmpeg-devel mailing list