User Tools

Site Tools


doc:appunti:linux:video:vobcopy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:linux:video:vobcopy [2021/02/19 09:54] – [Converting a DVD with subtitles to MKV using ffmpeg] niccolodoc:appunti:linux:video:vobcopy [2021/02/19 17:13] (current) – [Converting a DVD with subtitles to MKV using ffmpeg] niccolo
Line 78: Line 78:
 I got a rather complicate DVD to rip from, basically the problems are: I got a rather complicate DVD to rip from, basically the problems are:
  
-  * Subtitles are in dvdsub format (which is normal for DVD). +  * Subtitles are in **dvdsub** format (which is normal for DVD), which need **palette** info to be displayed correctly
-  * Some subtitles streams do not start at the beginning+  * Different subtitles streams **start at different times**, some do start **after several minutes**. The automatic detection performed by ''ffmpeg'' does not detect some of them and gets the sorting wrong
-  * Languages of subtitles are not automatically detected.  * Need to apply the original paletto to subtitles, otherwise they are rendered with wrong colors.+  * **Languages of subtitles** are not automatically detected. 
 + 
 +=== Inspect the disk ===
  
 Using lsdvd directly on the DVD disk, you can see the **video** tracks, **audio** streams and **subtitles** availables: Using lsdvd directly on the DVD disk, you can see the **video** tracks, **audio** streams and **subtitles** availables:
Line 95: Line 97:
 Title: 04, Length: 00:00:09.800 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00 Title: 04, Length: 00:00:09.800 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
 </code> </code>
 +
 +=== Rip the track ===
  
 First of all I **ripped the first track** (the only one I'm really interested in) from the DVD into a directory: First of all I **ripped the first track** (the only one I'm really interested in) from the DVD into a directory:
