tags:

views:

340

answers:

3

Is it possible to change the frame rate of an avi file using the Video for windows library? I tried the following steps but did not succeed. 1) AviFileInit 2) AviFileOpen(OF_READWRITE) 3) pavi1 = AviFileGetStream 4) avi_info = AviStreamInfo 5) avi_info.dwrate = 15 6) EditStreamSetInfo(dwrate) returns -2147467262.

A: 

I don't know anything about VfW, but you could always try hex-editing the file. The framerate is probably a field somewhere in the header of the AVI file.

Otherwise, you can script some tool like mencoder[1] to copy the stream to a new file under a different framerate.

[1] http://www.mplayerhq.hu/
rix0rrr
A: 

HRESULT: 0x80004002 (2147500034)
Name: E_NOINTERFACE
Description: The requested COM interface is not available
Severity code: Failed
Facility Code: FACILITY_NULL (0)
Error Code: 0x4002 (16386)

Does it work if you DON'T call EditStreamSetInfo?

Can you post up the code you use to set the stream info?

Goz
I don't know if there is a different way to post code in this forum. //ChangeFrameRateint frame_rate = 15;int error_code = 0;PAVIFILE file_ptr = NULL;PAVISTREAM stream_ptr = NULL;AVIFileInit();AVIFileOpen(AVIFileGetStream(file_ptr, AVIStreamInfo(stream_ptr, stream_info, sizeof(AVISTREAMINFO));/* stream_info.dwRate is 25. I want to change this parameter in the file to 15*/error_code = EdiStreamSetInfo(stream_ptr, /* Returns (-2147500034) */
Nripun
+4  A: 

I'm pretty sure the AVIFile* APIs don't support this. (Disclaimer: I was the one who defined those APIs, but it was over 15 years ago...)

You can't just call EditStreamSetInfo on an plain AVIStream, only one returned from CreateEditableStream.

You could use AVISave, then, but that would obviously re-copy the whole file.

So, yes, you would probably want to do this by parsing the AVI file header enough to find the one DWORD you want to change. There are lots of documents on the RIFF and AVI file formats out there, such as http://www.opennet.ru/docs/formats/avi.txt.

David Maymudes
Well i'd accept your memory even if its 15 years old ;) The RIFF format is incredibly easy to parse anyway.
Goz
+1 just for the coolness factor of a reply from the original developer!
Soo Wei Tan