LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-23-2017, 05:17 PM   #1
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 651
Blog Entries: 134

Rep: Reputation: 188Reputation: 188
linux program to extract subtitles from a series of vob files


Some time ago, got a DVD. Ripped it to VOBs. No problems there. VOBs play fine. In mplayer can even display subtitles. This last indicates that there are subtitles.

To make a long and tiresome story short, mencoder renders the subtitles strangely (poor readability) and ffmpeg swears up and down on a stack of bibles that there are no subtitles.

In Linux tradition of small programs to do one task well, is there a program that just exacts subtitles from video files, and does nothing else?

Thank you.
 
Old 07-23-2017, 06:52 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,148

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
vobsub
ffmpef can be made to search further into the video to find subttitle tracks, can't remember the cli switch for it off hand but look in the ffmpec docs
 
Old 07-24-2017, 01:10 AM   #3
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
ffmpeg is the one software I go to whenever I have to do anything with videos. Check this out: https://trac.ffmpeg.org/wiki/ExtractSubtitles
 
Old 07-27-2017, 05:23 PM   #4
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 651

Original Poster
Blog Entries: 134

Rep: Reputation: 188Reputation: 188
Quote:
Originally Posted by aragorn2101 View Post
ffmpeg is the one software I go to whenever I have to do anything with videos. Check this out: https://trac.ffmpeg.org/wiki/ExtractSubtitles
Funny thing about that page...
  • It shows how to list the subtitle streams in an input file. (that much actually works, now my ffmpeg concedes that there are subtitles)
  • It shows how to convert an already extracted subtitle format to another format.
  • It does not show how to actually extract the subtitle.

It's almost as if ffmpeg cannot actually extract subtitles and the maintainers of ffmpeg want to gloss over that small bothersome detail.

Which is why I asked my original question in this thread; a program that will actually extract subtitles.

Last edited by jr_bob_dobbs; 07-27-2017 at 05:26 PM.
 
Old 07-28-2017, 09:03 PM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I don't believe there is a program completely dedicated to extracting subtitles. You could ask this mailing list: http://ffmpeg.org/mailman/listinfo/ffmpeg-user

If you have some video that won't work with ffmpeg, I'm sure they'd love to know about it!
 
Old 07-29-2017, 08:51 AM   #6
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,133
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Quote:
ffmpeg swears up and down on a stack of bibles that there are no subtitles.
Subtitles start some time into the video. Scan a little farther into the video to find them.
Code:
ffrobe -probesize 1000000000 -analyzeduration 100000000 -i video.vob
You may need to make 3 or 4 tests to find the subs that you want. Look at the output of ffprobe to see what you have.
Streams: Video will be 0:0, audio will be 0:1 0:2 etc, after the audo will be the sub streams.

Find a spot in the video where subs should be and make a 15 second test.
Examples that will overlay subs on the video so that you can find the correct sub stream for you:

Vid, 1st audio, 1st sub streams
Code:
ffmpeg -ss 00:02:10 -t 00:00:15 -probesize 1000000000 -analyzeduration 100000000 -i file.vob -filter_complex "[0:0][0:3]overlay[0]" -map [0] -map 0:1 -c:a copy -c:v libx264 -b:v 1200k test1.mp4
ffmpeg -ss 00:02:10 -t 00:00:15 start at 2:10 run for 15 sec.
-probesize 1000000000 -analyzeduration 100000000 look farther into the video.
-filter_complex "[0:0][0:3]overlay[0] 1st stream(vid) and 4th stream(subs)
-map [0] -map 0:1 map the video with subs on it, and the 1st audio stream.
-c:a copy -c:v libx264 -b:v 1200k Do what you want here.

Vid, 2nd audio 2nd sub streams
Code:
ffmpeg -ss 00:02:10 -t 00:00:15 -probesize 1000000000 -analyzeduration 100000000 -i file.vob -filter_complex "[0:0][0:4]overlay[0]" -map [0] -map 0:2 -c:a copy -c:v libx264 -b:v 1200k test2.mp4
ffmpeg will do what you are wanting and more. You can overlay those subs onto the video or dump them to file, or reencode them.

Quote:
It's almost as if ffmpeg cannot actually extract subtitles and the maintainers of ffmpeg want to gloss over that small bothersome detail
Nonsense. If you can't manipulate a video with ffmpeg then it's probably a corrupted file.

As I said before, if you want more specifics then ask.

Edit: More info

Other syntax for that would be:
Code:
-filter_complex "[0:v][0:s:1]overlay[v]" -map [v] -map 0:a:1
If you want to crop the video while you are at it:
Code:
-filter_complex "[0:0]crop=706:362:8:56[a];[0:4]scale=706:362[b];[a][b]overlay[c]" -map [c] -map 0:2

