FFMPEG 转换 rawvideo 像素格式

FFMPEG 转换 rawvideo 像素格式

我有一个原始的 uyvy422 视频流,我正在尝试将其转换为 yuv420p 流。我认为这应该是可能的,因为 FFMPEG 会在必要时转换 h264 的色彩空间。

$ffmpeg \
-f rawvideo -pixel_format uyvy422 -video_size 1920x1080 -i test.uyvy422 \
-f rawvideo -pixel_format yuv420p -video_size 1920x1080 uyvy_to_yuv.420p

输出:

ffmpeg version 3.2.14-1~deb9u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[rawvideo @ 0x560821593f20] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'test.uyvy422':
  Duration: 00:00:00.60, start: 0.000000, bitrate: 829440 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, 829440 kb/s, 25 tbr, 25 tbn, 25 tbc
Output #0, rawvideo, to 'uyvy_to_yuv.420p':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.64.101 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=   15 fps=0.0 q=-0.0 Lsize=   60750kB time=00:00:00.60 bitrate=829440.0kbits/s speed=7.66x

可以看到,输入流是uyvy422,输出也是uyvy422。

答案1

-pixel_format是 rawvideo 解复用器的输入选项。使用-pix_fmt

$ffmpeg \
-f rawvideo -pixel_format uyvy422 -video_size 1920x1080 -i test.uyvy422 \
-f rawvideo -pix_fmt yuv420p -s 1920x1080 uyvy_to_yuv.420p

相关内容