我正在尝试使用 ffmpeg 将原始 yuv 视频转换为 mp4。
ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -r 25 -pix_fmt yuv420p -i Beauty_3840x2160_120fps_420_10bit_YUV.yuv -c:v libx264 -preset slow -qp 0 bb/output.mp4
我的视频出现错误。
ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -r 25 -pix_fmt yuv420p -i Beauty_3840x2160_120fps_420_10bit_YUV.yuv -c:v libx264 -preset slow -qp 0 bb/output.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[rawvideo @ 0x7fffe7e28440] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'Beauty_3840x2160_120fps_420_10bit_YUV.yuv':
Duration: 00:03:12.00, start: 0.000000, bitrate: 622080 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 622080 kb/s, 25 tbr, 25 tbn, 25 tbc
File 'bb/output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fffe7e35c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fffe7e35c00] profile High 4:4:4 Predictive, level 5.0, 4:2:0 8-bit
[libx264 @ 0x7fffe7e35c00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=8 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, mp4, to 'bb/output.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 4800 fps= 16 q=-1.0 Lsize=11907234kB time=00:03:11.96 bitrate=508147.7kbits/s speed=0.646x
video:11907177kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000485%
[libx264 @ 0x7fffe7e35c00] frame I:2789 Avg QP: 0.00 size:2638070
[libx264 @ 0x7fffe7e35c00] frame P:2011 Avg QP: 0.00 size:2404461
[libx264 @ 0x7fffe7e35c00] mb I I16..4..PCM: 28.0% 0.0% 67.1% 4.9%
[libx264 @ 0x7fffe7e35c00] mb P I16..4..PCM: 5.6% 0.0% 6.2% 0.6% P16..4: 52.9% 23.9% 10.8% 0.0% 0.0% skip: 0.0%
[libx264 @ 0x7fffe7e35c00] 8x8 transform intra:0.0% inter:9.6%
[libx264 @ 0x7fffe7e35c00] coded y,uvDC,uvAC intra: 99.4% 100.0% 100.0% inter: 100.0% 100.0% 100.0%
[libx264 @ 0x7fffe7e35c00] i16 v,h,dc,p: 89% 0% 1% 10%
[libx264 @ 0x7fffe7e35c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 65% 0% 0% 0% 0% 0% 0% 0% 35%
[libx264 @ 0x7fffe7e35c00] i8c dc,h,v,p: 1% 0% 94% 4%
[libx264 @ 0x7fffe7e35c00] Weighted P-Frames: Y:31.1% UV:29.3%
[libx264 @ 0x7fffe7e35c00] ref P L0: 21.3% 16.1% 27.4% 14.4% 11.7% 5.5% 3.6%
我得到了绿色视频。
答案1
提供适当的-pixel_format
和-video_size
:
ffmpeg -framerate 120 -video_size 3840x2160 -pixel_format yuv420p10le -i input.yuv -vf scale=1920:1080 -r 25 -c:v libx264 -preset slow -qp 0 output.mp4
看:
- rawvideo 解复用器文档
- 像素格式列表 (
ffmpeg -pix_fmts
)