<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.townx.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>townx - Doing all sorts of burning, ripping and encoding of video and DVDs and audio (on Linux) - Comments</title>
 <link>http://www.townx.org/blog/elliot/doing-all-sorts-burning-ripping-and-encoding-video-and-dvds</link>
 <description>Comments for &quot;Doing all sorts of burning, ripping and encoding of video and DVDs and audio (on Linux)&quot;</description>
 <language>en</language>
<item>
 <title>Doing all sorts of burning, ripping and encoding of video and DVDs and audio (on Linux)</title>
 <link>http://www.townx.org/blog/elliot/doing-all-sorts-burning-ripping-and-encoding-video-and-dvds</link>
 <description>&lt;p&gt;Using Linux every day means that I often grapple with how to re-encode proprietary formats so that I can watch them on the computer of my choice. I also do some &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;ripping and creating new &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt;s of home movies etc., for which the Linux command line tools work very nicely (more quickly, more consistently and in a more stable fashion than some of the &lt;span class=&quot;caps&quot;&gt;GUI&lt;/span&gt;s).&lt;/p&gt;

&lt;p&gt;So I&#039;ve gathered a whole load of tips on encoding, ripping, burning, culled from dozens of forums, websites, manpages etc.. This, then, is the current state of my understanding on this topic, and hopefully distills many hours of pain into an easily-digestible format. It&#039;s not very well organised, but hopefully useful. I should mention that this stuff works on Ubuntu, but your mileage may vary. Here goes.&lt;/p&gt;

&lt;h2&gt;A note on tools&lt;/h2&gt;

&lt;p&gt;All of the tools I use are easily installable on Ubuntu, either from official repositories or universe/multiverse. You will also need to install the proprietary codecs if you want to work with them. Here&#039;s what I tend to use:&lt;/p&gt;


&lt;ul&gt;
&lt;li&gt;vlc media player&lt;/li&gt;
&lt;li&gt;mplayer media player&lt;/li&gt;
&lt;li&gt;ffmpeg format transformer&lt;/li&gt;
&lt;li&gt;mencoder&lt;/li&gt;
&lt;li&gt;dvgrab&lt;/li&gt;
&lt;li&gt;dvdauthor&lt;/li&gt;
&lt;li&gt;dvdbackup&lt;/li&gt;
&lt;li&gt;growisofs&lt;/li&gt;
&lt;li&gt;mkisofs&lt;/li&gt;
&lt;li&gt;sox&lt;/li&gt;
&lt;li&gt;lame&lt;/li&gt;
&lt;li&gt;cdrecord&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;Burning an &lt;span class=&quot;caps&quot;&gt;ISO &lt;/span&gt;onto a &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt;/CD&lt;/h2&gt;

&lt;p&gt;To work out where your CD/DVD device is:&lt;/p&gt;



&lt;pre&gt;
$ cdrecord -scanbus
scsibus1:
        1,0,0   100) &#039;HL-DT-ST&#039; &#039;DVD+-RW GSA-T11N&#039; &#039;A103&#039; Removable CD-ROM
        1,1,0   101) *
        1,2,0   102) *
        1,3,0   103) *
        1,4,0   104) *
        1,5,0   105) *
        1,6,0   106) *
        1,7,0   107) *
&lt;/pre&gt;



&lt;p&gt;What you&#039;re looking for is an entry with something other than a * in it; then get the content of the first column, which is the device ID (here, it&#039;s &lt;code&gt;1,0,0&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Then:&lt;/p&gt;



&lt;pre&gt;
cdrecord -v -dao dev=1,0,0 image.iso
&lt;/pre&gt;



&lt;p&gt;setting &lt;code&gt;dev=&lt;/code&gt; to the ID you found above, and where &lt;code&gt;image.iso&lt;/code&gt; is the path to your &lt;span class=&quot;caps&quot;&gt;ISO &lt;/span&gt;image file.&lt;/p&gt;

&lt;h2&gt;Getting the audio out of a YouTube video into an mp3 file&lt;/h2&gt;

&lt;p&gt;First off, download the &lt;span class=&quot;caps&quot;&gt;FLV &lt;/span&gt;version of the video. This is the tricky bit, but here&#039;s how to find it:&lt;/p&gt;


