Authoring a DVD into an image file, from command line
I would like to convert a whatever-type video file into an ISO image I could then burn to a DVD (on another computer) - so that the final disc is playable on a regular DVD player.
I already have ffmpeg
installed with medibuntu, and mpeg output support does seem to work.
Is there a command line tool, or a simple script that I could use to do this?
You need specifically mpeg2 output (mpeg1 will do, if you don't mind the loss of resolution, but mpeg4 is outside the spec). You probably want PAL 720x576 25fps 16:9, with MPEG-1 or AC3 audio; or for NTSC 720x480 and 23.97fps (or whatevs). However, you can use the "dvd" target preset to make things easy, simply by running ffmpeg -i input.avi -target dvd video.mpg
To turn the mpeg file to an DVD compatible folder structure, you need a tool like dvdauthor. There are probably some frontends to it, but the first example from the book, chapter 1.2, is probably sufficient for you. Put that example into file dvdauthor.xml
and your video to video.mpg
and execute dvdauthor -o DVD -x dvdauthor.xml
.
This will result in a directory structure under folder DVD, which you can turn in to an iso file with genisoimage -dvd-video -o my.iso -v DVD
. You can then copy my.iso to some other system and burn on a disc with wodim
or some other tool.
The resulting disc should be playable in standalone players, but due to DVD limitations you may run into problems with arbitrary mpeg streams. Some of the problems may be fixed with dvdauthor
and others with mplex
from package mjpegtools
. If you want subtitles, you'll need to learn how to use spumux
.
@taneli's answer covers most of the process but there are a few missing details. Here is my complete process for converting an MP4 file and writing it to a DVD.
I usually only work with MP4 files but I think this should work with most video formats as inputs (as long as it's supported by ffmpeg). I have tested this on NTSC DVD players.
(Tested in Lubuntu 16.04 LTS, Ubuntu Mate 18.04, and Ubuntu Mate 20.04, AMD64)
1. Install these packages (using sudo apt-get install
):
- dvdauthor
- ffmpeg
- wodim
- mkisofs
2. Convert your video file to the correct format.
(tested using ffmpeg version 2.8.15-0 and 4.2.2-1ubuntu1)
This depends on the region of the world where you bought the DVD player.
-
NTSC Users:
ffmpeg -i yourvideo.mp4 -target ntsc-dvd yourvideo.mpg
-
PAL Users:
ffmpeg -i yourvideo.mp4 -target pal-dvd yourvideo.mpg
- SECAM Users: May not be supported, see -target on ffmpeg's documentation
3. Use dvdauthor to create the dvd filesystem
(Tested using dvdauthor 0.7.0 and 0.7.2)
First time setup:
(source)
Create a file called video_format
in ~/.config/
.
The file just needs to contain a single line:
- NTSC Users:
NTSC
- PAL Users:
PAL
- SECAM Users:
SECAM
? I wasn't able to confirm this.
Creating the DVD's Filesystem:
(source)
dvdauthor --title -o yourvideo -f yourvideo.mpg
dvdauthor -o yourvideo -T
These commands will write the DVD's filesystem to a folder named "yourvideo".
4. Creating an iso
(Tested using mkisofs 1.11.11)
This command will take the contents of the yourvideo folder and convert it into an iso.
mkisofs -dvd-video -o yourvideo.iso yourvideo/
5. Burn the iso to a blank DVD
(Tested using Wodim 1.1.11)
(source)
You will likely need to change /dev/sr0/
to match the device name of your DVD burner.
sudo wodim -tao speed=2 dev=/dev/sr0 -v -data yourvideo.iso