问题
The line
ffmpeg -f h264 -i pipe111.fifo -c:v copy -f mp4 -
gives the error:
Input #0, h264, from 'pipe111.fifo':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 480x270, 6 fps, 6 tbr, 1200k tbn, 12 tbc
[mp4 @ 0x1562130] muxer does not support non seekable output
Output #0, mp4, to 'pipe:':
Metadata:
encoder : Lavf56.9.100
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 480x270, q=2-31, 6 fps, 1200k tbn, 1200k tbc
Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
But the
ffmpeg -f h264 -i pipe111.fifo -c:v copy -f mp4 /some/file/in/fs.mp4
works correctly. Why? NO ERROR.
回答1:
Due to this question is still popular I want to write a quick answer from here https://superuser.com/questions/760056/receiving-ffmpeg-error-22-when-piping-data-to-stdout
the mp4 container requires the ability to seek within the file. A pipe is a stream, and impossible to seek inside of. Try using a streaming container like ts, or flv.
来源:https://stackoverflow.com/questions/27924274/ffmpeg-could-not-write-header-for-output-file-0