Opened 12 years ago
Last modified 10 years ago
#2067 open enhancement
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: | sub 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 (15)
comment:1 by , 12 years ago
Priority: | critical → normal |
---|
comment:2 by , 12 years ago
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.
follow-up: 8 comment:3 by , 12 years ago
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).
follow-up: 5 comment:4 by , 12 years ago
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 by , 12 years ago
Status: | new → open |
---|---|
Summary: | -vf subtitles=??? libass seeking problem → 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 by , 12 years ago
Type: | defect → enhancement |
---|
comment:7 by , 12 years ago
Keywords: | seek added |
---|
comment:8 by , 12 years ago
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 requiresetpts
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 by , 12 years ago
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 by , 12 years ago
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 by , 12 years ago
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 setpts=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
comment:12 by , 11 years ago
If you are using the Windows full path inside double quotes it is not easy to escape correctly. I found this to be working: -filter_complex "subtitles='C\:/ffmpeg/f2.srt'". Double backslashes in stead of the single forward slashes may work as well, but I tend to avoid backslashes as much as possible. So the solution is escaping the ':' and surrounding the full path by single quotes.
comment:13 by , 11 years ago
Keywords: | sub added; subtitles removed |
---|
comment:14 by , 10 years ago
Implementing option 'ss' in subtitles filter would be decent workaround too. Here is citation from another issue about this (duplicate #3852)
So, maybe add option 'ss' to filter http://ffmpeg.org/ffmpeg-filters.html#subtitles-1 with same function as -ss in ffmpeg itself? This would be simple and convenient workaround.
The ss option would specify from what point ffmpeg should start subtitles, explicitly.
There is already such option in ffmpeg itself, so in 'subtitles' it wouldn't be a foreign.
And with this option it would be finally possible to burn subtitles in fast seek mode.
comment:15 by , 10 years ago
Ricky1252's workaround gave me some quality issues for some reason.
This is another workaround for this issue.
ffmpeg -ss 102.042 -t 24.250 -i sintel-1024-surround.mp4 -c:v libvpx -vf scale=640:-1,setpts=PTS+102.042/TB,subtitles=sintel_en.srt,setpts=PTS-STARTPTS out.webm
Works nice for me, even in 2pass mode.
Please provide complete, uncut console output together with your command line.