[FFmpeg-user] Feeding FFMPEG from buffer in c code RAW H264 to MP4 wrapping, or named fifo?

abraxas1 abraxas1 at gmail.com
Tue May 9 00:47:06 EEST 2017

i have a raw h264 stream coming in from cameras with a custom API. data
gets put into a callback function in my c code.

i need to wrap this as mp4. i'm using ffmpeg to do this now, but only after
the h264es file has been written and closed, so very time consuming on a
beaglebone-like processor.

i have been trying to write this data to a named pipe and feed that to
ffmpeg but can not get this to work. maybe i'm not opening/closing pipes
properly, it hangs. or not specifying the piping properly for ffmpeg.

is it possible to feed the buffered data more directly to ffmpeg? or, how
do i set up the named pipe to work properly?

first i'm opening the fifo like this

mkfifo(g_fifoname, 0666);               // make the fifos
fd_fifo[ch+brd*2] = open(g_fifoname, O_RDWR);

then, i'm calling ffmpeg like this, at this moment anyway. trying many

char* execargs[]={PATH_TO_FFMPEG,"-re","-y","-framerate","30","-f","h264","-video_size","1920x1080","-i",g_fifname,"-c:v","copy","-an",pathname,

i probably got the ffmpeg call wrong. argh. i open the fifo first, then
start ffmpeg. when streaming is stopped i close fifo's, then close ffmpeg
output file.

ffmpeg is so powerful and frustrating to wrangle. thanks all,

More information about the ffmpeg-user mailing list