Question

I'm looking for a way to mux mjpeg (compressed) video data into a video container like mp4 or avi. (I'll also need to add audio in the future). Since i use FFMPEG in other parts of my project as well i'd like to do it using those libraries if possible. I'm not looking for command line FFMPEG use! I've tried to use the muxing example in ffmpeg with that i can only create a (very large) .mjpeg file with video information. This is not what I am looking for.

Examples would be very welcome, but a pointer in the right direction also works!

edit: I have output the yuvj422p stream to jpeg images and I want to put this into a mp4 container. Using ffmpeg commandline this works:

ffmpeg -i yuvy%01d.jpg -vcodec mjpeg out.mp4

I would like to do this directely in my code (without creating jpeg images first ofcourse)

Was it helpful?

Solution

I fixed it doing the following:

I used the muxing example and in stead of using the encode functions i just skipped it and directly loaded the JPEG data into the packet. To set up the OutputContext i used guess format functions and i set the codec to MJPEG. I changed the PTS data to a frame counter. since all frames are chronologic anyway.

OTHER TIPS

three major steps

  1. decode ( using avcodec_decode_video() )
  2. convert raw frame to yuv420p format ( using swscale() )
  3. encode ( using avcodec_encode_video() )

I can provide a sample code if you need

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top