View Full Version : How can I locate a keyframe in a DivX stream?
boilerlt1
16th May 2008, 18:26
Hi guys, major video newbie here.
I'm encoding DivX 3 video using ffdshow, and I'm encapsulating it in Matroska. I'm using mkvmerge, a Matroska utility, to pull the DivX stream out of the container. What I'd like to do is read the stream and locate the keyframes. However, I haven't found any luck finding information on how frames are encoded, other than that DivX 3 is based on Microsoft's MPEG-4 Version 3 codec.
Can anyone offer any tips? I couldn't find much when I searched the board.
Thanks!
setarip_old
16th May 2008, 18:42
Hi!
Load the DivX-compressed video into VirtualDub and press the keyframe radiobutton (looks like a key)...
boilerlt1
16th May 2008, 18:51
setarip_old -- unfortunately, I need to do this programatically, through code. Thanks for the tip though. :)
unskinnyboy
16th May 2008, 19:40
This isn't 1999. Why are you using DivX 3 for encoding?
boilerlt1
16th May 2008, 20:51
This isn't 1999. Why are you using DivX 3 for encoding?
Long story. :rolleyes: I'll try to summarize it:
The project is a DirectShow-based program where one process records video to disk. Another process (also DirectShow based) reads that video, while it's still being recorded to disk, and lets you seek around it. You could loosely think of it as a TiVo, but this is actually for monitoring video output from a scientific instrument. The video will be sync'ed with a considerable amount of metadata.
Now that that's out of the way... :)
The project requirements don't really bind me to using DivX 3, but so far anything newer than version 3 won't let me seek around video while it's still being recorded. EDIT -- if it matters, I've done initial testing with ffdshow, which is GPL'ed, so I can't really use that for production anyways.
On that note, how can I find keyframes in files recorded with newer versions of DivX?
Dark Shikari
16th May 2008, 21:05
EDIT -- if it matters, I've done initial testing with ffdshow, which is GPL'ed, so I can't really use that for production anyways.Isn't DivX 3 the hacked version of DivX using Microsoft's MPEG-4 codec? :p
boilerlt1
16th May 2008, 21:17
Why, yes it is. ;)
unskinnyboy
16th May 2008, 21:35
boilerlt1, I see. Your issue is very specific - seeking on a video while recording it, and you say anything above DivX 3 doesn't allow it? I am surprised. If anything, I'd have expected a newer version of an ASP codec to support this. I suppose you have already tried the latest builds of Xvid & DivX?
Why is ffdshow being GPL'd stopping you? AFAIK, GPL doesn't restrict any production usage (however, if you are using it for a commercial purpose and making money of it, then your program should also be GPL'd).
Now, about the frame list, I don't think you should reinvent the wheel, when there are existing tools which can do this.
Here is one way -
Get MPEG4 Modifier CL (http://www.moitah.net/download/latest/MPEG4ModifierCL.zip) from here.
In your program call it with the following parms:
mmcl --frame-list "C:\path_to_frame_list\frame_list.txt" "C:\path_to_your_video\yourvideo.avi"
Now do a:
findstr I-VOP "C:\path_to_frame_list\frame_list.txt">"C:\path_to_frame_list\I-frame_list.txt"
Your I-frame_list.txt will be in the following format:
0: I-VOP (0:00:00.000)
300: I-VOP (0:00:12.512)
600: I-VOP (0:00:25.025)
900: I-VOP (0:00:37.537)
1200: I-VOP (0:00:50.050)
1245: I-VOP (0:00:51.926)
1249: I-VOP (0:00:52.093)
1266: I-VOP (0:00:52.802)
1268: I-VOP (0:00:52.886)
1271: I-VOP (0:00:53.011)
1273: I-VOP (0:00:53.094)
1573: I-VOP (0:01:05.607)
1873: I-VOP (0:01:18.119)
2173: I-VOP (0:01:30.632)
2372: I-VOP (0:01:38.932)
2486: I-VOP (0:01:43.686)
2671: I-VOP (0:01:51.402)
2971: I-VOP (0:02:03.915)
3024: I-VOP (0:02:06.126)
3221: I-VOP (0:02:14.342)
3321: I-VOP (0:02:18.513)
3369: I-VOP (0:02:20.515)
....
...
..
I-VOP = I-frame
boilerlt1
16th May 2008, 21:50
Why is ffdshow being GPL'd stopping you? AFAIK, GPL doesn't restrict any production usage (however, if you are using it for a commercial purpose and making money of it, then your program should also be GPL'd).
Correct, this is a paid project. I understand mkvmerge is GPL'ed as well, and ultimately we will avoid using anything that doesn't have a commercial-compatible license. There are some killer GPL-based tools out there... but unfortunately we're not in a position to make this project open-source as well.
Dark Shikari
16th May 2008, 22:06
Correct, this is a paid project. I understand mkvmerge is GPL'ed as well, and ultimately we will avoid using anything that doesn't have a commercial-compatible license. There are some killer GPL-based tools out there... but unfortunately we're not in a position to make this project open-source as well.First of all, in that case, you better not use DivX 3; being hacked, its totally illegal and has no commercial use clause whatsoever.
Perhaps you should use ffmpeg, which is available under the far less restrictive LGPL?
Ajax_Undone
16th May 2008, 23:49
You know you could hit the Divx guys up on a feature request for the read behind writing ability that divx 3 has...
Probubly not going to happen so If not I would go with ffmpeg...
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.