Rip CD/DVD with ffmpeg

21,920

Solution 1

From DVDs, you can access the VOB files directly though, but you have to concatenate them:

cd /path/to/dvd/
cat VOB1.VOB VOB2.VOB VOB3.VOB | ffmpeg -i - -c:a libmp3lame -vn /path/to/output.mp3

For CD, if your ffmpeg was compiled with libcdio support, @M132 gives us a solution:

ffmpeg -f libcdio -ss 0 -i /dev/sr0 dump.flac

To get libcdio with ffmpeg under Windows, check out the Media Autobuild Suite. It can then read from a .cue file.

Solution 2

If your ffmpeg doesn't have libcdio or you want to automatically store each track separately and you have cdparanoia installed, you can use that as the input and pipe each track to ffmpeg:

$ cdparanoia -Q 2>&1 | 
grep "^ *[1-9]" | 
sed -e 's/^ *\|\..*//g' | 
while read t; do 
  cdparanoia $t - | ffmpeg -i pipe: -b:a 128k -ar 44100 -ac 2 -y "rip $t.mp3"; 
done
  • cdparanoia -Q 2>&1 prints a track list and redirects it to standard out
  • grep "^ *[1-9]" finds the lines with a number at the start representing tracks
  • sed -e 's/^ *\|\..*//g' removes all substrings that are not the track number
  • while read t; do reads each track number into variable t
  • cdparanoia $t - runs cdparanoia again, this time to read the given track and writes output to standard out
  • ffmpeg -i pipe: -b:a 128k -ar 44100 -ac 2 -y "rip $t.mp3"; reads the input from standard in and does the conversion, here into mp3 (of course you can use any audio encoding you like)
  • done end of the while-loop

So you end up with a bunch of files named "rip <track number>.mp3" in your current directory.

Share:
21,920

Related videos on Youtube

alexandertr
Author by

alexandertr

Updated on September 18, 2022

Comments

  • alexandertr
    alexandertr almost 2 years

    Is this possible with ffmpeg? Do you have any links that explain how to do this?

    I have searched with Google but had not many results.

    I just want to be able to convert a CD or DVD to MP3 audio files.

    • Rajib
      Rajib about 10 years
      You want to convert audio CD to mp3 and DVD to mp4? Could you explain? And if this about 2 things- DVD and CD- maybe 2 separate questions are better.
  • Elisa Cha Cha
    Elisa Cha Cha about 10 years
    There is this in configure: --enable-libcdio enable audio CD grabbing with libcdio, but I know nothing of it and haven't investigated. Might be worth a look.
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 6 years
    When I call ffmpeg -f libcdio -ss 0 -i /dev/sr0 dump.flac on Windows, I get the following error: Unknown input format: 'libcdio'.
  • slhck
    slhck over 6 years
    @Shimmy As written above, this only works under Linux (/dev/sr0 is Linux-specific) and requires libcdio to be installed on your system as well as ffmpeg compiled with --enable-libcdio.
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 6 years
    Thank you. Is there a trustable compiled ffmpeg download for Windows with all flags and all codecs enabled?
  • slhck
    slhck over 6 years
    @Shimmy This building suite works for Windows: github.com/jb-alvarado/media-autobuild_suite — but you have to compile yourself.
  • rogerdpack
    rogerdpack about 3 years
    You can rip the video that backs the title menu as well /media/username/diskname/VIDEO_TS/VIDEO_TS.VOB
  • SteakOverflow
    SteakOverflow almost 3 years
    ffmpeg never stops seducing me