ffmpeg:Codec for stream 0 does not use global headers but container format requires global headers
Posted Dontla
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ffmpeg:Codec for stream 0 does not use global headers but container format requires global headers相关的知识,希望对你有一定的参考价值。
ubuntu下,我用.h264转换.mp4格式提示一下信息:
ffmpeg -i 1e1fee9790f26fa3_202214225310.h264 -vcodec copy -f mp4 test.mp4
[root@ubuntu /arnold_test/20220104_ffmpeg_test]6# ffmpeg -i 1e1fee9790f26fa3_202214225310.h264 -vcodec copy -f mp4 test.mp4
ffmpeg version 2.8.17-0ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
...
Input #0, h264, from '1e1fee9790f26fa3_202214225310.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p, 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[mp4 @ 0x1acb080] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080, q=2-31, 25 fps, 25 tbr, 1200k tbn, 1200k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 150 fps=0.0 q=-1.0 Lsize= 1451kB time=00:00:05.96 bitrate=1994.0kbits/s
video:1449kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.097164%
[root@ubuntu /arnold_test/20220104_ffmpeg_test]7#
这个也不算个错误,就是个警告,如果想消除可以这样
ffmpeg -i 1e1fee9790f26fa3_202214225310.h264 -vcodec copy -flags +global_header -f mp4 test.mp4
加上-flags +global_header
,就不会报提示了
以上是关于ffmpeg:Codec for stream 0 does not use global headers but container format requires global headers的主要内容,如果未能解决你的问题,请参考以下文章
FFmpeg[36] - Could not write header for output file #0 (incorrect codec parameters ?): Invalid
FFmpeg[36] - Could not write header for output file #0 (incorrect codec parameters ?): Invalid
ffmpeg decode, encode, transcode, mux, demux, stream, filter的区别
Default encoder for format image2 (codec png) is probably disabled. Please choose an encoder manuall