我正在尝试找到创建 .mp4 文件的最佳设置,该文件可以在 Mac 和 Windows 上轻松加载。
现在使用这些设置
f image2 -pattern_type glob -i '*.png' -vcodec libx264 -preset ultrafast -qp 0 out.mp4
Run Code Online (Sandbox Code Playgroud)
生成的 .mp4 无法在 OSX 中启动。即 Quicktime 说文件已损坏,如果我拖到一个空的浏览器窗口,我只能查看。
这是我的完整输出
Administrators-iMac:anim foo$ ffmpeg -f image2 -pattern_type glob -i '*.png' -vcodec libx264 -preset ultrafast -qp 0 out.mp4
ffmpeg version 2.5.3 Copyright (c) 2000-2015 the FFmpeg developers
built on Jan 17 2015 12:08:40 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, image2, from '*.png':
Duration: 00:00:05.76, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba, 1080x720, 25 fps, 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x7fc9e2801800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fc9e2801800] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x7fc9e2801800] 264 - core 142 r2455 021c0dc - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf56.15.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 1080x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc56.13.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 144 fps=0.0 q=-1.0 Lsize= 606kB time=00:00:05.76 bitrate= 862.5kbits/s
video:605kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.225304%
[libx264 @ 0x7fc9e2801800] frame I:1 Avg QP: 0.00 size:181499
[libx264 @ 0x7fc9e2801800] frame P:143 Avg QP: 0.00 size: 3060
[libx264 @ 0x7fc9e2801800] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x7fc9e2801800] mb P I16..4: 77.8% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:22.2%
[libx264 @ 0x7fc9e2801800] coded y,u,v intra: 0.2% 0.1% 0.1% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7fc9e2801800] i16 v,h,dc,p: 100% 0% 0% 0%
[libx264 @ 0x7fc9e2801800] kb/s:859.84
Run Code Online (Sandbox Code Playgroud)
有两个问题:
您正在使用 PNG 图像作为输入。将图像转换为视频时,ffmpeg 尝试通过选择yuv444p像素格式来保留图像色彩空间,该格式不使用色度子采样。就像它说的:
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
Run Code Online (Sandbox Code Playgroud)
QuickTime 和 Windows Media Player 就是这样“过时”的媒体播放器。不过,大多数基于 FFmpeg 的播放器(例如 VLC)都可以处理此类视频。
-qp 0(很像-crf 0)在 x264 中启用无损模式,这使得文件使用高 4:4:4 预测配置文件。QuickTime 不支持此配置文件。Windows Media Player 也很可能不支持它(但我无法检查)。
为确保兼容性,您应该始终添加选项-pix_fmt yuv420p并选择有损编码方法,最好使用CRF 编码,并设置-crf为合理的值。CRF 默认值为 23,但 18-28 之间的任何值都可以,其中越低意味着质量越好。
请注意,旧版本的 Windows 根本不支持 H.264。在这里,您必须退回到 MPEG-2 甚至 MPEG-1。也可以看看:
阅读H.264 编码指南了解更多编码策略。
| 归档时间: |
|
| 查看次数: |
4359 次 |
| 最近记录: |