如何将一系列 PNG 图像转换为 YouTube 视频?

Raf*_*ael 17 png youtube ffmpeg

我有一个 PNG 序列(这里是一个样本),我用 ffmpeg 将其转换为视频:

ffmpeg -r 10 -i image%03d.png -s 1380x720 -c:v libx264 -qscale 10 -r 30
       basf_merck_libx264.mp4
Run Code Online (Sandbox Code Playgroud)

使用 VLC,它看起来很漂亮,但在youtube 上我看到的都是灰色的!?为什么?

在此处输入图片说明

过了一会儿,会显示一个带有彩色斑点的单杠:

在此处输入图片说明

当我将“-pix_fmt yuv420p”添加到命令中时,youtube 会正确显示剪辑。但是我可以选择的最高质量是 480p,为此目的太低了。

ffmpeg 输出

C:\Users\Raffael\Documents\proj>ffmpeg -r 10 -i image%03d.png -s 1380x720 -c:v libx264 -qscale 10 -r 30 basf_merck_libx264.mp4
ffmpeg version N-48785-g2ea3f37 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 12 2013 20:45:33 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnu
tls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-l
ibopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwol
ame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
--enable-filter=frei0r
  libavutil      52. 14.100 / 52. 14.100
  libavcodec     54. 86.100 / 54. 86.100
  libavformat    54. 59.107 / 54. 59.107
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from 'image%03d.png':
  Duration: 00:00:02.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgb24, 1380x720, 25 fps, 25 tbr, 25 tbn, 25 tbc
Please use -q:a or -q:v, -qscale is ambiguous
File 'basf_merck_libx264.mp4' already exists. Overwrite ? [y/N] y
using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle Cache64
[libx264 @ 00000000021c6fe0] profile High 4:4:4 Predictive, level 3.2, 4:4:4 8-bit
[libx264 @ 00000000021c6fe0] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options:
 cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 dead
zone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_int
ra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahea
d=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'basf_merck_libx264.mp4':
  Metadata:
    encoder         : Lavf54.59.107
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv444p, 1380x720, q=-1--1, 15360 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> libx264)
Press [q] to stop, [?] for help
frame=  151 fps= 16 q=-1.0 Lsize=    1995kB time=00:00:04.96 bitrate=3290.5kbits/s dup=100 drop=0
video:1992kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.127092%
[libx264 @ 00000000021c6fe0] frame I:1     Avg QP:22.19  size: 57949
[libx264 @ 00000000021c6fe0] frame P:54    Avg QP:26.90  size: 36277
[libx264 @ 00000000021c6fe0] frame B:96    Avg QP:21.56  size:   236
[libx264 @ 00000000021c6fe0] consecutive B-frames:  5.3%  1.3% 85.4%  7.9%
[libx264 @ 00000000021c6fe0] mb I  I16..4: 71.1%  2.5% 26.4%
[libx264 @ 00000000021c6fe0] mb P  I16..4:  0.6%  0.5%  5.7%  P16..4:  3.1%  2.1%  2.9%  0.0%  0.0%    skip:85.0%
[libx264 @ 00000000021c6fe0] mb B  I16..4:  0.2%  0.1%  0.0%  B16..8:  4.7%  0.1%  0.0%  direct: 0.0%  skip:94.9%  L0:77.6% L1:22.3% BI: 0.1%
[libx264 @ 00000000021c6fe0] 8x8 transform intra:7.7% inter:5.2%
[libx264 @ 00000000021c6fe0] coded y,u,v intra: 59.5% 54.3% 52.9% inter: 1.3% 1.0% 0.6%
[libx264 @ 00000000021c6fe0] i16 v,h,dc,p: 81% 15%  4%  0%
[libx264 @ 00000000021c6fe0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10%  5% 64%  3%  2%  4%  3%  4%  3%
[libx264 @ 00000000021c6fe0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 13% 21%  7%  6%  7%  6%  7%  6%
[libx264 @ 00000000021c6fe0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000021c6fe0] ref P L0: 65.3%  9.0% 20.2%  5.5%
[libx264 @ 00000000021c6fe0] ref B L0: 73.0% 21.7%  5.3%
[libx264 @ 00000000021c6fe0] ref B L1: 90.8%  9.2%
[libx264 @ 00000000021c6fe0] kb/s:3241.64
Run Code Online (Sandbox Code Playgroud)

我在我的网站上收集了信息:http : //www.joyofdata.de/blog/hd-clips-with-ffmpeg-for-youtube-and-vimeo/

slh*_*hck 38

YouTube 希望您的视频采用 H.264 编码。如果您使用libx264,请遵循 YouTube 的编码建议:

ffmpeg -framerate 10 -i image%03d.png -s:v 1280x720 -c:v libx264 \
-profile:v high -crf 20 -pix_fmt yuv420p daimler_man.mp4
Run Code Online (Sandbox Code Playgroud)

提示:

  • -qscale是一种设置质量的方式,但-qscale单独是模棱两可的。使用-qscale:v视频和-qscale:a用于支持它的音频编码器。除非您知道它的含义,否则不要使用此选项。

    x264 有更好的质量设置选项:-crf. 该恒定速率因子是恒定的质量的编码模式。较低的值意味着更好的质量,但低于 18 的任何值在视觉上可能不会更好。默认值为 23,但像 20 这样的值会更好,因为 YouTube 会再次重新编码您的视频。

  • -pix_fmt yuv420p应该用于为 PNG 输入启用 4:2:0 下采样,它通常根本没有下采样(4:4:4,如在您的输出中所观察到的)并且通常包含一个 Alpha 通道。YouTube 不会正确处理此问题。

  • -r不需要设置输出帧率,因为无论如何 YouTube 都会处理几乎所有的帧率。当每秒读取 10 个图像作为输入时,将输出帧速率更改为更高的值(例如 30)只会复制帧,这是不必要的。

  • -s:v 1380x720是一个奇怪的决议。考虑使用原生 16:9 720p 分辨率 1280×720,并在必要时重新生成您的绘图。这将为您在 YouTube 上省去一些麻烦和信箱问题,并且坚持不寻常的尺寸可能会阻止您的视频以全分辨率显示或以 720p 质量设置提供。

  • 使用 MP4 容器而不是 YouTube 建议您使用的 MOV。MP4 在功能上与 MOV 几乎相同,但在播放设备中具有更好的支持。一般来说,如果可以的话,更喜欢它而不是 MOV。