Log in

View Full Version : Free MJPG codec?


JoelBenM
16th January 2008, 02:15
Hi everybody

I'm looking for a free MJPG codec, for encoding. vfw preferably, or direct show if not...

any recommendation?

:thanks: so much for any idea
Joel

mitsubishi
16th January 2008, 03:04
ffdshow

GrofLuigi
16th January 2008, 03:06
FFdshow (http://forum.doom9.org/showthread.php?t=120465) has MJpeg implementation. How well does it work, I don't know, because I haven't used it. But you may try.

GL

*edit - too late :)

stegre
16th January 2008, 03:07
I'd recommend using ffdshow (http://sourceforge.net/project/showfiles.php?group_id=173941), which will do either. After you choose ffdshow as the encoder, just select MJPEG from the configuration pulldown, set the bitrate mode and quality, and you'll be off and running...

edit: double too late ;).

But I'll add that have used it, and it works well. In fact, I'll have to re-confirm this (& maybe add the analysis to GSpot), but I think it produces files more "in spec" than some of the commercial alternatives. In particular it I believe creates a 4:2:0 subsamped MJPEG file, which is correct for MJPG, while some other codecs and the cheapie MJPG's produced by typical "still cameras in movie mode" often use 4:2:2 or 4:1:1 so they can start encoding without waiting around for the next scan line.

JoelBenM
16th January 2008, 19:12
This is great info - thanks so much. Stegre - your explanation was just great. I tried that with my VFW application and had two issues:

First, the file size grew HUGE very fast, which held the disk and therefore, harmed the performance again. Are there configuration settings that I could change to minimize that?

Second, perhaps my application is not doing something right. Can yo upoint me maybe to some application that uses this FFDShow MJPG codec? (preferably VFW, but anything would go)

thanks again so much,
Joel

therealjoeblow
18th January 2008, 00:20
VirtualDub Mod will re-encode using ffdshow in MJPEG mode, no problem. If it's a standard avi, ogm or mkv, vdmod will load it directly and you can set the recompression settings and save directly. If vdmod can't load the file directly (wmv, quicktime, rm, mpeg2, etc) then you can easily frameserver it to vdmod with avisynth and the directshowsource command.

JoelBenM
18th January 2008, 00:56
hi all

and thanks so much for all the help. I found now why i'm getting such HUGE file sizes. Basically, I'm using ICSeqCompressFrame, passing in the pixels. At first the compression is great, compressing the frames from 2156544 to 60000 or so. but then, after like 30 frames, ICSeqCompressFrame starts to fail and my code just puts the uncompressed image in the AVI

any ideas? why would it fail?

thanks much
J

foxyshadis
18th January 2008, 02:17
Do you get any error code back?

stegre
18th January 2008, 06:18
Except for listing codecs and the "render test", most of my programming work (GSpot) parses from scratch and specifically avoids all use of VFW or DirectShow API's - a requirement for me since one of GSpot's main uses is to identify a codec you "need but don't have" - attempting to use the API's would defeat the purpose. So I'm not that familiar with them. I did write create a VFW codec once, but not the code to use it, I used VDub.

All that being said, I was just glancing at the VFW API docs: are you calling ICCompressorFree for each frame you encode? From its misleading name it sounds like something you'd call to "free the resources for the compressor" - presumably at the end of the entire encode.

But the doc implies otherwise (http://msdn2.microsoft.com/en-us/library/ms708680(VS.85).aspx) - seems you have to call it once after each call to ICSeqCompressFrame. If you're not, maybe you're slowly building up some giant data structure as you proceed....