Re-codifica vídeo 4K para H.265 / HEVC com FFmpeg para reprodução no QuickTime

0

Eu tenho um vídeo 4K de uma hora que estava pesando 10 GB. Eu pensei em tentar recodificar o HEVC usando o FFmpeg para tentar economizar espaço, algo que eu não tinha tentado antes.

No entanto, mudei o formato do contêiner de .m4v para .mp4, o que não percebi que o QuickTime Player não pode reproduzir; suporta apenas fluxos HEVC dentro de contêineres .mov. O VLC pode reproduzir o .mp4, então a conversão parece ter sido bem-sucedida.

Então, tentei mudar o formato do contêiner para .mov, mas o QuickTime ainda não quer abri-lo.

Existe um passo adicional que está faltando? A conversão foi executada durante a noite, então prefiro não fazer isso novamente, se houver uma maneira de simplesmente alterar o contêiner.

$ ffmpeg -i otomatsuri.m4v -c:v libx265 -preset medium -crf 28 -c:a aac -b:a 128k otomatsuri.mp4
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.30)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'otomatsuri.m4v':
  Metadata:
    major_brand     : M4V 
    minor_version   : 1
    compatible_brands: M4V M4A mp42isom
    creation_time   : 2018-02-09T09:37:48.000000Z
    encoder         : Lavf57.83.100
  Duration: 00:53:53.00, start: 0.000000, bitrate: 24377 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 95 kb/s (default)
    Metadata:
      creation_time   : 2018-02-09T09:37:48.000000Z
      handler_name    : Core Media Audio
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2880x2160 [SAR 4:3 DAR 16:9], 24278 kb/s, 24 fps, 24 tbr, 60k tbn, 48 tbc (default)
    Metadata:
      creation_time   : 2018-02-09T09:37:48.000000Z
      handler_name    : Core Media Video
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> hevc (libx265))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 2.6
x265 [info]: build info [Mac OS X][clang 9.0.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-5 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(34 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 24 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-28.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: lslices=8 deblock sao
Output #0, mp4, to 'otomatsuri.mp4':
  Metadata:
    major_brand     : M4V 
    minor_version   : 1
    compatible_brands: M4V M4A mp42isom
    encoder         : Lavf57.83.100
    Stream #0:0(und): Video: hevc (libx265) (hev1 / 0x31766568), yuv420p, 2880x2160 [SAR 4:3 DAR 16:9], q=2-31, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2018-02-09T09:37:48.000000Z
      handler_name    : Core Media Video
      encoder         : Lavc57.107.100 libx265
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2018-02-09T09:37:48.000000Z
      handler_name    : Core Media Audio
      encoder         : Lavc57.107.100 aac
frame=77592 fps=2.8 q=-0.0 Lsize= 1670478kB time=00:53:52.93 bitrate=4232.9kbits/s speed=0.117x    
video:1624946kB audio:43103kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.145604%
x265 [info]: frame I:    738, Avg QP:25.05  kb/s: 9283.77 
x265 [info]: frame P:  20942, Avg QP:27.55  kb/s: 6165.77 
x265 [info]: frame B:  55912, Avg QP:31.10  kb/s: 3280.92 
x265 [info]: Weighted P-Frames: Y:21.5% UV:15.2%
x265 [info]: consecutive B-frames: 7.8% 10.9% 15.9% 46.2% 19.1% 

encoded 77592 frames in 27541.51s (2.82 fps), 4116.63 kb/s, Avg QP:30.09
[aac @ 0x7fd6d7801e00] Qavg: 58695.016
$ ffmpeg -i otomatsuri.mp4 -c copy -map 0  otomatsuri.mov
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.30)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'otomatsuri.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.83.100
  Duration: 00:53:53.00, start: 0.000000, bitrate: 4232 kb/s
    Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 2880x2160 [SAR 4:3 DAR 16:9], 4117 kb/s, 24 fps, 24 tbr, 12288 tbn, 24 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 109 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, mov, to 'otomatsuri.mov':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.83.100
    Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 2880x2160 [SAR 4:3 DAR 16:9], q=2-31, 4117 kb/s, 24 fps, 24 tbr, 12288 tbn, 12288 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 109 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=77592 fps=18819 q=-1.0 Lsize= 1670479kB time=00:53:52.90 bitrate=4232.9kbits/s speed= 784x    
video:1624946kB audio:43103kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.145614%
    
por rgov 10.02.2018 / 04:38

1 resposta

2

Alguns jogadores confiam em metadados para identificar se o conteúdo do arquivo pode ser usado. QT pertence a esta categoria. Como confirmado nos comentários, atribuir uma tag de codec de hvc1 permite a reprodução em QT,

ffmpeg -i otomatsuri.mp4 -c copy -map 0 -vtag hvc1 otomatsuri.mov
    
por 10.02.2018 / 14:21