&lt;ol&gt;
&lt;li&gt;Go to the YouTube page for the video&lt;/li&gt;
&lt;li&gt;Copy the content of the &lt;strong&gt;v&lt;/strong&gt; parameter in the querystring (the video ID)&lt;/li&gt;
&lt;li&gt;View the source of the web page&lt;/li&gt;
&lt;li&gt;Search for &lt;strong&gt;&quot;f&quot;:&lt;/strong&gt; in the source; following this will be a long text string (the t parameter), e.g. &quot;OEgsToPDskLJFcLZay_H2RO2hijVCxkP&quot;. This is some kind of secret token you&#039;ll need to do the download.&lt;/li&gt;
&lt;li&gt;Construct the &lt;span class=&quot;caps&quot;&gt;URL &lt;/span&gt;as follows:&lt;/li&gt;
&lt;/ol&gt;





&lt;pre&gt;
&lt;a href=&quot;http://www.youtube.com/get_video?video_id=&amp;lt;video&quot; title=&quot;http://www.youtube.com/get_video?video_id=&amp;lt;video&quot;&gt;http://www.youtube.com/get_video?video_id=&amp;lt;video&lt;/a&gt; ID&amp;gt;&amp;amp;t=&amp;lt;t parameter&amp;gt;
&lt;/pre&gt;



&lt;p&gt;Use your favourite browser or downloader to fetch the file (FLV format).&lt;/p&gt;

&lt;p&gt;My new technique for getting the mp3:&lt;/p&gt;



&lt;pre&gt;
ffmpeg -vn -i youtubevideo.flv youtubevideo.mp3
&lt;/pre&gt;



&lt;p&gt;You&#039;ll need a recent ffmpeg for some YouTube videos, and will also need mp3 support compiled in to do this conversion.&lt;/p&gt;

&lt;p&gt;My old technique for getting the mp3:&lt;/p&gt;

&lt;p&gt;Once you&#039;ve downloaded it, play it through mplayer, resampling the audio at 44.1KHz:&lt;/p&gt;



&lt;pre&gt;
mplayer -vo null -vc null -ao pcm:file=out.wav -af resample=44100:0:0 youtubevideo.flv
&lt;/pre&gt;



&lt;p&gt;Then, use lame to encode the wav file to mp3:&lt;/p&gt;



&lt;pre&gt;
lame -h -V0 out.wav out.mp3
&lt;/pre&gt;



&lt;p&gt;This does a reasonable quality, variable bit-rate mp3.&lt;/p&gt;

