1

I've got a 16:9 standard-def movie into which I need to burn some subtitles. I'm using

 ffmpeg -y -i input.mov -vf ass="./captions.ass" output.mov

and in the subtitle.ass file I've tried

PlayResX: 1024
PlayResY: 576

and

PlayResX: 768
PlayResY: 576

But in both cases the subtitles came out stretched. Is there anything I can do to get them square—either with the ffmpeg command or the subtitle file? I'd rather not stretch the video twice, it's already looking a bit shabby.

Command and console output:

PS C:\Users\stib\Desktop> ffmpeg -i .\test.mov -vf "ass='./test_subs.ass'" test_out.mp4
ffmpeg version N-76144-ge91cd8a Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  4.100 / 55.  4.100
  libavcodec     57.  7.100 / 57.  7.100
  libavformat    57.  8.102 / 57.  8.102
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 12.100 /  6. 12.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\test.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2014-05-07 03:24:23
  Duration: 00:01:50.84, start: 0.000000, bitrate: 30340 kb/s
    Stream #0:0(eng): Video: dvvideo (dvcp / 0x70637664), yuv420p(bt470bg/smpte170m/bt709), 720x576 [SAR 64:45 DAR 16:9], 28800 kb/s, SAR 118:81 DAR 295:162, 25 fps, 25 tbr, 25 tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2014-05-07 03:24:23
      handler_name    : Apple Alias Data Handler
      encoder         : DV - PAL
      timecode        : 01:00:00:00
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2014-05-07 03:24:23
      handler_name    : Apple Alias Data Handler
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2014-05-07 03:24:34
      handler_name    : Apple Alias Data Handler
      timecode        : 01:00:00:00
[Parsed_ass_0 @ 0000000002f61880] Shaper: FriBidi 0.19.6 (SIMPLE)
[Parsed_ass_0 @ 0000000002f61880] Using font provider directwrite
[Parsed_ass_0 @ 0000000002f61880] Added subtitle file: './test_subs.ass' (2 styles, 34 events)
[libx264 @ 0000000002f50cc0] using SAR=118/81
[libx264 @ 0000000002f50cc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000002f50cc0] profile High, level 3.0
[libx264 @ 0000000002f50cc0] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 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
Output #0, mp4, to 'test_out.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    encoder         : Lavf57.8.102
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 118:81 DAR 295:162], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2014-05-07 03:24:23
      handler_name    : Apple Alias Data Handler
      timecode        : 01:00:00:00
      encoder         : Lavc57.7.100 libx264
    Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s (default)
    Metadata:
      creation_time   : 2014-05-07 03:24:23
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc57.7.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (dvvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
[Parsed_ass_0 @ 0000000002f61880] fontselect: (Univers Com 55 Roman, 400, 0) -> UniversCom-55Roman, 0, UniversCom-55Roman
frame= 2771 fps=345 q=-1.0 Lsize=    8949kB time=00:01:50.85 bitrate= 661.3kbits/s
video:7133kB audio:1733kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.944520%
[libx264 @ 0000000002f50cc0] frame I:12    Avg QP:20.94  size: 50712
[libx264 @ 0000000002f50cc0] frame P:789   Avg QP:23.41  size:  6548
[libx264 @ 0000000002f50cc0] frame B:1970  Avg QP:26.27  size:   776
[libx264 @ 0000000002f50cc0] consecutive B-frames:  1.3%  5.5% 19.1% 74.2%
[libx264 @ 0000000002f50cc0] mb I  I16..4: 13.0% 72.4% 14.6%
[libx264 @ 0000000002f50cc0] mb P  I16..4:  1.0%  2.2%  0.4%  P16..4: 31.9%  9.3%  7.5%  0.0%  0.0%    skip:47.7%
[libx264 @ 0000000002f50cc0] mb B  I16..4:  0.0%  0.1%  0.0%  B16..8: 21.4%  0.9%  0.2%  direct: 0.4%  skip:76.9%  L0:41.3% L1:54.7% BI: 4.0%
[libx264 @ 0000000002f50cc0] 8x8 transform intra:64.5% inter:75.4%
[libx264 @ 0000000002f50cc0] coded y,uvDC,uvAC intra: 66.4% 69.9% 34.2% inter: 5.9% 10.1% 0.9%
[libx264 @ 0000000002f50cc0] i16 v,h,dc,p: 18% 65%  3% 14%
[libx264 @ 0000000002f50cc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 18% 22%  4%  4%  6%  4%  5%  6%
[libx264 @ 0000000002f50cc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 26% 11%  4%  5%  8%  5%  5%  5%
[libx264 @ 0000000002f50cc0] i8c dc,h,v,p: 42% 25% 28%  5%
[libx264 @ 0000000002f50cc0] Weighted P-Frames: Y:2.3% UV:2.3%
[libx264 @ 0000000002f50cc0] ref P L0: 55.6% 13.1% 21.8%  9.5%  0.0%
[libx264 @ 0000000002f50cc0] ref B L0: 82.5% 13.7%  3.8%
[libx264 @ 0000000002f50cc0] ref B L1: 92.9%  7.1%
[libx264 @ 0000000002f50cc0] kb/s:527.13

ASS file:

[Script Info]
ScriptType: v4.00+
PlayResX: 1024
PlayResY: 576

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, BorderStyle, Outline, Shadow, Alignment, MarginL, Margi nR, MarginV, AlphaLevel, Encoding
Style: Default,Univers Com 55 Roman,36,&Hffffff,&Hffffff,&H0,&H0,0,0,0,1,2,0,2,10,10,16,0,0

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.54,0:00:04.70,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:04.70,0:00:06.96,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:06.96,0:00:11.78,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:11.78,0:00:14.81,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:14.81,0:00:17.39,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:17.39,0:00:20.60,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:20.60,0:00:25.22,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:25.22,0:00:30.31,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:30.31,0:00:34.48,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:34.48,0:00:37.11,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:37.11,0:00:41.28,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:41.28,0:00:45.14,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:45.14,0:00:49.98,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:49.98,0:00:53.79,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:53.79,0:00:54.97,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:54.97,0:00:58.59,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:00:58.59,0:01:01.88,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:01.88,0:01:05.73,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:05.73,0:01:07.95,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:07.95,0:01:10.56,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:10.56,0:01:14.00,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:14.00,0:01:17.27,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:17.27,0:01:19.99,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:19.99,0:01:25.51,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:25.51,0:01:26.48,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:26.48,0:01:27.45,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:27.45,0:01:28.80,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:28.80,0:01:31.37,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:31.37,0:01:31.92,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:31.92,0:01:35.05,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:35.05,0:01:39.18,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:39.18,0:01:42.72,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:42.72,0:01:46.37,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
Dialogue: 0,0:01:46.37,0:01:51.25,Default,,0,0,0,,Lorem ipsum dolor sit amet,\Nconsectetur adipiscing
1
  • Please include the complete console output from your command, and provide the add ASS file (or just copy the contents into the question) if possible.
    – llogan
    Nov 25, 2015 at 18:49

2 Answers 2

2

You can try adding the original_size filter option, such as:

-vf "ass=test_subs.ass:original_size=768x576"

Specify the size of the original video, the video for which the ASS file was composed. For the syntax of this option, check the Video size section in the ffmpeg-utils manual. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to correctly scale the fonts if the aspect ratio has been changed.

3
  • Based on the documentation of the subtitles filter, it uses libass for the rendering itself. This filter just has a routine to convert other formats to .ass before stepping aside for libass.
    – Gyan
    Nov 27, 2015 at 5:15
  • 1
    @Mulvya The original_size option was the important part of the answer, which I assumed the ass filter lacked, but it appears to just be undocumented (can't test now). Answer updated.
    – llogan
    Nov 27, 2015 at 7:29
  • Tested - it works.
    – Gyan
    Nov 27, 2015 at 7:47
1

I found some ASS files, like this sample, which contain a Video Aspect Ratio tag but it seems to not make a difference in ffmpeg hardcoding.

The workaround I can think of right now is to create a complex filter where you create a transparent RGBA canvas of 1024x576; burn the subtitles onto them, scale the result to 768x576 or 720x576, depending on your source video and then overlay that output onto your video.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.