Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Simple mpg encoder...

runew
Beginner
4,662 Views
In our (CAD) application we have a simple video export option based on a stadard Microsoft codec package. The problems started with Vista, as this codec package refused to install. Therefore we're looking for another solution...

To put it simple, we have a set of frames/images that we'd like to encode to some kind of video that can be read by pure Windows intallations (Me/2000 and up). I guess plain old mpg1 would do the trick, but it isn't supported by IPP? Well, maybe some of the other supported formats would fit the bill...

I know next to nothing about video codecs, so I was hoping that there were some extremely simple (IPP based) examples out there, like:

encoder = InitEncoder(outFile, width, height, fps, quality [, numberOfFrames]);
encoder->AddFrame(image1);
encoder->AddFrame(image2);
encoder->AddFrame(image3);
...
encoder->Close();

I'm sure this is TOO simple, and that I'm hoping for too much (and that I'm over my head), but if there was an example that was somewhere in the neighborhood, I'd be very happy if anybody pointed to it for me :-)


0 Kudos
29 Replies
runew
Beginner
1,369 Views

>It would be nice if command line, .par file if any and one .bmp file have been provided.

I would love to, but I'm not sure how I can attatch enything here... is it possible, or should I place them onmy web server and provide you with links?

-Rune

0 Kudos
runew
Beginner
1,369 Views

Hi!

Your expert advice worked! I'm now able to create an mpeg-2 based avi file from a set of bmp files!

However, I can only get the mpeg-2 encoding to work. I was hoping for a more up to date encoder, like mpg-4, but I'm not able to get any of the others to work!!!

The command line I use is this:

For mpeg-2 encoding:
encoder m2 -i blah -w 384 -h 288 -f 25 -b 800000 -n 100 -o out_m2.avi
For h264-encoding:
encoder h264 -i blah -w 384 -h 288 -f 25 -b 800000 -n 100 -o out_h264.avi

etc. etc. (as I don't use an avi file as input I just write "dummy")

The result from the m2 command line is an avi file of 396 kB, not far from the goal (800 kbps x 4 secs = 400 kB). You can find the (working) mpeg-2 file here.

mpeg-4
When I try encoding with mpeg-4, the application completes without any error messages and the filesize is as expected (391 kB). The avi file, however, is not playable in any of my players (and I do have a lot).You can find it here.

h264
When I try encoding with h264, the application also completes without any error messages, nut this time the filesize isnot as expected (901 kB), and it's not playable either. You can find the output file here.

h262 & h263
When I try encoding with h261 or h263, the application fails on this line:

p_vidEncoder->Init(p_vidEncoderParams)

As far as I can see there's nothing wrong with the parameters, but who am I to tell...?

The source for my test application is here and the executable is here.

0 Kudos
runew
Beginner
1,369 Views

Thank you, Vladimir, your expert advice certainly helped!

I'm now able to convert a set of bmp files to a (working) mpeg-2 avi file!

However I'm not able to use any of the other codecs successfully. The application goes thought both the m4 and the h264 encoding process without any error messages, but the resulting files are unplayable. The m4 file is of the expected size (ca 400kB), but the h264 file is much larger than expected (ca 900 kB).

Trying to encode with h261/h263, the application failsat the following line:

if (p_vidEncoder->Init(p_vidEncoderParams) != UMC_OK)

As Init() returns not UMC_OK.

I don't care about h261/h263, however, as I only want to get the h264 / mpeg-4 encoding working.

I use the following command line:

vEnc h264 -i blah -w 384 -h 288 -f 25 -b 800000 -n 100 -o out_h264.avi

And here you can find my files:

Source file

Executable file
Working mpeg-2 file
Not working mpeg-4 file
Not working h264 file

Thank you for your time!

-Rune

0 Kudos
runew
Beginner
1,369 Views

Hi Nikolay, and thanks for answering!

Raw bitstreams? I had no idea... I need very badly to be able to create a"legal" AVI file that can be played back natively on all platforms from WinXP and up.

My impression was that this was handled by the umc_video_enc_con example, but I may have screwed this up when I modified it to take single images as input.

Is there some way of modifying"my" source to create a "fully functional" AVI file?

-R

0 Kudos
runew
Beginner
1,369 Views

Hi Nicolay, and thanks for your reply!

I didn't know about the raw compressed video output of umc_video_enc_con...

I have a couple of problems with ffmpeg. One is the legal problem ofbundling ffmpeg with out commercial application.We already had a working video export based on mplayer/mencoder, but it was abandoned because of legal issues. i don't think we can use ffmpeg either, although I'm not 100% sure of this.

The other problem is that I don't know how to change the fourcc from FMP4 to DIVX. Does this require yet another third party application?

---

Can I alternatively use simple_player as a playback application without going through the hassle of using ffmepg and changing the fourcc?

-Rune

0 Kudos
runew
Beginner
1,369 Views

smiley [:-)]

Nikolay - you're da man!

Thank you so very much! Now it works from A to Z, no problems!

Now I'll make the code lean and clean and hopefully add audio (mp3 file) to the mux (if I figure it out...)

Thanks again!

-Rune

0 Kudos
runew
Beginner
1,369 Views

ARRRRRRGHH!

The generated videos won't play on pure Vista OR XP systems without any extra codecs installed (which was one of the goals of this whole project)...

I've tried to "cheat" by using other fourcc's than DIVX (like MP42 and such), but to no avail. Windows Media Player opens the file, but refuses to play it on newly installed Vista or XP boxes :-(

I'm using the mpg4 encoder. Is it any hopes for any of the other ones in the umc_video_encoder example (for instance h264)?

-Rune

0 Kudos
Vladimir_Dudnik
Employee
1,369 Views

Hi Rune,

As far as I know, MJPEG decoder should be available on any Windows system by default. I think that the same is true for H.263 decoder.

On Windows Vista there should be default MPEG2 decoder (but not on Windows XP)

Regards,
Vladimir

0 Kudos
runew
Beginner
1,369 Views

Hi Vladimir!

OK. I'll give it a shot with the H.263-encoder then. Any idea what FOURCC is to be used with the H.263 codec?

Thanks!

-Rune

0 Kudos
Reply