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

Dave Rice dave at dericed.com
Sun Feb 24 02:41:37 CET 2013


Hi all,

I am capturing many DV tapes to dv files with dvgrab and then use ffmpeg to rewrap dv to mov. [1]  I'm also ingesting the entire tapes from beginning to end and typically the first frames of a tape will include a higher than usual amount of damage (audio dropouts, video error concealment, etc) and this makes the rewrapping from dv to mov fail, miss audio tracks, or cause loss of sync.

Here is the command I would like to use:

ffmpeg -i dv_tape_capture.dv -map 0 -c copy dv_tape_capture.mov

and here is a sample file that depicts the issue: http://dericed.com/samples/dv_tape_capture.dv

Here is an ffmpeg -i output of the file:

ffmpeg -i dv_tape_capture.dv 
ffmpeg version 1.1.git Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 23 2013 20:08:23 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (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-ffplay --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
  libavutil      52. 17.103 / 52. 17.103
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 39.101 /  3. 39.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[dv @ 0x7fd49b82b400] Detected timecode is invalid
[dvvideo @ 0x7fd49b813000] AC EOB marker is absent pos=64
    Last message repeated 1 times
[dvvideo @ 0x7fd49b813000] AC EOB marker is absent pos=65
[ ... trimmed ... ]
[dvvideo @ 0x7fd49b813000] AC EOB marker is absent pos=71
[dvvideo @ 0x7fd49b813000] AC EOB marker is absent pos=66
[dv @ 0x7fd49b82b400] Estimating duration from bitrate, this may be inaccurate
Input #0, dv, from 'dv_tape_capture.dv':
  Duration: 00:00:00.33, start: 0.000000, bitrate: 28771 kb/s
    Stream #0:0: Video: dvvideo, yuv411p, 720x480, 28771 kb/s, SAR 8:9 DAR 4:3, 29.97 tbr, 29.97 tbn, 29.97 tbc
At least one output file must be specified

Only the video is detected, although there is audio in the dv data once past the first few broken frames. Within the first 7 or 8 frames about 50% of the DIF blocks use video error concealment STA flags and audio errors. I grepped out the audio DIF blocks of the first frame as placed them in hex here as a sample: http://gist.github.com/dericed/8f0288f5133384b4fb6a

Without recognizing the audio in the first frames then no audio is copied if I try to use: ffmpeg -i dv_tape_capture.dv -map 0 -c copy dv_tape_capture.mov.

Since I can see the 9th frame and on has no video error concealment or audio errors. I then tried to use probesize to have ffmpeg read the stream further to detect the audio. Here I tried -probesize 1200000 since 1200000 bytes is the size of 10 ntsc dv frames.

ffmpeg -probesize 1200000 -i dv_tape_capture.dv -c copy -map 0 dv_tape_capture.mov
ffmpeg version 1.1.git Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 23 2013 20:08:23 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (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-ffplay --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
  libavutil      52. 17.103 / 52. 17.103
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 39.101 /  3. 39.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[dv @ 0x7fbf69036e00] Detected timecode is invalid
[dvvideo @ 0x7fbf69013000] AC EOB marker is absent pos=64
    Last message repeated 1 times
[dvvideo @ 0x7fbf69013000] AC EOB marker is absent pos=65
[ ... trimmed ... ]
[dvvideo @ 0x7fbf69013000] AC EOB marker is absent pos=66
[dv @ 0x7fbf69036e00] Estimating duration from bitrate, this may be inaccurate
Input #0, dv, from 'dv_tape_capture.dv':
  Duration: 00:00:00.33, start: 0.000000, bitrate: 28771 kb/s
    Stream #0:0: Video: dvvideo, yuv411p, 720x480, 28771 kb/s, SAR 8:9 DAR 4:3, 29.97 tbr, 29.97 tbn, 29.97 tbc
Output #0, mov, to 'dv_tape_capture.mov':
  Metadata:
    encoder         : Lavf54.63.100
    Stream #0:0: Video: dvvideo (dvcp / 0x70637664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 28771 kb/s, 30k tbn, 29.97 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[dv @ 0x7fbf69036e00] New audio stream 0:1 at pos:960000 and DTS:0s
dv_tape_capture.dv: Input/output error
frame=   10 fps=0.0 q=-1.0 Lsize=    1173kB time=00:00:00.33 bitrate=28790.8kbits/s    
video:1172kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.068000%

Still no audio listed in the stream mapping, but I now see the line:
[dv @ 0x7fbf69036e00] New audio stream 0:1 at pos:960000 and DTS:0s
(and actually I see with line without -probesize as well), but the new audio stream doesn't become mapped.

I can use dvanalyzer to detect the frame number of where the audio errors first cease and use tail to pipe the dv stream from that point onward to ffmpeg, like this:

tail -c +960001 dv_tape_capture.dv | ffmpeg -i -
ffmpeg version N-50177-g6f77122 Copyright (c) 2000-2013 the FFmpeg developers
built on Feb 22 2013 13:31:03 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configuration: --enable-gpl --enable-nonfree --enable-libx264 --enable-libfaac
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. 39.100 /  3. 39.100
libswscale      2.  2.100 /  2.  2.100
libswresample   0. 17.102 /  0. 17.102
libpostproc    52.  2.100 / 52.  2.100
[dv @ 0x2395560] Estimating duration from bitrate, this may be inaccurate
Input #0, dv, from 'pipe:':
Duration: N/A, 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
 
but I'd like to identify a cleaner way to copy both audio and video from dv to mov. I can't seem to find a way to map an audio stream that isn't detected in the first frame but exists later in the stream. Not sure if this is an enhancement request or I'm overlooking an option. Advice please.

Thanks,
Dave Rice

[1] I know dvgrab can output mov but ffmpeg does a better job with this task: copying dv timecode to mov timecode and better handling of 4 channel audio in dv.



More information about the ffmpeg-user mailing list