[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 21:08:05 EEST 2017
yes, thanks carl, i went on to do just that.
first i fed the buffer output to the fifo and piped that to a file. then i
used this command to successfully wrap that up as an mp4
ffmpeg -frqmerate 30 -y -f h264 -i /tmp/fifocam1.h264 -c:v copy -an
-video_size 1920x1080 -f mp4 fifocam1.mp4
then i jump back into my code, and try to get it all to work at once with
this command (moving the -video_size to the output side of the command
elliminated the video_size error)
and still no joy.
i think it's my sequence of events,perhaps.
how to properly tell ffmpeg to close up shop?
1) mkfifo(fifoname, S_IRUSR| S_IWUSR) (the latest options im trying there)
2) open(fifoname, O_RDWR|O_NONBLOCK) (other options have been tried...)
2a) fopen pathnaem, files that ffmpeg will write to (why the heck am i
doing this?)
3) launch exec thusly.
char*
execargs[]={PATH_TO_FFMPEG,"-loglevel","debug","-framerate","30","-y","-f","h264","-i",g_fifoname,"-c:v","copy","-an","-video_size","1920x1080","-f","mp4",pathname,
(char*)0};
4)write(fd_fifo[ch], buffer, size); in callback function that receives
camera data (as h264es)
5) stop video
6)close(fd_fifo)
7) rm fifo with execv (not sure why)
8) close files that ffmpeg should be writing to (why? this is ffmpeg
business)
9) kill(ffmpeg_pid, SIGTERM) (really shouldln't have to do this, i think.
closing the pipe should cause ffmpeg to wrap up thigns?)
ok, so let me take out the file manipulations ffmpeg should be doing.
my outputs are multiplexed because i'm doing this four times. 2 video
streams in 2 threads.
really appreciate the help, excited to get this to work.
thanks,
mike
Successfully opened the file.
Parsing a group of options: output url /media/sd-card/orbi_0145.cam3.mp4.
Applying option c:v (codec name) with argument copy.
Applying option an (disable audio) with argument 1.
Applying option f (force format) with argument mp4.
Successfully parsed a group of options.
Opening an output file: /media/sd-card/orbi_0145.cam3.mp4.
Successfully opened the file.
[mp4 @ 0x1101f50] Codec for stream 0 does not use global headers but
container format requires global headers
Output #0, mp4, to '/media/sd-card/orbi_0145.cam3.mp4':
[h264 @ 0x8a6800] interrupted
[h264 @ 0x8a6800] decoding for stream 0 failed
[h264 @ 0x8a6800] [h264 @ 0x1002800] 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 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?):
Immediate exit requested
[AVIOContext @ 0x110aee0] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0x10f4fc0] Statistics: 32768 bytes read, 0 seeks
Exiting normally, received signal 15.
interrupted
[h264 @ 0x1002800] decoding for stream 0 failed
[h264 @ 0x1002800] After avformat_find_stream_info() pos: 26624 bytes
read:32768 seeks:0 frames:3
Input #0, h264, from '/tmp/fifocam4.h264':
Duration: N/A, bitrate: N/A
Stream #0:0, 3, 1/1200000: Video: h264 (Main), 1 reference frame,
yuv420p(tv, left), 1920x1080 (1920x1088), 1001/60000, 29.97 fps, 29.97 tbr,
1200k tbn, 59.94 tbc
Successfully opened the file.
Parsing a group of options: output url /media/sd-card/orbi_0145.cam4.mp4.
Applying option c:v (codec name) with argument copy.
Applying option an (disable audio) with argument 1.
Applying option f (force format) with argument mp4.
After avformat_find_stream_info() pos: 18432 bytes read:32768 seeks:0
frames:3
Input #0, h264, from '/tmp/fifocam1.h264':
Successfully parsed a group of options.
Opening an output file: /media/sd-card/orbi_0145.cam4.mp4.
Successfully opened the file.
Duration: N/A, bitrate: N/A
Stream #0:0, 3, 1/1200000: Video: h264 (Main), 1 reference frame,
yuv420p(tv, left), 1920x1080 (1920x1088), 1001/60000, 29.97 fps, 29.97 tbr,
[mp4 @ 0x8bbf50] 1200k tbn, 59.94 tbc
Successfully opened the file.
Parsing a group of options: output url /media/sd-card/orbi_0145.cam1.mp4.
Codec for stream 0 does not use global headers but container format
requires global headers
On Tue, May 9, 2017 at 6:28 AM Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> 2017-05-08 23:47 GMT+02:00 abraxas1 <abraxas1 at gmail.com>:
>
> > char* execargs[ {PATH_TO_FFMPEG,"-re","-y","-framerate","30",
> > "-f","h264","-video_size","1920x1080","-i",
> > g_fifname,"-c:v","copy","-an",pathname, (char*)0};
>
> Test the command from the shell, remove the useless options
> like "f", "framerate" and "video_size" and if it doesn't work,
> provide the complete, uncut console output.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list