Last edited by teckk; 07-29-2017 at 09:03 AM.
 
Old 07-29-2017, 03:44 PM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
also you can run it for each vob.

Code:
ls -1 *.vob | while read -r i ; do echo "$i" ; mycommandextract "$i" ; done
 
Old 08-01-2017, 01:37 PM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
.VOB is basically an mpeg2 video stream with navigation data. ffmpeg has options to omit parts -sn (no subtitles) -vn (no video) -an (no audio), so omit the one you want to keep and copy the codec of the one you want.

$ ffmpeg -i video.vob -vn -an -scodec copy -y out.srt

Not sure if that would work, haven't ever played with subtitles much. But the jist of things is there. Now if the subtitles are actually part of the video image, I'm not sure what could be done there.
 
Old 06-17-2020, 11:37 AM   #9
Gew
LQ Newbie
 
Registered: Nov 2009
Location: Kingston, Jamaica.
Posts: 24

Rep: Reputation: 6
Red face

Three years later, I'm on the same task, and having the same problem.

Unfortunately, it seems that ffmpeg is not capable of stream-copying VobSubs from DVD's.
I even had the discussion on the #ffmpeg IRC channel a couple of weeks ago.
So, all attempts to do some "-i film.vob -c:s copy -an -vn output.idx" are doomed.
I have yet to find a working VobSub command line extractor for Linux, sigh.

Well, yeah, there is mencoder, of course.

Code:
mencoder <VOBFILE> -nosound -ovc frameno -o /dev/null -vobsuboutindex 0 -sid 0 -vobsubout <SUBFILE>
The -sid <number> (0 in my example) is the subtitle stream number, so you have to guess.
However, skipping the -sid does (unfortunately) not grab _all_ subtitle streams from a VOB.
Instead, it only seems to grab the first one, and the language ID in the .idx will be "xx".

Gosh, in Windows this operation is so damn easy...

Code:
c:\windows\syswow64\rundll32 vobsub.dll,Configure
..which starts the GUI, where it defaults on grabbing ALL subtitle streams from the IFO you pick, and then puts out a nice pack with IDX and SUB files.

Why isn't there a neat Linux port?
 
Old 06-17-2020, 12:01 PM   #10
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,133
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Quote:
Unfortunately, it seems that ffmpeg is not capable of stream-copying VobSubs from DVD's
Code:
mplayer dvd://1 -dumpstream -dumpfile file.vob
I've done that for 17 years. It will have the subs in the .vob file.
mpv will dump .vob too.

If you want to overlay the subs that you choose onto the video when re encoding, you can. Hard subs.

Overlay dvd_subs onto video (1st vid, 2nd audio, 2nd sub stream) example:
Code:
ffmpeg -probesize 1000000000 -analyzeduration 100000000 -i movie.vob -filter_complex "[0:0][0:4]overlay[0]" -map [0] -map 0:2 -c:a copy -c:v libx264 -crf 18 -preset slow -s 720x540 Output.mp4
You can also choose the color and font size, position of the subs.

You can also dump subs to file. Depends on what they are and what you want.
Code:
ffmpeg -i file.vob -map 0:s:0 subs.srt
ffmpeg -i file.vob -map 0:3 -c copy subs.ass
You can choose which subs that you want
1st 2nd 3rd sub streams to file
Code:
ffmpeg -i file.vob -an -vn -map 0:2 -map 0:3 -map 0:4 -c:s:0 srt -c:s:1 srt -c:s:2 srt -c:s:0 sub0.srt
ffmpeg -i file.vob -an -vn -map 0:2 -c:s:0 srt sub1.srt
ffmpeg -i file.vob -an -vn -map 0:3 -c:s:0 srt sub2.srt
ffmpeg -i file.vob -an -vn -map 0:4 -c:s:0 srt sub3.srt
Take a look at the video first. Subs often times don't start until a while into the video.
Code:
ffmpeg -probesize 1000000000 -analyzeduration 100000000 -i file.vob
All of that works. Been using it for years.
 
Old 06-17-2020, 02:31 PM   #11
Gew
LQ Newbie
 
Registered: Nov 2009
Location: Kingston, Jamaica.
Posts: 24

Rep: Reputation: 6
@teckk: Thanks for your quick response, much appreciated.

However, there are some question marks.

The part about using mplayer to dump the VOB is on spot, in fact that was how I extracted a DVD recently.
However, the tricky part is getting that VobSub stream out of the .VOB file without messing with it.

