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

abraxas1 abraxas1 at gmail.com
Wed May 10 01:23:29 EEST 2017


ok, i removed the opening and the closing of the files that ffmpeg is
opening in it's own process. (they were legacy...)
now it seems to proceed through the recording nicely, with no output fro
ffmpeg until recording stops. i have to investigate just where the problem
starts, but probably with closing the fifo's which tell ffmpeg to finish
the stream and close it's output file(?)
and results in this. again, this is happening across 4 streams and the
output from the four ffmpegs is rather convoluted.
any thoughts? i must be so close to this working, i hope.
[h264 @ 0x10f8320] bytestream overread -11
[h264 @ 0x10f8320] error while decoding MB 52 40, bytestream -11
[h264 @ 0x10f8320] concealing 3357 DC, 3357 AC, 3357 MV errors in I frame
[h264 @ 0xe3320] bytestream overread -46
[h264 @ 0xe3320] error while decoding MB 26 40, bytestream -46
[h264 @ 0xe3320] [h264 @ 0x621320] concealing 3383 DC, 3383 AC, 3383 MV
errors in I frame
bytestream overread -12
[h264 @ 0x621320] error while decoding MB 24 43, bytestream -12
[h264 @ 0x621320] concealing 3025 DC, 3025 AC, 3025 MV errors in I frame
[h264 @ 0x10f8320] Frame num gap 5 3
**********************IN THREAD stopBlink turned to 1
[h264 @ 0x1087320] bytestream overread -7
[h264 @ 0x1087320] error while decoding MB 27 13, bytestream -7
[h264 @ 0x1087320] [h264 @ 0x621320] concealing 6622 DC, 6622 AC, 6622 MV
errors in P frame
[h264 @ 0xe3320] Frame num gap 8 6
Frame num gap 5 3
[h264 @ 0x10f8320] bytestream overread -4
[h264 @ 0x10f8320] bytestream overread -8
[h264 @ 0x10f8320] error while decoding MB 31 20, bytestream -8
[h264 @ 0x10f8320] concealing 5778 DC, 5778 AC, 5778 MV errors in P frame
[h264 @ 0xe3320] bytestream overread -8
[h264 @ 0xe3320] error while decoding MB 68 12, bytestream -8
[h264 @ 0xe3320] concealing 6701 DC, 6701 AC, 6701 MV errors in P frame
[h264 @ 0x1087320] Frame num gap 6 4
[h264 @ 0x1087320] bytestream overread -4
    Last message repeated 5 times
[h264 @ 0x1087320] bytestream overread -10
[h264 @ 0x1087320] error while decoding MB 58 14, bytestream -10
[h264 @ 0x1087320] concealing 6471 DC, 6471 AC, 6471 MV errors in P frame



On Tue, May 9, 2017 at 11:08 AM abraxas1 <abraxas1 at gmail.com> wrote:

> 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