Short version: I believe I have truncated but otherwise valid AVI/DV files that won't play in any player I've tried (Adobe Premiere, MPC HC, VLC). I assume the stream data is intact but truncated, and the container is damaged. Are the files still recoverable and how would I accomplish this?
Long version: Having finished a recording from a Sony AnyCast workstation with two cameras to a FireWire hard disk drive, I accidentially unplugged the hard disk drive without "disconnecting" (unmounting) it first.
The result was a corrupted ext3 filesystem that would not mount under the Windows Ext2 IFS setup I was using to download the videos, so I connected the hard disk to a Linux laptop and ran e2fsck on it. After this, I was able to list the directory and copy the files, but the files appeared corrupted.
I'm working under the assumption that I've only lost some data at the end of the two video files. (This might prove false as e2fsck might have wrecked havoc on them.) That would mean I have 1,5 hours (x2) of unscathed DV stream. Unfortunately, my layman analysis concludes that these lost bits must have contained some information vital to the container format.
Note that all I have are the files copied to an NTFS volume from the fsck'ed ext3 volume. I no longer have access to the original hard disk drive.
Dear StackExchange, please help me find a way to recover and reconstruct these files! I suspect what I would need is some software that would guess or be told the information usually contained in the container header, copy the stream data and write it into a new, valid container file.
Edit: I believe the format is DV instead of MPEG2.
Edit2: It seems that the broken files do not in fact have an AVI header at all - they should begin with the bytes "RIFF" which they do not.
ffprobe does recognize the stream format, though:
[dv @ 0xefb8a0] Estimating duration from bitrate, this may be inaccurate Input #0, dv, from '120610-1-001.avi': Duration: 02:08:36.84, start: 0.000000, bitrate: 28799 kb/s Stream #0.0: Video: dvvideo, yuv420p, 720x576, 28800 kb/s, PAR 64:45 DAR 16:9, 25 tbr, 25 tbn, 25 tbc Stream #0.1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
Edit3: Thanks to Matti "Lumpio-" Virkkunen, we've finally got the video files fixed. He wrote a good 400 lines of C that did exactly what @JEEB suggested: crafted an AVI header and searched for things that look like AVI chunks, copying them over to the output file. A long AVI file needs a new header between every gigabyte or so, and the program simply fixes the broken first section and then copies the following sections as-is. The source code for
fixavi.c can be found on Gist.
Please note that details such as codecs, audio sample rate and video frame rate are hard-coded in the source, so if you need to replicate this process, please adapt the source to your needs. I found Alexander Noe's AVI format guide a good reference on the AVI file format.
Edit4: And as
fixavi.c does not create an index at the end of the AVI file, I simply used
./fixavi broken.avi recovered_without_index.avi; ffmpeg -i recovered_without_index.avi -acodec copy -vcodec copy recovered_with_index.avi to make one.
ffmpeg -i FILE(or better yet,
ffprobe FILE) return any sane result for the file?