Split a raw video file into chapters for a DVD

I intend to transfer family films from VHS to DVD, and VHS tapes that I bought, too. I previously recorded a big video file from the VHS. For a more general view of the process, instead of a family film, I will consider a bought VHS, with a legal warning, an advertisement, and so on. My task now is to split the big video file into parts that will become introductions, menus, and chapters.

My tools for this task are Avidemux and FFmpeg. I open the video in Avidemux and move the cursor I-frame by I-frame, using the up and down arrow-keys. An I-frame is a full picture, whereas other frames are “delta-pictures”. Thus, unless you want to spend some time re-encoding part of the video, you cannot start nor end a video sequence anywhere but an I-frame.

Avidemux: DVD chapters settingsOn the left-hand side of the window, I set the Video format to “Copy” (since my big file is already in the right format), and the Audio format to “MP2 (lav)” (too bad vlc chose MP3 instead of MP2…). As for the container Format, I choose “MPEG-PS (A+V)” and configure it to the “DVD” muxing preset.

Now, for each sequence, I press the [A[ button at the start of the sequence, and ]B] at the end of the sequence. Then in the “File” menu, I choose “Record → Record a video…” (Ctrl+S) and choose a file name ; that’s all… when I’m lucky.

But Avidemux isn’t very good at keeping the audio and video in sync, or maybe it just is better with AVI than it is with MPEG… Anyway, Avidemux remains usefull for selecting [A-B] sequences, and then I use FFmpeg to do the actual video sequences.

Let’s assume I record the legal warning as the first sequence, and to this end I set A to I-frame #12 at 00:00:00.480, and B to I-frame #300 at 00:00:12.000. Then the commands to run are these (keep in mind I have PAL/SECAM videos, hence 25 images per second):

[me@localhost ~]$ bc -lq <<<"(300-12)/25"
[me@localhost ~]$ ffmpeg -ss 00:00:00.480 -i bigfile.mpegps -t 11.52 -target pal-dvd -vcodec copy -acodec mp2 -b:a 128k sequence_01.mpegps

Don’t forget: if you intend to have a video sequence right after the previous one, as two consecutive chapters of the same film for example, you must set the A value of the second sequence to the exact same value as B from the first sequence.

Now, sometimes, such as the example above (a legal warning), the sound may be changing but the picture may be still. VHS quality being what it is, chances are that the picture really is not static at all. In this case, you can gain some bytes by recording a single frame of this video, and creating a video out of it. Here is the process:

  1. In Avidemux, choose the frame with the best quality, and record it: “File: Record → Record as a JPEG image…” (Ctrl+E) under the name image.jpeg (for example). You may enhance this picture with a tool like The Gimp if you want.
  2. A and B being correctly set in Avidemux at frames #12 and #300, record the audio: “Audio: Record…” (Ctrl+Alt+S) under the name sound.mp2.
  3. It’s time to use FFmpeg:
    ffmpeg -i sound.mp2 -loop 1 -i image.jpeg -t 11.52 -target pal-dvd -vcodec mpeg2video -acodec mp2 -b:a 128k sequence_01.mpegps
  4. Sometimes, you don’t even want sound because it is only white noise; then discard it with this command instead:
    ffmpeg -loop 1 -i image.jpeg -t 11.52 -target pal-dvd -vcodec mpeg2video -an sequence_01.mpegps

You should get a much better quality this way. Note that this is a nice trick for creating a menu too. Indeed, with a DVD, the menu must be a (usually looping) video even if it is static.

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

La discussion continue ailleurs

URL de rétrolien : http://yalis.fr/cms/index.php/trackback/14

Fil des commentaires de ce billet