ffmpeg - centOS上如何提高输出视频的清晰度?
问题描述
我在 Windows 和 centOS 上使用相同的 ffmpeg cmd 为输入视频添加时间码,centOS 上的输出视频具有低清晰度和马赛克。
ffmpeg 版本:
ffmpeg on Windows: 4.1.3 built with gcc 8.3.1 (gcc) 20190414
ffmpeg on centOS: 4.1.0 built with gcc 5.8.5(gcc) 20150623 (Red Hat 4.8.5-16)
ffmpeg 命令:
ffmpeg -i \input.mp4 -vf drawtext="timecode='00\:00\:00\:00':rate=30:x=10:y=10:text=qwer:fontsize=50:fontcolor=yellow:boxcolor=black" \output.mp4
视频截图:
完整登录centOS:
[root@3b8e5c174983 installfile]# ls
ffmpeg-4.1.3 ffmpeg-4.1.3.tar.gz input.mp4 yasm-1.3.0 yasm-1.3.0.tar.gz
[root@3b8e5c174983 installfile]# ffmpeg -i /installfile/input.mp4 -vf drawtext="fontfile=/usr/share/fonts/lyx/simhei.ttf:timecode='00\:00\:00\:00':rate=30:x=10:y=10:text=qwer:fontsize=50:fontcolor=black" /installfile/output.mp4
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-libfreetype
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/installfile/input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:00:25.68, start: 0.000000, bitrate: 3620 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 1920x1080, 3490 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to '/installfile/output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0(und): Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1920x1080, q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.35.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.35.100 aac
frame= 769 fps=108 q=31.0 Lsize= 10290kB time=00:00:25.70 bitrate=3279.4kbits/s speed=3.62x
video:9870kB audio:397kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.222400%
[aac @ 0x37dbec0] Qavg: 2346.057
[root@3b8e5c174983 installfile]#
它是关于 ffmpeg 的版本?
解决方案
您ffmpeg
在 CentOS 上未配置为使用编码器libx264 (H.264),因此它使用的是编码器mpeg4 (MPEG-4 Part 2)。该编码器是较老的一代,效率较低。
如果您想继续使用 mpeg4,请添加-q:v 2
以提高输出质量。
如果要输出 H.264,则需要重新编译ffmpeg
(--enable-gpl --enable-libx264
并--enable-libfreetype
用于 drawtext 过滤器)。有关编译指南,请参阅FFmpeg Wiki:CentOS ,或下载已编译的支持 libx264 的二进制文件。
-c:a copy
如果您不需要重新编码音频,您可以添加,因为输入和输出都是 AAC。
推荐阅读
- c# - Null Check 结合三元表达式抛出 NullReferenceException
- perl - overloading a Perl object to redirect hash access to custom routine
- bash - 如何在 Bash 中创建 JSON 数组
- python - 从通过 `pip install -e` 安装的 `sys.path` 中删除包路径
- reactjs - How to add Radio Button in Formik Validations Reactjs?
- python - 用什么来替换 matplotlib 已弃用的 line2d_seg_dist 函数?
- java - 为什么我的 java 计时器根本不重复代码?
- python - Splitting columns in pandas
- sql - 按日期从前一行数据中获取下一个数据的值
- c++ - 为什么 boost intrusive list 的 push_back 函数需要左值?