我该如何使用ffmpeg编码Retina屏幕截图时保留2倍像素密度?

6
每当我使用ffmpeg编码HiDPI/Retina屏幕录制时,视频播放的大小是原来的2倍,因此看起来模糊,因为像素密度没有保留。
如何在使用ffmpeg时保留HiDPI屏幕录制的原始像素密度?
如何重现:
  1. Use QuickTime Player to create a Screen Recording on a Retina Mac.
  2. Play the video you recorded in QuickTime Player using the ⌘1 Actual Size view. Notice that it’s playing 2:1 on your Retina Display, so the video looks sharp. It’s playing in half the space of the actual recorded pixels.
  3. Use ffmpeg to encode the video using a command like this:

    ffmpeg -i haha.mov -c:v libx264 -crf 23 haha-lg.mov
    
  4. Play the new ffmpeg-compressed video in QuickTime Player using the ⌘1 Actual Size view. Notice that it’s playing 1:1, so the video looks fuzzy.
为了澄清,视频之所以看起来模糊并不是因为被压缩了。相反,它看起来模糊是因为视频播放的尺寸是应该的两倍,像素密度为1:1,而不是所需的2:1像素密度。这可能是因为在编码时丢弃了一些元数据。
值得一提的是,VLC也会播放过大(模糊)的两个视频。因此,能够播放HiDPI视频似乎是QuickTime Player的一个功能。
以下是ffmpeg显示的原始屏幕录制的详细信息:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'haha.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2018-02-26T16:46:00.000000Z
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iMac18,3
    com.apple.quicktime.software: Mac OS X 10.13.3 (17D102)
    com.apple.quicktime.creationdate: 2018-02-26T10:45:50-0600
  Duration: 00:00:04.35, start: 0.000000, bitrate: 10947 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1396x928 [SAR 1:1 DAR 349:232], 10701 kb/s, 60 fps, 60 tbr, 6k tbn, 12k tbc (default)
    Metadata:
      creation_time   : 2018-02-26T16:46:00.000000Z
      handler_name    : Core Media Data Handler
      encoder         : H.264

以下是经过ffmpeg压缩的版本信息:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'haha-lg.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf57.83.100
  Duration: 00:00:04.35, start: 0.000000, bitrate: 1923 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1396x928 [SAR 1:1 DAR 349:232], 1783 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc57.107.100 libx264

为了参考,我在Video Production上发布了一个略微不同版本的问题(https://video.stackexchange.com/questions/23503/how-does-quicktime-player-know-when-do-play-a-video-in-hidpi-retina-2x-mode),询问QuickTime如何准确知道何时以2倍模式播放视频。 - Sean Moubry
1个回答

3

当前FFmpeg不支持这种类型的元数据。如果您可以在FFmpeg的错误跟踪器上提供一个(简短的)示例,我们可能会在将来的版本中添加对此类型元数据的支持。


1
@hfossli,您是否为此功能开了一张故障单? - ericbn
2
@ericbn 看起来在ffmpeg上从未创建过这个问题(或者至少我找不到),所以我在这里创建了一个:https://trac.ffmpeg.org/ticket/7045 - Sean Moubry

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接