Ticket #2067 (open enhancement)

Opened 5 months ago

Last modified 8 weeks ago

Support subtitles in libavfilter so seek is honored for subtitles filters (like hardsubbing)

Reported by: nikov Owned by:
Priority: normal Component: avfilter
Version: unspecified Keywords: subtitles seek
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When I try to burn subtitles in the video, everything is fine, except when I try seeking. The subtitles are added again from the first second, not from 30 minute. I think that when I seek the movie, the subtitles must be seeked too.

How to reproduce:

C:\ffmpeg>ffmpeg -ss 00:30:00 -i f.avi -vf subtitles=f.srt -c:a vorbis -strict -2 -c:v libx264 -preset ultrafast fout.mp4

Change History

comment:1 Changed 5 months ago by cehoyos

  • Priority changed from critical to normal

Please provide complete, uncut console output together with your command line.

comment:2 Changed 5 months ago by ubitux

You need to do that in two steps currently. libavfilter has no visibility on your seek.

ffmpeg -ss 30 -i f.srt f2.srt
ffmpeg ... -vf subtitles=f2.srt ...

Alternatively, we could add a seek parameter to the filter. The best solution is obviously to support proper subtitles filtering, but this is another long standing issue, not easy to deal with, and which require large changes.

comment:3 follow-up: ↓ 8 Changed 5 months ago by Cigaes

I do not think this is absolutely necessary here: if you know how subtitles and seeking work, reading the title of the ticket is enough to guess what and why, the only problem in reproducing it is finding files layound around on one's hard drive.

The hard part is to devise a clean way of fixing the problem.

Other temporary workarounds: -ss as output option (slower before the start of encoding), or -copyts to keep the timestamps (but it will require setpts to reset the timestamps afterwards, or it will show in the output file).

comment:4 follow-up: ↓ 5 Changed 5 months ago by nikov

Also another problem is if you put full path to the subtitles on windows
example
-vf subtitles=C:
ffmpeg
f2.srt

It tries to find \ffmpeg\f2.srt

comment:5 in reply to: ↑ 4 Changed 5 months ago by ubitux

  • Status changed from new to open
  • Summary changed from -vf subtitles=??? libass seeking problem to Support subtitles in libavfilter so seek is honored for subtitles filters (like hardsubbing)

Replying to nikov:

Also another problem is if you put full path to the subtitles on windows
example
-vf subtitles=C:
ffmpeg
f2.srt

It tries to find \ffmpeg\f2.srt

':' is the option separator in filters. You need to escape it somehow. See  https://ffmpeg.org/ffmpeg-utils.html#Quoting-and-escaping for more information.

comment:6 Changed 5 months ago by ubitux

  • Type changed from defect to enhancement

comment:7 Changed 3 months ago by cehoyos

  • Keywords seek added

comment:8 in reply to: ↑ 3 Changed 8 weeks ago by Ricky1252

Replying to Cigaes:

I do not think this is absolutely necessary here: if you know how subtitles and seeking work, reading the title of the ticket is enough to guess what and why, the only problem in reproducing it is finding files layound around on one's hard drive.

The hard part is to devise a clean way of fixing the problem.

Other temporary workarounds: -ss as output option (slower before the start of encoding), or -copyts to keep the timestamps (but it will require setpts to reset the timestamps afterwards, or it will show in the output file).

Can you give an example of how to use setpts? I keep using this option but it doesnt seem to change the output in anyway no matter what I do... example -

ffmpeg -ss 60 -i abc.mkv -copyts -vf setpts=PTS-60T -vf ass=abc1.ass -y abc.mp4

iv tried a few of the examples on the guide here http://ffmpeg.org/ffmpeg-filters.html#setpts its as if the filter is just being neglected all together nothing changes.

comment:9 Changed 8 weeks ago by Cigaes

I believe that using -vf twice will only result in the first instance being ignored. You have to put the filters in the same -vf option, separated by comas.

You can check the effect of the setpts filter by inserting the showinfo filter before and/or after it.

comment:10 Changed 8 weeks ago by Ricky1252

Ah, it works now, but for some reason all the frames are dropped, or nothing happens when I use setpts. Going to keep working on it hopefully can figure it out! If any one can shead some light that would be great! If i figure it out ill post back this is the command line im using now.

ffmpeg -ss 60 -i abc.mkv -copyts -vf ass=/home/abc1.ass,setpts=PTS+60T -y abc.mp4

the results are all Frames dropped. xD

comment:11 Changed 8 weeks ago by Ricky1252

OK! I dont know if its the most efficient way but I got the results Iv desired thank you _

ffmpeg -ss 60 -i abc.mkv -copyts -af asetpts=PTS-60/TB -vf ass=abc1.ass,setpts=PTS-60/TB -y abc.mp4

it seeks with subtitles and makes the start of the video at the actual start of the video! yay! thanks so much everyone <3

Last edited 8 weeks ago by Ricky1252 (previous) (diff)
Note: See TracTickets for help on using tickets.