Line 103: Line 107:
  
 Using the **mediainfo** tool you can inspect the resulting vob file to verify that **video**, **audio** and **text** (subtitles) streams are the ones we expect. Using the **mediainfo** tool you can inspect the resulting vob file to verify that **video**, **audio** and **text** (subtitles) streams are the ones we expect.
 +
 +=== Get subtitles palette info ===
  
 Then I extracted the first (#0) **dvdsub stream** (there are 22!) from the DVD: Then I extracted the first (#0) **dvdsub stream** (there are 22!) from the DVD:
Line 120: Line 126:
          d717cc, d6a80b, 8b02d6, 1dca41, 0d007f, 95679f, 8caa67, 783d3f          d717cc, d6a80b, 8b02d6, 1dca41, 0d007f, 95679f, 8caa67, 783d3f
 </file> </file>
 +
 +As an alternative you can get the the **.IFO** of the track (for the first track it is **VIDEO_TS/VTS_01_0.IFO**), that file contains the palette info and can be used instead of the palette numbers.
 +
 +Also **lsdvd** should be able to print the palette, using the option **-P**. But in my tests it produced a palette with different color values, which displayed incorrectly in the final result.
 +
 +=== Transcode with ffmpeg ===
  
 Finally I launched the **ffmpeg** incantation: Finally I launched the **ffmpeg** incantation:
  
 <code bash> <code bash>
-ffmpeg -probesize 200M -analyzeduration 200M +ffmpeg -probesize 500M -analyzeduration 500M 
-    -palette "$PALETTE" +    -palette 'd7410d,101010,0e00d7,d5ccc9,d4b1cb,aac5d0,abd3af,d5ff0c,d717cc,d6a80b,8b02d6,1dca41,0d007f,95679f,8caa67,783d3f' 
-    -i "$SRC_FILE" \+    -i 'FREEDOMDOWNTIME1.vob' \
     -map '0:v:0' -map '0:a:0' -map '0:a:1' \     -map '0:v:0' -map '0:a:0' -map '0:a:1' \
-    -metadata:s:a:0 title="English-metadata:s:a:0 language=eng \ +    -map '0:s:20'
-    -metadata:s:a:1 title="Comment" -metadata:s:a:1 language=eng \ +    -map '0:s:0'  -map '0:s:1'  -map  '0:s:2' -map  '0:s:3'
-    ...+    -map '0:s:4'  -map '0:s:5'  -map  '0:s:6' -map  '0:s:7'
 +    -map '0:s:8'  -map '0:s:9'  -map '0:s:10' -map '0:s:11'
 +    -map '0:s:12' -map '0:s:13' -map '0:s:14' -map '0:s:15'
 +    -map '0:s:16' -map '0:s:17' -map '0:s:18' -map '0:s:19'
 +    -map '0:s:21' -map '0:s:22' -map '0:s:23'
 +    -metadata:s:a:0 title='English-metadata:s:a:0 language=eng \ 
 +    -metadata:s:a:1 title='English Commented' -metadata:s:a:1 language=eng \ 
 +    -metadata title='Freedom Downtime' -metadata:s:v:0 title='Freedom Downtime'
 +    -metadata:s:s: language=eng -metadata:s:s: title='English'
 +    -metadata:s:s: language=eng -metadata:s:s: title='English FCC-Approved'
 +    -metadata:s:s: language=dan -metadata:s:s: title='Dansk'
 +    -metadata:s:s: language=deu -metadata:s:s: title='Deutsch'
 +    -metadata:s:s: language=spa -metadata:s:s: title='Espanol'
 +    -metadata:s:s: language=est -metadata:s:s: title='Estonian'
 +    -metadata:s:s: language=per -metadata:s:s: title='Persian'
 +    -metadata:s:s: language=fin -metadata:s:s: title='Suomi'
 +    -metadata:s:s: language=fra -metadata:s:s: title='Francais'
 +    -metadata:s:s: language=heb -metadata:s:s: title='Hebrew'
 +    -metadata:s:s:10 language=hrv -metadata:s:s:10 title='Hrvatski'
 +    -metadata:s:s:11 language=ita -metadata:s:s:11 title='Italiano'
 +    -metadata:s:s:12 language=jpn -metadata:s:s:12 title='Japanese'
 +    -metadata:s:s:13 language=nld -metadata:s:s:13 title='Nederlands'
 +    -metadata:s:s:14 language=nor -metadata:s:s:14 title='Norsk'
 +    -metadata:s:s:15 language=pol -metadata:s:s:15 title='Polish'
 +    -metadata:s:s:16 language=por -metadata:s:s:16 title='Portugues'
 +    -metadata:s:s:17 language=rus -metadata:s:s:17 title='Russian'
 +    -metadata:s:s:18 language=swe -metadata:s:s:18 title='Svenska'
 +    -metadata:s:s:19 language=tur -metadata:s:s:19 title='Turkish'
 +    -metadata:s:s:20 language=zho -metadata:s:s:20 title='Chinese'
 +    -metadata:s:s:21 language=xxx -metadata:s:s:21 title='Babel nonsense'
 +    -metadata:s:s:22 language=xxx -metadata:s:s:22 title='Game'
 +    -metadata:s:s:23 language=xxx -metadata:s:s:23 title='Words'
 +    -codec:s 'dvdsub'
 +    -vf yadif \ 
 +    -codec:v 'libx264' -pix_fmt 'yuvj420p' -preset 'veryslow' -tune 'film' -profile:v 'high' -level:v 5 \ 
 +    -b:v '2048k'
 +    -ac 2 -codec:a 'libvorbis' -b:a '192k'
 +    'FREEDOMDOWNTIME1.mkv'
 </code> </code>
 +
 +Without the **%%-probesize%%** and **%%-analyzeduration%%** options (both are required), ''ffmpeg'' does not see the subtitles streams that starts some time after the begin of the video. If you explicitly map the unseen stream it will produce an error like this:
 +
 +<code>
 +Stream map '0:s:20' matches no streams.
 +</code>
 +
 +If you don't explicitly map the streams, you will get only a warning message during the transcode: 
 +
 +<code>
 +New subtitle stream 0:27 at pos:8284174 and DTS:20.0200s
 +</code>
 +
 +I mapped (i.e. selected to be inserted into the output) the **video track**, then **two adio tracks** (there were four), and finally **24 text subtitles tracks** (they are actually bitmaps in dvdsub format). The order of the **%%-map%%** options is used to re-arrange the position of the subtitles, overriding the autodetect performed by ''ffmpeg''. All the **%%-metadata%%** are used to properly tag the subtitles once they are sorted as I want.
 +
 +It is mandatory to use the **%%-codec:s 'dvdsub'%%** for subtitles, if you use the **copy** option (which does not re-encode the stream) the **palette** is not applied and you will get subtitles with wrong colors.
 +
 +Yes, the source video has annoying **interlacing artifacts**, so I used the **yadif** video filter to apply a deinterlace effect.
 +
doc/appunti/linux/video/vobcopy.1613724871.txt.gz · Last modified: 2021/02/19 09:54 by niccolo