我想使用 ffmpeg 转换视频大小但失败并出现以下错误。
ffmpeg -v verbose -i Running-Map-Reduce-program-on-EMR_frag.mp4 -vcodec h264 -filter scale=800x600 -f mp4 -hls_segment_filename 'file%03d.ts' out.m3u8
ffmpeg version N-103157-ge6754d2ad2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration:
libavutil 57. 3.100 / 57. 3.100
libavcodec 59. 4.100 / 59. 4.100
libavformat 59. 4.101 / 59. 4.101
libavdevice 59. 0.100 / 59. 0.100
libavfilter 8. 1.103 / 8. 1.103
libswscale 6. 0.100 / 6. 0.100
libswresample 4. 0.100 / 4. 0.100
[h264 @ 0x3278600] Reinit context to 1600x912, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Running-Map-Reduce-program-on-EMR_frag.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41iso5
Duration: 00:12:28.02, start: -0.023220, bitrate: 310 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1598x900 (1600x912), 231 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : Bento4 Video Handler
vendor_id : [0][0][0][0]
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 75 kb/s (default)
Metadata:
handler_name : Bento4 Sound Handler
vendor_id : [0][0][0][0]
Matched encoder 'h264_vaapi' for codec 'h264'.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264 @ 0x3365300] Reinit context to 1600x912, pix_fmt: yuv420p
[Parsed_scale_0 @ 0x3726b80] w:800 h:600 flags:'' interl:0
[graph 0 input from stream 0:0 @ 0x3727980] w:1598 h:900 pixfmt:yuv420p tb:1/12800 fr:25/1 sar:0/1
[auto_scaler_0 @ 0x3727140] w:iw h:ih flags:'' interl:0
[format @ 0x3727300] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_scale_0' and the filter 'format'
Impossible to convert between the formats supported by the filter 'Parsed_scale_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
[AVIOContext @ 0x336d180] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x327fc80] Statistics: 9588735 bytes
答案1
VAAPI硬件加速编码器
您的configure
行是空白的,这意味着您没有启用任何外部库和编码器,例如 libx264。因此对于通用编码-c:v h264
器,默认选择 h264_vaapi。这是一个硬件加速编码器,需要特定的附加选项。请参阅FFmpeg 维基:VAAPI(该网站目前出现问题,因此您可能需要尝试几次才能正常工作)。
libx264:更简单的方法
或者,获取启用了 libx264 的 ffmpeg 版本。然后它就可以正常工作了。请参阅FFmpeg Wiki:在 CentOS/RHEL 上编译和安装或者从以下网址下载已编译好的版本johnvansickle.com。
修复你的命令
与您遇到的确切问题无关,但您的命令不正确,不会输出分段。对于 HLS 分段,请使用:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -vf scale=800:600 -hls_segment_filename 'file%03d.ts' out.m3u8
查看HLS 多路复用器文档以获得更多选择。