Your suggestion about re-encoding the dvd_subtitle into SubRip (.SRT) sounded weird and not-doable (without OCR add-on), but I tried.
I got this from ffmpeg, kind of like I had predicted:

Code:
Subtitle encoding currently only possible from text to text or bitmap to bitmap
Also the command that would stream-copy (-c copy) the VobSub into a ASS/SSA gave me an error:

Code:
[ass @ 0000023688b6f480] Exactly one ASS/SSA stream is needed.
So, right now I'm stuck with the VOB. Let's say I don't want to keep it that way, but put the MPEG-2 main video stream and one or maybe two audio streams and all the subtitle streams into a Matroska (.MKV) container. Well, that's a tough one, in Linux. I can use ffmpeg to copy all .VOB streams (including subtitles, when giving "-map 0" option) and mux it into a MKV, but all .idx data about colors will be messed up (in my attempt, anyways) so the subs will be 100% black, all four color codes. I can't extract them using "mkvextract" either, I get this error trying to.

Code:
Error: Track 2 with the CodecID 'S_VOBSUB' is missing the "codec private" element and cannot be extracted.
All I really want to do is get the "dvd_subtitle" stream loose from the VOB, into convenient .idx/.sub files that I can both edit and feed to mkvtoolnix (mkvmerge). I have yet to find a way to do so. Also, a the standalone utility that I'm looking for must be able to fetch "libdvdcss" whilst extracting, since 95% of all DVD titles are CSS-protected and will mess up the VobSub index as well, I know this for a fact since on Windows I must run the discs through Slysoft AnyDVD before doing the VSRip.

Anyways, I'm still out of luck.
Any further suggestions would be much appreciated.

Cheers!
 
Old 06-17-2020, 03:38 PM   #12
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,133
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Code:
ffprobe -probesize 1000000000 -analyzeduration 100000000 Myfile.vob

Input #0, mpeg, from 'Myfile.vob':
  Duration: 01:55:14.91, start: 0.041500, bitrate: 4464 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 32:27 DAR 16:9], Closed Captions, 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:2[0x23]: Subtitle: dvd_subtitle
    Stream #0:3[0x22]: Subtitle: dvd_subtitle
    Stream #0:4[0x21]: Subtitle: dvd_subtitle
    Stream #0:5[0x20]: Subtitle: dvd_subtitle

ffmpeg -codecs | grep subtitle
...
 DES... dvd_subtitle         DVD subtitles (decoders: dvdsub ) (encoders: dvdsub )
This gives me a .mkv with subs. Which can be turned on and off in mplayer with the j key. And I chose the wrong one, I got french.
Code:
ffmpeg -probesize 1000000000 -analyzeduration 100000000 -fflags +genpts -i Myfile.vob -map 0:0 -map 0:1 -map 0:2 -c:v copy -c:a copy -c:s dvdsub Myvid.mkv
 
Old 06-17-2020, 03:54 PM   #13
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,133
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
I then tried to make an mp4 clip with x264. Cropped, sized, with subs.
Code:
ffmpeg -probesize 1000000000 -analyzeduration 100000000 -ss 00:00:40 -t 00:01:00 -fflags +genpts -i Myfile.vob -map 0:0 -map 0:1 -map 0:2 -c:a copy -c:v libx264 -crf 18 -preset slow -c:s dvdsub -maxrate 3000k -bufsize 1M -r 24 -vf crop=714:336:6:70 -s 846x336 Myvid.mp4
Code:
curl -F'file=@Myfile.png' https://0x0.st
https://0x0.st/iWlN.png
https://0x0.st/iWlN.png
 
Old 01-01-2021, 03:02 PM   #14
hftom
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Rep: Reputation: 0
@Gew : are you looking for "vob2sub", from "submux-dvd" package ?
It extracts vob subs to bmp files (using a palette.txt file if you want custom colors) and writes all timings in a script file.

Last edited by hftom; 01-01-2021 at 03:37 PM.
 
Old 01-01-2021, 05:04 PM   #15
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,340

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Have you looked at how makeMKV works and handles the subtitles when ripping DVDs.? It can rip an entire video to an mkv with all or selected subtitles included.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] take VOB, BUP, IFO file(s) combine into mkv with subtitles? lleb Linux - General 3 04-09-2015 05:21 PM
Which program plays VOB video files of DVDs? Novatian Linux - Software 16 10-18-2014 07:03 AM
RAR archives: a linux program to extract files from them. stf92 General 2 11-11-2013 11:51 AM
ffmpeg, trying to demux VOB, subtitles show up in video stream Meson Linux - Software 1 01-29-2010 08:41 AM
Which program or packages can play .VOB files vitalstrike82 Slackware 17 05-27-2009 08:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration