[FFmpeg-user] ffmpeg with damaged dv from tape capture

Dave Rice dave at dericed.com
Fri Mar 8 16:07:57 CET 2013

On Feb 24, 2013, at 3:37 AM, Carl Eugen Hoyos wrote:

> Dave Rice <dave <at> dericed.com> writes:
>> Only the video is detected, although there is audio 
>> in the dv data once past the first few broken frames.
> I can reproduce the issue but are you sure whoever wants 
> to work on this issue will find enough audio in the 
> sample to test a possible fix? (I don't know.)

As I've been transferring more dv from tape via dvgrab I think I can more clearly express the issue. The issues appears to be more about how ffmpeg decodes audio error codes embedded within DV audio DIF blocks. While others tools like QuickTime decode them so that the audio will stay in sync, ffmpeg loses audio sync when processing audio dif blocks with the 0x8000 audio error code.

I uploaded a 60 second sample here http://dericed.com/samples/error.dv. Here is ffmpeg -i

ffmpeg -i error.dv 
ffmpeg version 1.1.git Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 18 2013 12:16:42 with Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libass --enable-ffplay --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
  libavutil      52. 17.102 / 52. 17.102
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 38.103 /  3. 38.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[dv @ 0x7fd21103d800] Estimating duration from bitrate, this may be inaccurate
Input #0, dv, from 'error.dv':
    timecode        : 01:09:48:11
  Duration: 00:01:00.03, start: 0.000000, bitrate: 28771 kb/s
    Stream #0:0: Video: dvvideo, yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28771 kb/s, 29.97 tbr, 29.97 tbn, 29.97 tbc
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
At least one output file must be specified

As many dv files transferred from physical dv tape do, the file contains video error concealment and audio error codes. These occurs in the range of frames 771 through 784 as detected by dvanalyzer. The video error concealment rate goes to 50% during this range as if there is a head clog, the audio DIF blocks of these frames are then filled with the DV audio error code 0x8000 [1] which should play as silence.

When I try
ffplay error.dv
the audio goes out of sync goes I get many "AC EOB marker is absent pos=" errors during the decoding of the frames with video error concealment and audio error codes.

When I play in QuickTime 7 the video and audio stay in sync, so I use QuickTime to convert the dv file to a wav file and also used ffmpeg to convert the dv file to a wav file. At 25.759 seconds in the files deviate. I made a screenshot of the two audio files in Audacity showing the point of deviation highlighted: http://dericed.com/samples/qt_vs_ffmpeg_difference_in_decoding_dv_audio.tiff. And here's a zoom in: qt_vs_ffmpeg_difference_in_decoding_dv_audio_zoom.tiff.

I tested the same file in mplayer and it also loss sync at the same point. 

Dave Rice

[1] http://web.archive.org/web/20060927044735/http://www.smpte.org/smpte_store/standards/pdf/s314m.pdf SMPTE 314M Section Audio Error Code

More information about the ffmpeg-user mailing list