How to encode pixel data into a video format? - c

I'm using ESCAPI to capture webcam, it captures the frames in form of RGB pixel data, I've stored the RGB pixel data into a file but the file is huge 200MB for 15s video of 320x240.
I want to encode that pixel data into a video format.
I'm using MinGW on windows.

First use any encoder
I suggest H264 codec for encoding
so find its library for encoding and encode it
Then find any container File formats
I suggest Matroska (.mkv file)
so find its library for muxing encoded h264 in .mkv
Good begining is start with ffmpeg libraries.

Related

Why fmp4 files can't decode the audio with VLC, but they can play normally with PotPlayer

I have an fmp4 file (using h264 and aac frame codes). When playing with VLC, only video has no audio, but the audio can be parsed with PotPlayer.
The AAC format is ADTS.The screenshot of my fmp4 audio-related box is as follows
Mp4 should not have ADTS headers in the data. Just raw aac frames plus a configuration record in esds.

How to convert AV_SAMPLE_FMT_S16 to AV_SAMPLE_FMT_S16P?

I use ffmpeg to decode audio and use libmp3lame to encode it into mp3. As libmp3lame inside ffmpeg needs S16P instead of S16, I have to convert audio samples.
I tried using swr_convert but everytime I get a random crash. I started to have doubt if swr_convert accepts S16 as input or not.
So, how can I convert audio samples from AV_SAMPLE_FMT_S16 to AV_SAMPLE_FMT_S16P?

processing .raw file image with ffmpeg api or C code

I am trying to process a .raw image file captured using vrl2, it's a h264 encoded image with yuv422 color space from a Logitech c920 webcam, dcraw is not working for me however from my previous question this command is working fine with low performance (a 32kb jpg image however using opencv capture I get a 900kb image for the same 640x480 resolution):
ffmpeg -f rawvideo -s 640x480 -pix_fmt yuyv422 -i frame-1.raw
frame-1.jpg
I need a code written in C or the ffmpeg api/OpenCV etc .. to do the same as this command,I don't want to use QProcess in Qt(I am working on a server using Qt where I am trying to send the raw file from a Raspberry PI to the server and process it their), dcraw output is a corrupted image.
http://ffmpeg.org/doxygen/trunk/examples.html
There should be some api samples in there that show how to get the image out with that specific encoding.
When interacting with a RAW file, I have also used IrfanView. If you know the headersize of the file and the width and the height and the bits per pixel per color, you can see what it looks like quickly that way.
EDIT: I tried using Irfanview with your RAW, and I got something close, but not quite. The coloring was always off. I don't think it can handle that particular encoding of a RAW file right now.

Save video encoded by libavcodec to an AVI file format

I am able to encode video frames using libavcodec, by calling avcodec_encode_video function. How do I save these encoded frames into an AVI file?
Check this out:
http://forum.doom9.org/archive/index.php/t-112286.html
You must open file for binary write, write header in it, and simultaniosly put binary frames in it, I think.

jpg file transfer using a socket_stream in C

I was wondering if sending a file with a jpg extension through a socket_stream, this automatically makes the transformation of bytes to jpg ? or need to implement some algorithm to transform the lot of bytes to image... Please could somebody explain me the way to do?
JPEG images are nothing but a bunch of bytes organized according to the JPEG format. A network socket isn't going to organize random bytes into the JPEG format. You can send the bytes that make up a JPEG formatted image across a socket as a binary blob, receive it on the other end, and write it to a file with a .jpg extension. An application can interpret this file as a JPEG image based on the extension and try to display it. But you are still responsible for providing a set of bytes that are organized as a JPEG image.

Resources