[FFmpeg-user] Burned Subtitles using .ass files for small time intervals(<1 sec) Issue

Aameer Rafiq Wani aameer.rafiq at gmail.com
Tue Apr 12 09:46:24 CEST 2016


Objective:
burning subtitles onto a video for small time intervals intervals(less than
1 second )


Some background information of the issues I faced:
when I was tryign to burn the subtitles for larger videos the subtitle
sometimes wouldnt show up for time intervals less than 1 sec(e.g 0.5
seconds interval, 0.075 secs, 0.75 sec, 0.6 secs etc). Very rarely could I
replicate it on smaller videos.

probable cause:
* A given subtitle start time and duration may cause partial overlap
with frames (remember that frame timestamps are going to be at the
granularity of the framerate). E.g.

  framerate = 30fps (timestamps are: frame 1 = 0.0s, frame 2 = 0.333s,
frame 3 = 0.666s, ...)
  subtitle time = 1.5s to 2.1s
  overlapping frame timestamps = 1.333s (partial), 1.666s (full), 2.0s
(partial)

* You can see that depending on the subtitle duration (specifically,
if it is < 2 video frames' duration), it's possible to have no frames
with full overlap

* Basically, how many frames you apply the subtitle to becomes
dependent on ffmpeg's logic to decide what to do with partially
overlapping frames.So I would like to know from you guys where can I get
that information?.
Atleast link to the code which I can study.

my working solution for now:

I had mailed ffmpeg commutnity about this issue multiple times but
unfortunately I havent got any response yet.
link to previous qs for details on code etc:
https://www.mail-archive.com/ffmpeg-user@ffmpeg.org/msg08798.html

In addition to the issue of subtitle not showing up for small time
intervals I also observed another issue which I want to report, I am not
sure if this is a bug in ffmpeg or not but sometimes when I used the input
time in between a millisecond and if it showed up for secs e.g If I would
keep time interval as (00.75) but the subtitle will show up for 7 secs i.e
10X times more than I wanted it to.

So I did lots and lots of trail and error testing which led me to believe
that something was going wrong only when I was changing the milliseconds
times which were starting in between some millisecond. So I did some tests
in which I forced the seconds and millisecond times again with the same
small time interval(00.075) but this time I am avoiding any start times in
between a millisecond and it started working for all the videos.

I am sure either I am missing some information which could explain this
behaviour or there is some bug which needs to be looked into here.

The changed .ass file which made it work looks like this (for older version
please refer to the old qs link):

[Script Info]
; Script generated by FFmpeg/Lavc57.24.103
ScriptType: v4.00+
PlayResX: 384
PlayResY: 288

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour,
OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX,
ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL,
MarginR, MarginV, Encoding
Style:
Default,Arial,16,&H99999999,&H99999999,&H0,&H0,0,0,0,0,100,100,0,0,1,0,0,2,10,10,10,0
Style:
Hidden,Arial,16,&H99999999,&H99999999,&H0,&H0,0,0,0,0,100,100,0,0,1,0,0,6,10,10,10,0

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect,
Text
Dialogue: 0,0:00:00.00,1:59:31.783,Default,,0,0,0,,dialog1
Dialogue: 0,0:39:00.000,0:39:00.075,Hidden,,0,0,10,,dialog2

Note the timings for short time interval subtitle i.e dailog2 which is:
dialog2 start : 0:39:00.000, dialog2 end : 0:39:00.075
short time interval for subtitle i.e dialog2_time_interval = (dialog2 start
time- dialog2 end time) = 00.075

It stated working when I kept the seconds part fixed but I am able to get
the desiered output if I change the hours and mins part.

question:
Can anyone explain this behaviour , I would like to get to the root of this
, any links to the code or debug the issue would be highly appreciated. It
has been almost a month since I had posted question related to this on
ffmpeg users list so I wanted to add some more information before I ask the
question again. Hope this time I would hear back form you guys.

for code please refer to http://aameer.github.io/cloud-computing-101/
encoding_script_watermarked.sh line no line 116 is the place where I am
mentioning about the burned_subtitle (referred to as watermark in the post)
note if we just change the secs portion of timings there e.g

say $BURNED_END_TIME = 1:59:31.783

0,0:00:00.00,1:59:31.783
changed to something like
0,0:39:10.390,0,0:39:00.465

it won't work but if we change it to something like this:
0,0:39:00.000,0,0:39:00.075
it starts to work

Sorry for the long post, but hope this explains the issue and possible bug.

Thanks and Regards,
AAMEER RAFIQ WANI
email: aameer.rafiq at gmail.com
websites: aameer.github.io <aameer at github.io>
LinkedIn: http://in.linkedin.com/in/aameerwani


More information about the ffmpeg-user mailing list