Decode mJPEG to a format usable by libx264 - c++

I am compressing frames coming from webcam with libx264. So far I used YUY2 raw frames and swscale to transcode the frames to I420, which is usable by x264.
Anyway I would like to add support for mJPEG webcams (usually webcam provides both, but mJPEG allows higher frame rates and resolutions). What can I use to transcode mJPEG to some format, that can be used by x264?

If you already use swscale why not to use ffmpeg/libav (libavcodec) for decoding mjpeg?

Related

Encoding uncompressed avi using RAWVIDEO codec and RGB24

I coded an encoder using FFMPEG (c++). The requirements for this encoder are:
The output format should be uncompressed avi,
Preferably using RGB24/YUV444 pixel format since we do not want chroma subsampling.
Most standard players should support the format (windows media player (WMP), VLC)
Using the encoder I wrote, I can write a number of file types right now:
Lossless H.264 encoded video using the YUV420p pixel format and AVI container. (Obviously not uncompressed and chroma subsampled, however both WMP and VLC play without any problem.)
MPEG4 encoded video using the YUV420p pixel format and AVI container.(Obviously not uncompressed and chroma subsampled, however both WMP and VLC play without any problem.)
AYUV encoded video using the YUVA444P pixel format. (uncompressed as far as I understand and not chroma subsampled. However, VLC does not play this.)
FFV1 encoded video using the YUV444P pixel format. (lossless, and not chroma subsampled. However, WMP does not play this.)
The above is derived from this very usefull post.
So I am now looking into the RAWVIDEO encoder from FFMPEG. I can't get this to work and neither can I find an example in the FFMPEG documentation on how to use this encoder for writing video. Can somebody point me in the right direction or supply sample code for this?
Also, if there is another direction I should follow to meet my requirements feel free to point me to it.
Thanks in advance

Decoded video gives different format from encoded one

I am trying to decode a h264 video that I encoded using FFMPEG. The encoder used is libx264rgb with a AV_PIX_FMT_BGR0 pixel format. The encoded video plays well inside ffplay.
When I decode the frames, I obtain a planar pixel format(AV_PIX_FMT_GBRP) which is different from the original. Is it normal? If yes is there a way to disable the planar format? (either at encoding or decoding). This would allow me to skip the packing overhead from planar at runtime.
I used this decoder sample with a AV_CODEC_ID_H264 decoder instead of AV_CODEC_ID_MPEG1VIDEO.
Thank you!

Is it possible to use libx264 to convert H264 raw data to a image(PNG/JPEG) without ffmpeg?

I received some video data via RTP / RTSP / SIP, the data is encoded by H264 and sent by a IP camera. I would like to convert H264 keyframe data into a picture and analyze whether it contains faces. I do not want to use FFMPEG such a huge library, just use libx264 and opencv can do it? How?
Thanks.
No, not possible. X264 can not decode (it is a h264 encoder only). It also can not encode jpeg/png. Ffmpeg is what you need. If it is too large, custom compile including only the features you need. And static link so unused functions are striped out.

FFMPEG get jpeg data buffer from mjpeg stream?

I'm using FFMPEG to decode video stream from IP Camera, I have the example code that can decode video stream with any codec into YUI frames format.
But my case is special, I will describe as below
The IP camera stream is MJPEG, and I want using FFMPEG to decode, but I don't want to decode frame into YUV, I want to decode frame under jpeg format, and save those jpeg buffer into image files (*.jpg).
So far, I can do it by converting YUV frame (after decoding) to Jpeg, but this will cause bad performance. Since video stream is MJPEG, I think I can get jpeg data before decoding to YUI, but I don't know how to do it.
Someone can help me?
Many thanks,
T&T

How to encode series of images into VP8 using WebM VP8 Encoder API? (C/C++)

How to transcode RGB images into VP8 frames (Keyframe + some dependent frames)?
So I created some images how to turn tham into VP8 now?
The easiest way to go is to use ffmpeg.
The latest release of ffmpeg (0.6) now supports the VP8 codec, and building it is now easy.
Then, ffmpeg makes it simple to gather individual frames into a movive. Here is a tutorial, but you can google for more results.
First, you need a codec library for VP8:
http://www.webmproject.org/code/build-prerequisites/
Using libvpx API you can then encode your RGB frames into VP8 frames.