【问题标题】:Bad conversion video from yuv to rgb using ffmpeg使用 ffmpeg 从 yuv 到 rgb 的错误转换视频
【发布时间】:2021-08-10 06:32:31
【问题描述】:

我正在尝试将视频从 YUV 转换为 RGB。我通过以下命令行使用 ffmpeg

ffmpeg -y input.mp4 -c:v libx264rgb output.mp4

不幸的是,输出似乎以某种方式损坏。请参阅下面的示例输入/输出图像。我还在此处粘贴两个视频的 mediainfo 输出。非常感谢您的建议。

input image

output image

媒体信息输入.mp4

General
Complete name                            : input.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 226 MiB
Duration                                 : 1 min 36 s
Overall bit rate                         : 19.7 Mb/s
Writing application                      : Lavf58.29.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L5.1
Format settings                          : CABAC / 5 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 5 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 min 36 s
Bit rate                                 : 19.3 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.093
Stream size                              : 222 MiB (98%)
Writing library                          : x264 core 148 r11 73ae2d1
Encoding settings                        : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=67 / lookahead_threads=11 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=infinite / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=crf / mbtree=1 / crf=20.0 / qcomp=0.60 / qpmin=5 / qpmax=69 / qpstep=4 / vbv_maxrate=24200 / vbv_bufsize=66000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 1 min 36 s
Bit rate mode                            : Constant
Bit rate                                 : 384 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 4.41 MiB (2%)
Default                                  : Yes
Alternate group                          : 1

媒体信息输出.mp4

General
Complete name                            : Starlings_264.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 340 MiB
Duration                                 : 1 min 36 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 29.7 Mb/s
Writing application                      : Lavf58.29.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High 4:4:4 Predictive@L5.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 min 36 s
Bit rate                                 : 29.6 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : RGB
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.143
Stream size                              : 339 MiB (100%)
Writing library                          : x264 core 155 r2917 0a84d98
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=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_lookahead=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
Color range                              : Limited
Matrix coefficients                      : Identity
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 1 min 36 s
Bit rate mode                            : Variable
Bit rate                                 : 118 kb/s
Maximum bit rate                         : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 1.35 MiB (0%)
Default                                  : Yes
Alternate group                          : 1

【问题讨论】:

  • 1. 根据documentationlibx264rgb 编码器与 libx264 相同,只是它接受打包的 RGB 像素格式作为 输入 而不是 YUV。 但是您的输入是 YUV,而不是 RGB。 2. 您忘记在input.mp4 之前添加-i(复制粘贴问题?)。 3. 更新您的 FFmpeg 版本。 4. 请解释一下这句话:“convert a video from YUV to RGB”您的预期输出是什么?

标签: python video ffmpeg rgb yuv


【解决方案1】:

你可以试试这个命令:

ffmpeg -y -i input.mp4 -c:v libx264rgb -crf 25 output.mp4

【讨论】:

  • 抱歉,有些输出。
  • 您可以将此-pix_fmt rgb24 添加到您的命令中
  • 同样的输出。
猜你喜欢
  • 2017-04-21
  • 2014-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-28
  • 2013-06-15
  • 1970-01-01
相关资源
最近更新 更多