在 ffmpeg 中,为什么这个 AVC 视频不能转换为 H264?

在 ffmpeg 中,为什么这个 AVC 视频不能转换为 H264?
C:\vids\aug2020\uploaded>mediainfo avideo.mp4
General
Complete name                            : avideo.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 219 MiB
Duration                                 : 7 min 34 s
Overall bit rate                         : 4 052 kb/s
Writing application                      : Lavf58.31.104

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
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                                 : 7 min 34 s
Bit rate                                 : 3 919 kb/s
Width                                    : 1 080 pixels
Height                                   : 1 920 pixels
Display aspect ratio                     : 0.563
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.076
Stream size                              : 212 MiB (97%)
Title                                    : VideoHandle
Writing library                          : x264 core 158 r2984 3759fcb
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_r
ef=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=
1 / 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 / dir
ect=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
Language                                 : English
Color range                              : Full
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Format settings                          : Joint stereo / MS Stereo
Codec ID                                 : mp4a-6B
Duration                                 : 7 min 33 s
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Stream size                              : 6.93 MiB (3%)
Title                                    : SoundHandle
Writing library                          : LAME3.100
Language                                 : English
Default                                  : Yes
Alternate group                          : 1

^^^ 所以看到视频是 AVC

现在我尝试将其转换为 H264。我使用 -t 3(仅 3 秒),因为它更快,仅作为示例。但如果不使用 -t 3,问题还是一样。

C:\vids\aug2020\uploaded>ffmpeg -i "avideo.mp4" -t 3 -acodec libmp3lame -vcodec libx264 "aaa.mp4"
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --e
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --ena
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enabl
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'avideo.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.31.104
  Duration: 00:07:34.08, start: 0.000000, bitrate: 4052 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1080x1920 [SAR 1:1 DAR 9:16], 3918 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
 (default)
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandle
File 'aaa.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 @ 0000000002bc0500] using SAR=1/1
[libx264 @ 0000000002bc0500] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000002bc0500] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0000000002bc0500] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_in
tra=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_lookahe
ad=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 'aaa.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.31.104
    Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc), 1080x1920 [SAR 1:1 DAR 9:16], q=-1--1, 25 fps, 12800 tbn, 25 tbc (defau
lt)
    Metadata:
      handler_name    : VideoHandle
      encoder         : Lavc58.55.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: 18446744073709551615
    Stream #0:1(eng): Audio: mp3 (libmp3lame) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp (default)
    Metadata:
      handler_name    : SoundHandle
      encoder         : Lavc58.55.101 libmp3lame
frame=   75 fps=8.3 q=-1.0 Lsize=    2061kB time=00:00:03.00 bitrate=5611.3kbits/s speed=0.331x
video:2011kB audio:47kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.162176%
[libx264 @ 0000000002bc0500] frame I:1     Avg QP:21.24  size:106597
[libx264 @ 0000000002bc0500] frame P:22    Avg QP:22.75  size: 43373
[libx264 @ 0000000002bc0500] frame B:52    Avg QP:24.69  size: 19182
[libx264 @ 0000000002bc0500] consecutive B-frames:  4.0%  8.0%  8.0% 80.0%
[libx264 @ 0000000002bc0500] mb I  I16..4: 10.0% 78.6% 11.4%
[libx264 @ 0000000002bc0500] mb P  I16..4:  8.0% 33.1%  2.0%  P16..4: 33.0%  8.1%  3.5%  0.0%  0.0%    skip:12.4%
[libx264 @ 0000000002bc0500] mb B  I16..4:  2.9%  7.4%  0.4%  B16..8: 30.1%  3.9%  0.7%  direct: 7.3%  skip:47.2%  L0:44.6% L1:49.6% BI: 5.8%
[libx264 @ 0000000002bc0500] 8x8 transform intra:74.4% inter:75.7%
[libx264 @ 0000000002bc0500] coded y,uvDC,uvAC intra: 42.0% 51.1% 3.9% inter: 16.1% 25.1% 0.1%
[libx264 @ 0000000002bc0500] i16 v,h,dc,p: 32% 21% 13% 35%
[libx264 @ 0000000002bc0500] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 20% 22%  4%  6%  6%  5%  5%  4%
[libx264 @ 0000000002bc0500] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 21% 12%  6% 12% 10%  8%  6%  4%
[libx264 @ 0000000002bc0500] i8c dc,h,v,p: 51% 24% 20%  4%
[libx264 @ 0000000002bc0500] Weighted P-Frames: Y:45.5% UV:31.8%
[libx264 @ 0000000002bc0500] ref P L0: 58.9% 13.0% 19.7%  6.8%  1.7%
[libx264 @ 0000000002bc0500] ref B L0: 87.6% 10.1%  2.3%
[libx264 @ 0000000002bc0500] ref B L1: 96.0%  4.0%
[libx264 @ 0000000002bc0500] kb/s:5488.74

现在我用 mediainfo 测试它是否是 H264 或 AVC

C:\vids\aug2020\uploaded>mediainfo aaa.mp4
General
Complete name                            : aaa.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 2.01 MiB
Duration                                 : 3 s 24 ms
Overall bit rate                         : 5 583 kb/s
Writing application                      : Lavf58.31.104

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
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                                 : 3 s 0 ms
Bit rate                                 : 5 491 kb/s
Width                                    : 1 080 pixels
Height                                   : 1 920 pixels
Display aspect ratio                     : 0.563
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.106
Stream size                              : 1.96 MiB (98%)
Title                                    : VideoHandle
Writing library                          : x264 core 158 r2984 3759fcb
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_r
ef=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=
1 / 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 / dir
ect=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
Language                                 : English
Color range                              : Full
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Format settings                          : Joint stereo / MS Stereo
Codec ID                                 : mp4a-6B
Duration                                 : 3 s 24 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Stream size                              : 46.9 KiB (2%)
Title                                    : SoundHandle
Writing library                          : LAME3.100
Language                                 : English
Default                                  : Yes
Alternate group                          : 1



C:\vids\aug2020\uploaded>

^^ 看到 ffmpeg 生成的文件仍然是 AVC!但我没有复制视频编解码器,我指定了-vcodec libx264

答案1

音频视频编码H.264 – 它们是完全相同的编解码器,但有两个标准化名称。(“MPEG-4 AVC”来自 MPEG 组,而“H.264”是 ITU-T 标准,您看到哪一个取决于程序。)

请注意,ffmpeg/ffprobe 已将该文件列h264 (avc)在“输入”下。

同样,H.265 与 HEVC 是同一回事。

相关内容