Log in

View Full Version : AVIs incompatible with my digicam - I think I need something that copies AVI headers.


brett
27th October 2006, 08:35
My camera (Fuji FinePix F30) can record 640x480 30fps MJPEG AVIs. Since it's really small and has a good screen, it'd be nice to actually copy little video clips back onto it that I want to show people.

I can copy an AVI that the camera made to my computer, change the name, and copy it back to the camera and the video still plays fine. So it's a problem with the file itself.

I've tried about 10 different MJPEG codecs with all kinds of different settings, and none of the videos I create on my computer will play when I copy them to the camera.

I finally figured out that it has something to do with the AVI header. If I take an AVI that the camera made and do a direct stream copy in VirtualDub, the resulting file doesn't work when I copy it back to the camera (whether it's regular or "old format" AVI that I save it as).

I used a program called "abcAVI Tag Editor v1.7" and this is the tag info it gives me for an original AVI that the camera created:


[RIFF AVI 14036794]: Audio/Video Interleaved File
[LIST hdrl 9782]: Format Definition Chunk
[avih 56]: Main AVI Header
[dwMicroSecPerFrame]: Microseconds Per Frame: 33333
[dwMaxBytesPerSec]: Maximum Bytes Per Second: 1169408
[dwPaddingGranularity]: Padding Granularity (bytes): 0
[dwFlags]: Flags 0x00010010
[AVIF_HASINDEX]: AVI file has 'idx1' chunk
[AVIF_WASCAPTUREFILE]: AVI file is a specially allocated file used for capturing real-time video
[dwTotalFrames]: Number Of Frames: 360
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwStreams]: Number Of Streams: 2
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 192000
[dwWidth]: Image Width (pixels): 640
[dwHeight]: Image Height (pixels): 480
[LIST strl 9606]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: vids (Video Data)
[fccHandler]: Handler: mjpg (Motion JPEG including Huffman Tables 'mjpg' <0x67706A6D>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 33333
[dwRate]: Stream Rate: 1000000
[dwStart]: Stream Start: 0
[dwLength]: Stream Length: 360
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 192000
[dwQuality]: Stream Quality (1-10000): 10000
[dwSampleSize]: Sample Size: 0
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 640
[wY2]: Right: 480
[strf 40]: Video Stream Format
[biSize]: Header Size (bytes): 40
[biWidth]: Image Width (pixels): 640
[biHeight]: Image Height (pixels): 480
[biPlanes]: Number Of Planes: 1
[biBitCount]: Number Of Bits Per Pixel: 24
[biCompression]: Compression Algorithm: MJPG (Motion JPEG including Huffman Tables 'MJPG' <0x47504A4D>)
[biSizeImage]: Image Size (bytes, 0 = uncompressed): 921600
[biXPelsPerMeter]: Horizontal resolution of target device: 0
[biYPelsPerMeter]: Vertical resolution of target device: 0
[biClrUsed]: Number of colors used (0 = maximum): 0
[biClrImportant]: Number of important colors (0 = all): 0
*** [strd 9448]: Additional Header Data
[strn 26]: Stream Name: FUJIFILM AVI STREAM 0100
[LIST strl 92]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: auds (Audio Data)
[fccHandler]: Handler: 0x00000000 (No Compression <0x00000000>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 16000
[dwStart]: Stream Start: 0
[dwLength]: Stream Length: 192000
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 32000
[dwQuality]: Stream Quality (1-10000): 10000
[dwSampleSize]: Sample Size: 1
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 16]: Audio Stream Format
[wFormatTag]: Audio Format: 0x0001 (Microsoft PCM Format <0x0001>)
[nChannels]: Number of channels: 1
[nSamplesPerSec]: Frequency of the sample rate (Hz): 16000
[nAvgBytesPerSec]: Average data rate (byte/s): 16000
[nBlockAlign]: Block alignment of the data (bytes): 1
[wBitsPerSample]: Number of bits per sample (0 = undefined): 8
[cbSize]: Size of extra information (bytes): 0
[JUNK 4514]: Padding
[LIST movi 14016510]: Audio/Video Data
Skipped
[idx1 5952]: AVI Index Chunk


There are a few tags that are unique to this AVI, but what really stands out to me is the line that I added 3 stars by, the:

[strd 9448]: Additional Header Data

That's a pretty big section. 9 KB of header data that is totally gone after I run it through VDub.

A breakdown of how the header changes when VDub rebuilds it:


[RIFF AVI] Audio/Video Interleaved File 14,036,794 bytes -> 14,038,908 bytes
[LIST hdrl] Format Definition Chunk 9,782 bytes -> 292 bytes
[avih] Main AVI Header 56 bytes -> 56 bytes
[LIST strl] Stream Format Definition Chunk (video) 9,606 bytes -> 116 bytes
[strh] Stream Header 56 bytes -> 56 bytes
[strf] Video Stream Format 40 bytes -> 40 bytes
[strd] Additional Header Data 9,448 bytes -> *DOES NOT EXIST
*
[strn] Stream Name "FUJIFILM AVI STREAM 0100" -> *DOES NOT EXIST*
[LIST strl] Stream Format Definition Chunk (audio) 92 bytes -> 92 bytes
[JUNK] Padding 4,514 bytes -> 7,872 bytes
[LIST movi] Audio/Video Data 14,016,510 bytes -> 14,019,412 bytes
[idx1] AVI Index Chunk 5,952 bytes -> 11,296 bytes


So, it could be any of those things that is breaking the AVI so that the camera can't play it anymore. Maybe it's just looking for the "FUJIFILM" stream name. I also don't like the way the actual amount of audio/video data changes, and the index is twice as large. But the biggest difference I notice is the missing 9 KB "additional header data" section. That section might be storing the thumbnail image the camera uses for the video.

Anyway, I'd like to be able to copy over different pieces of the header from one AVI to another to see if one of them makes the AVI play on the camera, but I can't find any good utilities. That "abcAVI Tag Editor" can't do it.

I found a little program called "AVIRepair" that's supposed to copy headers from one AVI to another, but it doesn't do it right (the "fixed" AVI has all kinds of header corruption).

I'm going to see if I can fix it using XVI32, but I was hoping to find a utility that specifically copies sections of RIFF headers.

brett
4th November 2006, 07:18
I used 010 Editor to splice the "additional header data" section into a VDub-encoded AVI, and it gave the video a thumbnail that I could see, but when I tried to play the video it still didn't work.

cnn66
5th November 2006, 20:04
try ...

squid_80
6th November 2006, 16:52
When you spliced the header data in with the hex editor, did you fix all the RIFF sizes and index offsets?
I tried doing the same thing with my old digital camera just for the hell of it and found pretty much the same thing - the camera won't play without the extra header data. I could take files from the camera, direct stream them and they would play if I inserted the header data from the original files and fixed them up. But I couldn't figure out how to generate that data for clips that didn't originate from the camera so I gave up.