We are still actively working on the spam issue.

Video Editing

From InstallGentoo Wiki
Jump to: navigation, search

Basic Encoding

Encoding a video from an uncompressed format into a compressed one can be done with the cross-platform AviDemux tool. It is not a fully featured video editor, but designed mainly for the purpose of simple encoding. This means there are less options to get in our way.

A video file generally consists of three things:

  • The video stream (x264, XViD)
  • The audio stream (aac, mp3)
  • The container (mp4, avi)

For this example we'll convert a .mpg file, with an mpeg video stream and an mp2 audio stream (quite common from cameras, phones, webcams and tv broadcasts) and convert it to an aac/x264 .mp4 file (generally considered the best quality for the file size produced, and standard for The Scene).

There are a heap of steps just to encode a simple video, but after you've done it a couple of times you'll blast through all these steps in 30 seconds flat.

  1. Open AviDemux. You'll be presented with a blank project. On the left side of the window will be the options for Video, Audio and Format (container). We'll be going through each of these in turn, but first we need to import our uncompressed file.
  2. File > Open and select your .mpg file. You might be prompted to index the file. Say yes.
  3. Change the Video type from Copy to MPEG-4 AVC. This is longspeak for x264. We'll configure it's options in a moment.
  4. Change the Audio type from Copy to AAC (Faac).
    • Click Configure under Audio to check the bitrate. It defaults to 128, which is the mp3 equivalent of 160-192. Change it if you need to. If unsure, leave it at 128.
  5. Change the Format to MP4.
  6. Now we need to understand some properties of our raw video stream:
    • Does it have black bars on the edges which need to be cropped out?
    • Is it interlaced? Interlaced video will breakup into a dozen or so horizontal bars most visible in high movement/action scenes. Use the position bar and play/pause button at the bottom of the window to check for this.
  7. Under video, click Filters.
    • If your video is interlaced, look in the interlacing section for "yadif" and double click to add it (default options are fine). If interlacing is required, it must always be the first filter you add.
    • If you video is squashed horizontally, look in the Transform section for "MPlayer resize". Double click to add it, Setting the correct width and correct Destination aspect ratio. (Tip: for 1:1 to 16:9 conversion, divide the height by 9 then multiply by 16 for the correct width. eg. 720x576: 576 / 9 = 64. 64 * 16 = 1024. 1024x576).
    • If your video needs to be cropped, look in the Transform section for "Crop". Double click and set the crop out areas. Try using the location bar to find a nice bright scene to contrast against the black bars. Your crop numbers must be multiples of 8 and you'll get a warning if you forget.
    • There are many more filters available, but you probably don't need them. There's one to blur out watermarks, but a blurred watermark often looks worse than the tv channel's logo does.
    • Close the Video Filters window.
  8. Using the location bar at the bottom of the screen, find the start of where you wish the video to begin. Fine tune this position by using the Previous Keyframe and Next Keyframe buttons (which look like "fast forward" and "rewind"). With the starting keyframe found, hit the Selection Start button (looks like an "A" on a film roll).
  9. Again using the location bar and keyframe buttons, find the last keyframe of your video. Mark this with the Selection End button (the "B"). We have now selected what part of our raw video we wish to encode.
  10. Click the Calculator button on the toolbar. Here we'll set the final output size of the video. The Audio Bitrate will already be filled in. Select the Medium, or set it to Custom and fill out a Custom Size for the video. This will calculate the Video Bitrate.
    • For general x264 video, 500 is a poor bitrate, 1000 is good, 1500 is excessive. This will change depending on the size of your video (1920x1080 needs more bits to look nice compared to 848x480) and how much action is in the footage (video of 100 people dancing has more movement than one cat sleeping).
  11. Take note of the Video Bitrate and close the Calculator.
  12. Under Video, click Configure. This is to configure the video codec settings.
    • Bitrate tab
      • Set Encoding Mode to Two Pass - Average Bitrate
      • Set the average bitrate to the Video Bitrate you noted down from the Calculator.
    • Motion and Misc tab
      • Set the Partition Decision to 9 or 10. This has a big effect on your video quality.
      • Set Method to Hadamard Exhaustive Search. This will make action scenes look much better.
    • Click OK.
  13. Finally, you can click Save on the toolbar, enter an output video filename, and wait as your video encodes.
  14. Check the outputted file's video quality, interlacing, cropping, aspect ratio, audio sync and filesize to make sure everything is ok.

If you have parts of the raw video you wish to cut out, use the location bar, keyframe selectors and "A and B" Selection buttons to select the unwanted part and select Edit > Delete.

Full details of all the options for video and audio codecs, filters and more can be found at the AviDemux Wiki.

See Also

  • Handbrake, a simple video transcoder for Windows/OSX/Linux.