20

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.

1
  • 6
    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.
    – Rajib
    Commented May 4, 2014 at 7:17

5 Answers 5

12

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.

9
  • 2
    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.
    – llogan
    Commented May 6, 2014 at 3:48
  • ffmpeg -f libcdio -ss 0 -i /dev/sr0 dump.flac (works at least on Linux)
    – m132
    Commented Aug 23, 2014 at 5:44
  • @M132 Thanks, sounds good. I added it to the post. Will have to try to compile it again at some point.
    – slhck
    Commented Aug 23, 2014 at 5:47
  • 1
    @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.
    – slhck
    Commented Oct 31, 2017 at 16:08
  • 1
    @Shimmy This building suite works for Windows: github.com/jb-alvarado/media-autobuild_suite — but you have to compile yourself.
    – slhck
    Commented Oct 31, 2017 at 17:04
7

For DVDs, the key part is installing the DVD decryption library (e.g. libdvdcss).

Reading the DVD directly with ffmpeg caused a lot of broken frames for me.

What worked like a charm, was dumping the movie to disk first

mpv dvd:// --dvd-device=/dev/cdrom --stream-dump=filename.vob
dvd://[title][/device] --dvd-device=PATH
          Play a DVD. DVD menus are not supported. If no title is given, the longest ti‐
          tle  is  auto-selected.  Without --dvd-device, it will probably try to open an
          actual optical drive, if available and implemented for the OS.

and convert it afterwards using ffmpeg:

ffmpeg -i filename.vob \
    -c:a libopus -b:a 90k -ar 48000 \  # OPUS, vbr 90 kbps, 48000 Hz
    -c:v libx264 -bf 16 -crf 22  \ # X.264, 16 B-frames (might be too high for action movies), target quality 22
    -trellis 2 -direct-pred auto \ # Some video quality tweaks
    -vf "unsharp=3:3:1.:5:5:0.0" \ # Unsharp masking for low DVD resolutions (720x576)
    -profile:v high444 -pix_fmt yuv444p -movflags +faststart \ # Some output settings
    outfile.mp4

For audio CDs I recommend

  • asunder as a simple and light GUI-program that reliably "just-works" with some nice features, like automatic meta-data lookup, error correction, multi-output format conversion, etc.
  • abcde if you really want to dive into stuff and customize everything. Really nice console program but be prepared to spend some time reading the manual and figuring out the config first.
1

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.

1

Adding to @Suuuehgi's answer:
For me using mpv also worked, but mpv would add the DVD menu after the selected track itself, i.e. it concatenates the selected track and DVD menu. So I tried mplayer instead which also uses libdvdcss, but doesn't add the DVD menu after the selected track:

mplayer dvd://1 -dvd-device /dev/sr0 -dumpstream -dumpfile filename.vob
dump: 5386743808 bytes written (~99.9%)
dump: 5389791232 bytes written to 'filename.vob'.
Core dumped ;)

;)

-3

If a CD contains raw pcm data like 16 bit per channel at 44100 samples per second it should be possible to simply transfer the raw data to HDD then give it a standard wave header. making the data into a file all its own is up to you since finding programming tools to pre-open a null file is unknown to myself.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .