Ticket #1098 (closed defect: fixed)
ass subtitle are stretched
| Reported by: | fate | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avfilter |
| Version: | git-master | Keywords: | ass |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | yes |
Description
I compiled ffmpeg with the option --enable-libass on debian sid. I can add ass subtitle with the command -vf "ass=subtitle.ass" but there is a little problem, the subtitles add with ffmpeg are stretched. I don't have this problem with mencoder and I think ffmpeg and mencoder use the same library libass.
In the image to the top you have the subtite load with vlc, with the good size, and to the bottom the subtitle add with ffmpeg.
I tried with several video, codec and subtitle and the result is always the same result.
Attachments
Change History
comment:1 Changed 14 months ago by cehoyos
- Keywords subtitle removed
Please add a ffmpeg command line that allows to reproduce the problem together with complete, uncut console output.
comment:2 Changed 14 months ago by fate
The ffmpeg command :
ffmpeg -i raw/Rocket_Girls_Raw_04.mp4 -vf "ass=ass/Rocket_04.ass" -vcodec libx264 -crf 26 -acodec libfaac -ab 128k -threads 4 -t "00:00:10" Rocket_Girls_04_test_ffmpeg_ass.mp4
The console output :
ffmpeg version N-38845-g463705b Copyright (c) 2000-2012 the FFmpeg developers
built on Mar 17 2012 17:11:41 with gcc 4.6.3
configuration: --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-gpl --enable-libfaac --enable-libtheora --enable-zlib --disable-shared --enable-libx264 --enable-libdirac --enable-nonfree --enable-version3 --enable-libschroedinger --enable-avfilter --enable-libspeex --enable-libopenjpeg --enable-libgsm --enable-postproc --enable-pthreads --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-ffplay --enable-pthreads --enable-libass --prefix=/usr/local --enable-x11grab --enable-runtime-cpudetect --enable-bzlib --enable-libdc1394 --enable-libvpx
libavutil 51. 42.100 / 51. 42.100
libavcodec 54. 10.100 / 54. 10.100
libavformat 54. 2.100 / 54. 2.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 65.100 / 2. 65.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 7.100 / 0. 7.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'raw/Rocket_Girls_Raw_04.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.5.0
Duration: 00:23:44.34, start: 0.000000, bitrate: 5652 kb/s
Stream #0:0(eng): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 186:157 DAR 279:157], 5425 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(jpn): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, s16, 224 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name :
[buffer @ 0x26c43a0] w:720 h:480 pixfmt:yuv420p tb:1/1000000 sar:186/157 sws_param:
[ass @ 0x265a280] Added subtitle file: 'ass/Rocket_04.ass' (2 styles, 2 events)
[buffersink @ 0x2659dc0] auto-inserting filter 'auto-inserted scale 0' between the filter 'Parsed_ass_0' and the filter 'out'
[ass @ 0x265a280] auto-inserting filter 'auto-inserted scale 1' between the filter 'src' and the filter 'Parsed_ass_0'
[scale @ 0x269c700] w:720 h:480 fmt:yuv420p -> w:720 h:480 fmt:rgb24 flags:0x4
[scale @ 0x26bf3a0] w:720 h:480 fmt:rgb24 -> w:720 h:480 fmt:yuv420p flags:0x4
[libx264 @ 0x26c3900] using SAR=186/157
[libx264 @ 0x26c3900] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x26c3900] profile High, level 3.0
[libx264 @ 0x26c3900] 264 - core 119 r2106 07efeb4 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - 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=4 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=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=26.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Rocket_Girls_04_test_ffmpeg_ass.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf54.2.100
Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 720x480 [SAR 186:157 DAR 279:157], q=-1--1, 24k tbn, 23.98 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(jpn): Audio: aac (@[0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name :
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (ac3 -> libfaac)
Press [q] to stop, [?] for help
DTS -1001, next:-41709 st:0 invalid droping
frame= 240 fps= 61 q=-1.0 Lsize= 379kB time=00:00:09.92 bitrate= 313.0kbits/s
video:215kB audio:157kB global headers:0kB muxing overhead 2.011653%
[libx264 @ 0x26c3900] frame I:3 Avg QP:21.79 size: 23661
[libx264 @ 0x26c3900] frame P:118 Avg QP:21.29 size: 1024
[libx264 @ 0x26c3900] frame B:119 Avg QP:27.89 size: 230
[libx264 @ 0x26c3900] consecutive B-frames: 33.3% 0.8% 2.5% 63.3%
[libx264 @ 0x26c3900] mb I I16..4: 15.5% 45.6% 38.9%
[libx264 @ 0x26c3900] mb P I16..4: 1.1% 1.2% 0.7% P16..4: 12.5% 1.9% 0.9% 0.0% 0.0% skip:81.9%
[libx264 @ 0x26c3900] mb B I16..4: 0.1% 0.0% 0.0% B16..8: 16.1% 0.3% 0.0% direct: 0.1% skip:83.4% L0:28.3% L1:71.3% BI: 0.4%
[libx264 @ 0x26c3900] 8x8 transform intra:42.0% inter:80.8%
[libx264 @ 0x26c3900] coded y,uvDC,uvAC intra: 43.9% 40.6% 16.6% inter: 1.2% 2.9% 0.1%
[libx264 @ 0x26c3900] i16 v,h,dc,p: 26% 28% 8% 38%
[libx264 @ 0x26c3900] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 14% 26% 4% 6% 13% 4% 5% 5%
[libx264 @ 0x26c3900] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 15% 14% 6% 9% 12% 6% 8% 3%
[libx264 @ 0x26c3900] i8c dc,h,v,p: 62% 18% 17% 3%
[libx264 @ 0x26c3900] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x26c3900] ref P L0: 74.9% 6.2% 15.4% 3.5%
[libx264 @ 0x26c3900] ref B L0: 90.9% 7.9% 1.2%
[libx264 @ 0x26c3900] ref B L1: 98.2% 1.8%
[libx264 @ 0x26c3900] kb/s:175.15
I attach the ass subtitle I used to made my tests.
comment:3 Changed 14 months ago by cehoyos
Is the problem also reproducible without -vcodec libx264 (but with one of the internal encoders)?
comment:4 Changed 14 months ago by fate
How I can use internal encoder ? (Sorry I'm a beginner on ffmpeg)
I tried with libxvid and I had the same problem.
comment:5 Changed 14 months ago by cehoyos
$ ffmpeg -i raw/Rocket_Girls_Raw_04.mp4 -vf ass=ass/Rocket_04.ass -an -vcodec mpeg4 -qscale 2 -t 10 Rocket_Girls_04_test_ffmpeg_ass.mp4
comment:7 follow-up: ↓ 9 Changed 14 months ago by saste
- Analyzed by developer set
- Status changed from new to open
- Reproduced by developer set
Confirm the problem:
ffplay -vf ass=/home/stefano/s/Rocket_04.ass -f lavfi testsrc=s=720x480
The problem depends on the fact that vf_ass.c uses the same DAR of input for rendering the subtitles, which is indeed a rather arbitrary behavior (see line in vf_ass.c: ass_set_aspect_ratio(ass->renderer, dar, sar)).
Possible fixes:
set the DAR to 1.0, or allow the user to specify the DAR through an option.
In the second case I ask: does it make sense to be able to set such value, or should be rather set in the ass file itself (assuming it is possible)?
comment:9 in reply to: ↑ 7 Changed 14 months ago by dbuitenh
Replying to saste:
The problem depends on the fact that vf_ass.c uses the same DAR of input for rendering the subtitles, which is indeed a rather arbitrary behavior (see line in vf_ass.c: ass_set_aspect_ratio(ass->renderer, dar, sar)).
Possible fixes:
set the DAR to 1.0, or allow the user to specify the DAR through an option.
In the second case I ask: does it make sense to be able to set such value, or should be rather set in the ass file itself (assuming it is possible)?
The thing that everyone who uses VSFilter on windows (thus defining the behavior for other players and libs) has been doing since time immortal is to manually set the x/y resize factors in the .ass file. i.e. something with a 32:27 PAR -> x = (27 / 32) = 84.275%, y = 100 %. VSFilter then applies these at a 1.0 DAR, and then the renderer resizes on playback as the very last step.
To sum up: VSFilter always applies at 1.0 DAR.
comment:10 Changed 14 months ago by cehoyos
Patch by Stefano that fixes the problem here:
http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/142213/focus=142325
comment:11 Changed 14 months ago by fate
I managed to patch. It's work, a little too much same . Now the subtilte is little bit compress. You can see on the image. On the top it's the subtitle add with ffmpeg patched and on the bottom it's the subtitle load with vlc (it's the real size). But it's much better than before.
I will try to modify the patch, if I can, for adjust the size of subtitle.
Thank you :)
comment:12 Changed 14 months ago by saste
- Status changed from open to closed
- Resolution set to fixed
Should be fixed in:
commit 247fbf071bb9d30f5341844a3d4ebbd53a986968
Author: Nicolas George <nicolas.george@normalesup.org>
Date: Thu Mar 22 20:59:36 2012 +0100
ass: fix aspect ratio computation.
Please reopen if it doesn't work for you.
comment:13 Changed 14 months ago by fate
Ok I will try this patch. Thanks ;)



