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
g_fifoname="/tmp/fifocam1.h264";
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 things.
char* execargs[]={PATH_TO_FFMPEG,"-re","-y","-framerate","30","-f","h264","-video_size","1920x1080","-i",g_fifname,"-c:v","copy","-an",pathname, (char*)0};
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.
send my buffer to stdin and get ffmpeg to read stdout?
make the named fifo work?
thanks all,
Michael
Stream #0:0Opening an output file: /media/sd-card/orbi_0145.cam1.mp4.Successfully opened the file., 0, 1/1200000: Video: h264, 1 reference frame ([33][0][0][0] / 0x0021), yuv420p(left), 1920x1080 (0x0), 1/1200000, q=2-31, 29.97 fps, 29.97 tbr, 1200k tbn, 1200k tbcStream mapping: Stream #0:0 -> #0:0 (copy)Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested[AVIOContext @ 0x8c4ee0] Statistics: 0 seeks, 1 writeouts[AVIOContext @ 0x8aefc0] [mp4 @ 0x1017f50] Statistics: 32768 bytes read, 0 seeksExiting normally, received signal 15.Codec for stream 0 does not use global headers but container format requires global headersOutput #0, mp4, to '/media/sd-card/orbi_0145.cam1.mp4': Metadata: encoder : Lavf56.40.101 Stream #0:0, 0, 1/1200000: Video: h264, 1 reference frame ([33][0][0][0] / 0x0021), yuv420p(left), 1920x1080 (0x0), 1/1200000, q=2-31, 29.97 fps, 29.97 tbr, 1200k tbn, 1200k tbcStream mapping: Stream #0:0 -> #0:0 (copy)Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested[AVIOContext @ 0x1020ee0] Statistics: 0 seeks, 1 writeouts[AVIOContext @ 0x100afc0] [h264 @ 0x1e9d800] Statistics: 32768 bytes read, 0 seeksExiting normally, received signal 15.