Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ffmpeg to scale app preview videos for the AppStore

I'm generating an app preview video to send to the AppStore. Depending on the device type, the AppStore requires certain video resolutions.

I have a main video, with resolution 1920x1080, which I was able to upload.

I need to generate another video with the resolution 1920x886 for supporting 6.5" devices, so I used the following command to perform the scaling:

ffmpeg -i video_1920_1080.mp4 -vf scale=1920:886 -c:a copy video_1920_886.mp4

If I get the info for the generated video using ffmpeg -i I get the following result:

ffmpeg -i video_1920_886.mp4

ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libx264 --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 'hittin_1920_886.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:29.13, start: 0.000000, bitrate: 705 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x886 [SAR 443:540 DAR 16:9], 694 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      timecode        : 00:00:10:20
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      handler_name    : TimeCodeHandler
      timecode        : 00:00:10:20

Ok, so it seems the output video is in the correct 1920x886 resolution.

However, when I try to upload this video the AppStore complains that the video is in the incorrect resolution.

If I open the file properties window on macos, the following information appears for the same video:

Properties of video_1920_886.mp4

And, if I open the same video on VLC, I can see the following info on the Media Info screen:

Codec Details on VLC

So:

  1. ffmpeg -i tells me the video is in the resolution 1920x886.
  2. macos file properties tells me the video is in the resolution 1575x886.
  3. VLC tells me the video has a Resolution of 1920x898 and a Display Resolution of 1920x886.

Why are there three different resolutions? How can I change each one of them? I suppose the appstoreconnect website expects the file properties resolution to be 1920x886. How can I change that?

like image 978
Felipe Ferri Avatar asked Dec 24 '22 02:12

Felipe Ferri


1 Answers

FFmpeg's scale filter will adjust the sample aspect ratio of the video so that the original display ratio is preserved. Apple, apparently, computes the new effective display resolution using that SAR.

Insert a setsar filter to reset the SAR to 1, so that the display resolution is the same as the stored resolution.

ffmpeg -i video_1920_1080.mp4 -vf scale=1920:886,setsar=1 -c:a copy video_1920_886.mp4
like image 59
Gyan Avatar answered Dec 28 '22 06:12

Gyan