I am using FFMPEG library to mux H.264 and AAC frames to MP4 file. I can do that both using command line and C program.
Now, instead of writing the muxed MP4 data in to file I want to write these muxed data directly on to socket or pipe. Command line options for that will be appreciated. My actual goal is to write a C program though.
I tried using protocols tcp and udp but they are not working with Mp4 format. They are working with the matroska format.
Following is working.
ffmpeg -i Cartoon.mjpeg -f matroska -r 25 -vcodec copy tcp://10.99.19.224:8888
Following is not and gives error as below.
ffmpeg -i Cartoon.mjpeg -f mp4 -r 25 -vcodec copy tcp://10.99.19.224:8888
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Any help or advice? Thank you in advance.
If you look at all the ffmpeg output, there is a line:
The mp4 container needs to go back at the beggining of the file to write additional information. A thing that your network socket can not do. So it is not possible to use mp4 container here.
Just got one way to output the muxed MP4 output directly on the socket using fragments. I know there are limitations of using fragments but this can be useful.
https://www.ffmpeg.org/ffmpeg-formats.html#Example-1
So following command line is working for me now. I am able to play the MP4 file received from the 8888 port. ffprobe also confirms that its really an MP4 file.
Now I will have to write the C program to do this pragmatically.