&lt;p&gt;There are a couple of services which do this (e.g. &lt;a href=&quot;http://www.youtubehack.net/&quot;&gt;YouTubeHack&lt;/a&gt;) and a &lt;a href=&quot;http://www.arrakis.es/~rggi3/youtube-dl/&quot;&gt;command line script&lt;/a&gt;, but I couldn&#039;t get the services to work, and couldn&#039;t be bothered with the command line script.&lt;/p&gt;

&lt;h2&gt;mp4 or mov to mpg&lt;/h2&gt;

&lt;p&gt;Use mencoder for this. mp4 version:&lt;/p&gt;



&lt;pre&gt;
mencoder in.mp4 -ovc lavc -oac lavc -o out.mpg
&lt;/pre&gt;



&lt;p&gt;mov version is practically the same:&lt;/p&gt;



&lt;pre&gt;
mencoder in.mov -ovc lavc -oac lavc -o out.mpg
&lt;/pre&gt;



&lt;h2&gt;Ripping from a dv camera with dvgrab&lt;/h2&gt;



&lt;pre&gt;
dvgrab --autosplit --timestamp --format jpeg
&lt;/pre&gt;



&lt;p&gt;(The camera should be detected automatically, and I think this waits until it detects some input before the capture starts. I use a firewire cable to connect from the camera to the computer.) The files get named after timestamps coming from the film.&lt;/p&gt;

&lt;h2&gt;Encoding from .avi to .mpg&lt;/h2&gt;

&lt;p&gt;Use:&lt;/p&gt;



&lt;pre&gt;
ffmpeg -i infile.avi outfile.mpg
&lt;/pre&gt;



&lt;p&gt;(though this produces quite low quality output)&lt;/p&gt;

&lt;p&gt;This produces better quality (bitrate = 800):&lt;/p&gt;



&lt;pre&gt;
ffmpeg -i infile.avi -vcodec mpeg2video -acodec mp2 -b 800 outfile.mpeg
&lt;/pre&gt;



&lt;h2&gt;Encoding from .avi to .mpg suitable for &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;burning&lt;/h2&gt;



&lt;pre&gt;
ffmpeg -i finalmovie.avi -y -target pal-dvd -sameq -aspect 16:9 finalmovie.mpg
&lt;/pre&gt;



&lt;p&gt;If you&#039;re in the &lt;span class=&quot;caps&quot;&gt;US, &lt;/span&gt;changed &lt;code&gt;pal-dvd&lt;/code&gt; to &lt;code&gt;ntsc-dvd&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Ripping &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt;s to hard disk&lt;/h2&gt;

&lt;p&gt;(See &lt;a href=&quot;http://www.bunkus.org/dvdripping4linux/single/index.html&quot; title=&quot;http://www.bunkus.org/dvdripping4linux/single/index.html&quot;&gt;http://www.bunkus.org/dvdripping4linux/single/index.html&lt;/a&gt; for lots of good tips)&lt;/p&gt;

&lt;p&gt;May need dvdcss decoder to be installed:&lt;/p&gt;



&lt;pre&gt;
sudo /usr/share/doc/libdvdread3/examples/install-css.sh
&lt;/pre&gt;



&lt;p&gt;Use dvdbackup to rip a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;to hard disk. &lt;br /&gt;
See &lt;a href=&quot;http://dvd-create.sourceforge.net/dvdbackup-readme.html&quot; title=&quot;http://dvd-create.sourceforge.net/dvdbackup-readme.html&quot;&gt;http://dvd-create.sourceforge.net/dvdbackup-readme.html&lt;/a&gt; for full instructions&lt;/p&gt;



&lt;pre&gt;
# Get info. about DVD
dvdbackup -i /dev/cdrom -I

# Rip whole DVD
dvdbackup -M -i/dev/cdrom -o /media/usbdisk/dvdripping

# Rip main feature
dvdbackup -F -i /dev/cdrom -o /media/usbdisk/dvdripping

# Rip title set (in this case, title set 2)
dvdbackup -T 2 -i /dev/cdrom -o /media/usbdisk/dvdripping

# Rip title (here, rip title 1)
dvdbackup -t 1 -i /dev/cdrom -o /media/usbdisk/dvdripping
&lt;/pre&gt;



&lt;h2&gt;Direct &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;copying&lt;/h2&gt;

&lt;p&gt;This effectively copies the &lt;span class=&quot;caps&quot;&gt;DVD&#039;&lt;/span&gt;s iso image to hard disk:&lt;/p&gt;



&lt;pre&gt;
dd if=/dev/cdrom of=file.iso bs=2048
&lt;/pre&gt;



&lt;p&gt;If the disk is encrypted, this might fail. In this case, it might be worth running this first:&lt;/p&gt;



&lt;pre&gt;
dvdbackup -I -i /dev/cdrom
&lt;/pre&gt;



&lt;p&gt;Then try dd again.&lt;/p&gt;

&lt;p&gt;See &lt;a href=&quot;http://gentoo-wiki.com/HOWTO_Backup_a_DVD#dd&quot; title=&quot;http://gentoo-wiki.com/HOWTO_Backup_a_DVD#dd&quot;&gt;http://gentoo-wiki.com/HOWTO_Backup_a_DVD#dd&lt;/a&gt; for more details&lt;/p&gt;

&lt;p&gt;Note that this produces a mountable &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;image. However, it does not remove encryption, so you would still need to rip to individual &lt;span class=&quot;caps&quot;&gt;VOB&lt;/span&gt;s using dvdbackup to get rid of that. However, it is possible to mount the iso and play it as if it were a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;(see later): vlc is good for this.&lt;/p&gt;

&lt;h2&gt;Playing a partially ripped &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;If you&#039;ve ripped some of the content of a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;(e.g. using dvdauthor -i /dev/cdrom -F), you can play the partial rip with:&lt;/p&gt;



&lt;pre&gt;
mplayer dvd:// -dvd-device &amp;lt;ripped_dvd_directory&amp;gt;
&lt;/pre&gt;



&lt;p&gt;(vlc might also be able to do this)&lt;/p&gt;

&lt;h2&gt;Encoding audio out of a &lt;span class=&quot;caps&quot;&gt;VOB &lt;/span&gt;file (note that this drops the video altogether)&lt;/h2&gt;



&lt;pre&gt;
mplayer -vo null -vc null -ao pcm:file=outfile.wav infile.VOB
&lt;/pre&gt;



&lt;p&gt;You could probably use ffmpeg for this, too.&lt;/p&gt;

&lt;h2&gt;Creating a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;using dvdauthor when you don&#039;t want the whole disc&lt;/h2&gt;

&lt;p&gt;If you just have the main feature (a set of .VOB files) and you want to create a playable &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;from them.&lt;/p&gt;

&lt;p&gt;Create a dvd.xml file in the top level directory of the ripped &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;(e.g. in &lt;span class=&quot;caps&quot;&gt;VIDEO&lt;/span&gt;_TS)&lt;/p&gt;



&lt;pre&gt;
&amp;lt;dvdauthor&amp;gt;
  &amp;lt;vmgm /&amp;gt;
    &amp;lt;titleset&amp;gt;
      &amp;lt;titles&amp;gt;
        &amp;lt;pgc&amp;gt;
          &amp;lt;vob file=&amp;quot;VTS_01_1.VOB&amp;quot; /&amp;gt;
          &amp;lt;vob file=&amp;quot;VTS_01_2.VOB&amp;quot; /&amp;gt;
          &amp;lt;vob file=&amp;quot;VTS_01_3.VOB&amp;quot; /&amp;gt;
          &amp;lt;vob file=&amp;quot;VTS_01_4.VOB&amp;quot; /&amp;gt;
          &amp;lt;vob file=&amp;quot;VTS_01_5.VOB&amp;quot; /&amp;gt;
        &amp;lt;/pgc&amp;gt;
      &amp;lt;/titles&amp;gt;
    &amp;lt;/titleset&amp;gt;
&amp;lt;/dvdauthor&amp;gt;
&lt;/pre&gt;



&lt;p&gt;(Adding another &lt;vob&gt; element for each &lt;span class=&quot;caps&quot;&gt;VOB &lt;/span&gt;which you want included in your &quot;movie&quot;. Note that these can equally well be your own mpg files.) You can also add titles etc.: see the man page for dvdauthor for more details. This works fine for me, though.&lt;/p&gt;

&lt;p&gt;Then run it with:&lt;/p&gt;



&lt;pre&gt;
dvdauthor -o &amp;lt;output directory for DVD structure&amp;gt; -x dvd.xml
&lt;/pre&gt;



&lt;h2&gt;Burning complete &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;structure to a new &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;See &lt;a href=&quot;http://www.linux.com/articles/53702&quot; title=&quot;http://www.linux.com/articles/53702&quot;&gt;http://www.linux.com/articles/53702&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(I think you might need to have used dvdbackup -M (complete rip) for this to work, or have a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;structure created using dvdauthor (see above))&lt;/p&gt;



&lt;pre&gt;
growisofs -dvd-compat -Z /dev/cdrom -dvd-video &amp;lt;ripped dvd structure&amp;gt;
&lt;/pre&gt;



&lt;h2&gt;Creating an iso from a ripped &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;structure&lt;/h2&gt;

&lt;p&gt;If you&#039;ve ripped the structure of a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;(e.g. using dvdbackup) or created your own &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;structure (e.g. using dvdauthor), you can turn it into a single iso file with:&lt;/p&gt;



&lt;pre&gt;
mkisofs -dvd-video &amp;lt;ripped dvd directory&amp;gt; | dd of=file.iso obs=32k seek=0
&lt;/pre&gt;



&lt;h2&gt;Mounting an iso filesystem so you can read it&lt;/h2&gt;



&lt;pre&gt;
mkdir mountpoint
sudo mount -o loop file.iso mountpoint
&lt;/pre&gt;



&lt;p&gt;Once mounted, you can play the mounted iso (including its menu system) using vlc. For example, if we mounted it on the directory &quot;mountpoint&quot; we could do:&lt;/p&gt;



&lt;pre&gt;
vlc dvd:///path/to/mountpoint
&lt;/pre&gt;



&lt;h2&gt;Encode &lt;span class=&quot;caps&quot;&gt;VOB &lt;/span&gt;to mpg&lt;/h2&gt;

&lt;p&gt;If you ripped a &lt;span class=&quot;caps&quot;&gt;VOB &lt;/span&gt;off a &lt;span class=&quot;caps&quot;&gt;DVD &lt;/span&gt;but you want a smaller mpg:&lt;/p&gt;



&lt;pre&gt;
ffmpeg -i VTS_01_1.VOB -vcodec mpeg2video -acodec mp2 -b 1000 sleeper1.mpg
&lt;/pre&gt;



&lt;h2&gt;Ripping RealPlayer streams&lt;/h2&gt;

&lt;p&gt;See &lt;a href=&quot;https://help.ubuntu.com/community/HowToRipRealaudioStreamsToMp3&quot; title=&quot;https://help.ubuntu.com/community/HowToRipRealaudioStreamsToMp3&quot;&gt;https://help.ubuntu.com/community/HowToRipRealaudioStreamsToMp3&lt;/a&gt; for full instructions&lt;/p&gt;

&lt;p&gt;Short version:&lt;/p&gt;

&lt;p&gt;vsound --timing --dspout --file=myfilename.wav realplay &lt;a href=&quot;http://url.to.rip&quot; title=&quot;http://url.to.rip&quot;&gt;http://url.to.rip&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Ruby script for converting from m4a (iTunes format?) to mp3&lt;/h2&gt;

&lt;p&gt;This is a shell script for converting files from m4a to mp3. It uses mplayer and lame behind the scenes. sox is supposed to do this, but I can never work out how to install proprietary codecs for it. This doesn&#039;t retain tags, unfortunately. &lt;a href=&quot;http://townx.org/blog/elliot/nice-ruby-audio-format-transformer-tag-transferrer&quot;&gt;Sneetchalizer&lt;/a&gt; will probably also work.&lt;/p&gt;



&lt;pre&gt;
#!/opt/lampp/bin/ruby
# only works if the script is in the directory with the m4a files
prefix = &amp;quot;new_file_prefix&amp;quot;
Dir[&#039;*.m4a&#039;].each do |f|
  new_filename = prefix + File.basename(f).gsub(&#039; &#039;, &#039;_&#039;).slice(3..-5).downcase
  wav = new_filename + &amp;quot;.wav&amp;quot;
  mp3 = new_filename + &amp;quot;.mp3&amp;quot;
  `mplayer -ao pcm:file=&#039;#{wav}&#039; &#039;#{f}&#039;`
  `lame -h -b192 #{wav} #{mp3}`
  `rm #{wav}`
end
&lt;/pre&gt;



&lt;h2&gt;Ruby script for converting from ogg to mp3&lt;/h2&gt;

&lt;p&gt;Uses ogg123. This script loses all the tags, though. &lt;a href=&quot;http://townx.org/blog/elliot/nice-ruby-audio-format-transformer-tag-transferrer&quot;&gt;Sneetchalizer&lt;/a&gt; would do this, too.&lt;/p&gt;



&lt;pre&gt;
#!/opt/lampp/bin/ruby

filename = ARGV[0]

if filename.nil? or !(/\.ogg$/ =~ filename)
  puts &amp;quot;I don&#039;t think that&#039;s an ogg file, mister&amp;quot;
  exit
end

base_filename = filename.chomp(&amp;quot;.ogg&amp;quot;)
mp3_filename = base_filename + &amp;quot;.mp3&amp;quot;

`ogg123 -d au -f - #{filename} | lame - #{mp3_filename}`
&lt;/pre&gt;



&lt;h2&gt;mp3 to ogg&lt;/h2&gt;

&lt;p&gt;Bit basic, this, but you get the idea:&lt;/p&gt;



&lt;pre&gt;
mpg321 -s input.mp3 | oggenc -r -a &amp;quot;artist&amp;quot; -t &amp;quot;title&amp;quot; -b 100 -M 140 -o output.ogg -
&lt;/pre&gt;



&lt;h2&gt;ogg to wav&lt;/h2&gt;

&lt;p&gt;sox is OK for this, as neither codec is proprietary:&lt;/p&gt;



&lt;pre&gt;
sox input.ogg output.wav
&lt;/pre&gt;</description>
 <comments>http://www.townx.org/blog/elliot/doing-all-sorts-burning-ripping-and-encoding-video-and-dvds#comments</comments>
 <category domain="http://www.townx.org/tech">tech</category>
 <category domain="http://www.townx.org/howtos">howtos</category>
 <pubDate>Wed, 16 Jan 2008 18:39:16 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">696 at http://www.townx.org</guid>
</item>
</channel>
</rss>
