[FFmpeg-devel] [vf_ass.c] 2 lines of code that need your attention

Nicolas George nicolas.george at normalesup.org
Thu Mar 22 21:06:21 CET 2012


Le duodi 2 germinal, an CCXX, Stefano Sabatini a écrit :
> And now I see that both VLC and MPlayer use a more complex logic...

As far as I can see, the logic for the font size in ASS is, in deductive
order (v for virtual, p for pixels):

em_h_v = Fontsize * SclaleY/100
em_h_p = Fontsize * SclaleY/100 * video_h / PlayResY
em_w_p = Fontsize * SclaleX/100 * video_h / PlayResY
em_w_v = Fontsize * SclaleX/100 * video_h / PlayResY * PlayResX / video_w

This works when video_w and video_h are the pixels dimensions of the video
for which the ASS file has been conceived. Note that it completely
disregards any kind of aspect ratio.

So, assuming the ASS file has been designed for the original unscaled video
and we only scaled (no crop, no pad), we need an extra scaling on the X
direction with ratio current_sar / original_sar = original_iar / current_iar
(where iar is the aspect ratio in pixels, with dar = sar * iar).

Now, reading the sources for libass, I find that ass_set_aspect_ratio takes
two arguments: aspect and storage_aspect (and sar does not mean _sample_
aspect!), which seems to be display aspects, and computes the extra X
scaling as storage_aspect / aspect.

Therefore, the correct call would probably be:

ass_set_aspect_ratio(ass, current_iar, original_iar);

although the following should work too:

ass_set_aspect_ratio(ass, original_sar, current_sar);

It seems to be somewhat like what mplayer does.

Attached is a patch that does just that. I believe the dar option has not
been around for enough time to make its removal a problem, especially since
it did not work.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ass-fix-aspect-ratio-computation.patch
Type: text/x-diff
Size: 4001 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120322/12ff7868/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120322/12ff7868/attachment.asc>


More information about the ffmpeg-devel mailing list