what is the 4 char id for mpeg decoder in opencv - c++

I want to create a mpeg4 stream whith the following specs:
Container mp4.mov m4v
Resolution 1920 X 1080
Codec h264 main profile 4.1
I am wondering what CV_FOURCC and file extension should I use?
Any help appreciated.
I am using C++
In general where can find the fourcc for any coded?

If you read a file, you don't need to specify any codec.
If you write to a file, I think you need to specify X264. Full list of FOURCC codes avaliable here.

Some of the common fourCC codes used with OpenCV are mentioned here
http://opencv.willowgarage.com/wiki/documentation/cpp/highgui/VideoWriter
Here is a much longer list of the FOURCC codes of other codecs.
http://www.fourcc.org/codecs.php
Since you want to use H264, you can use H264 or X264 as the FOURCC codes.

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

opencv change video encoding parameters

I want to create a H.264 video out of frames generated by my program in C++. Is there a way to change the video encoding parameters for the VideoWriter object in my code, except the codec (eg. CRF) like we do in FFMpeg?
Thanks for your help

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.

How to add encoders/codec to opencv

So I am trying to use opencv VideoWriter but the thing is it only has about 5 codec options and does not have the codecs I would like to use such as HFYU (which support an alpha channel).
I want to know what exactly I need to do to get opencv to be able to use more codecs.
The codecs I can currently see (when passing -1 to videowriter) are:
Intel IYUV codec
Intel IYUV codec
Microsoft RLE
Microsoft Video 1
Lagarith Lossless Codec
Full Frames (Uncompressed)
Thanks in advance.

FFMpeg encoding RGB images to H264

I'm developing a DirectShow filter which has 2 input pins (1 for audio, 1 for video). I'm using libavcodec/libavformat/libavutil of FFMpeg for encoding the video to H264, audio to AAC and mux it/stream using RTP. So far I was able to encode video and audio correctly using libavcodec but now I see that FFMpeg seems to support RTP muxing too. Unfortunatelly, I can't find any example code which shows how to perform H264 encoding and RTP muxing. Does anybody know good samples?
Try checking out the code in HandBrake. Specifically, this file muxmp4.c, which was a jem I found working with FFMpeg / RTP. Be sure and use av_interleaved_write_frame() and the extradata fields correctly. Those were some key differences I remember for RTP.
Still, I had some stability issues with RTP/RTSP with FFMpeg, (I'm sure it's getting better). I had much better luck with live555, and you can look at the code in VLC and MPlayer for good examples on how to use it.