Open main menu

Wikibooks β

FFMPEG An Intermediate Guide/MPEG

< FFMPEG An Intermediate Guide

FFMPEG: Encoding, Decoding
Full Name: Moving Picture Experts Group
Web sites: Motion Picture Experts Home Page
Description: MPEG is one of the most standard and widely used formats. Its been produced in a number of different iterations and used throughout the film industry from capture, storage to delivery.

Contents

BackgroundEdit

The Moving Pictures Experts Group, is the fore most group on defining and implementing video standards through out the film industry. Operating since 1988 and shaping the development of the entire industry.

MPEG's can be used for all levels of use but understanding how the different formats work will help you decide which is best suited for you needs. Please read through usages to help you decided which are the best settings for you usage.

The basic premise of the Moving Picture Expert Group, is that encoding is done by a few powerful machines and decoding will be done by many weaker systems. So depending on the setting you use, it can be processor intense to encode, but should be fairly light to decode.

FFMPEG GuideEdit

UsagesEdit

MPEG1Edit

MPEG1 is a low bit rate format, designed to be used on CD running at a rate of less than 1.5Mb/s. Comparative to MPEG2, MPEG1 will generally out perform MPEG2 at lower bit rates, though MPG4 should out perform MPEG1.

There is no audio encoder for MPEG 1 audio, although there is a decoder. For audio simply use MPEG 2 (mp2) audio as this will work with most high end encoders.

For a single pass mpeg1Edit

ffmpeg -i "input_file" -vcodec mpeg1video -acodec mp2 "output_file.mpeg"

For a two pass mpeg1 encodingEdit

ffmpeg -i "input_video" -pass 1 -f mpeg1video -an -passlogfile log_file "output_file.mpeg"

ffmpeg -i "input_video" -pass 2 -f mpeg1video -acodec mp2 -passlogfile log_file "output_file.mpeg"

For an optimized two pass mpeg1 encodingEdit

ffmpeg -i "input_video" -pass 1 -f mpeg1video -b 750000 -s 320x240 -an -passlogfile log_file "output_file.mpeg"

ffmpeg -i "input_video" -pass 2 -f mpeg1video -b 750000 -s 320x240 -acodec mp2 -ab 128000 -passlogfile log_file "output_file.mpeg"

MPEG2Edit

SD Normal QualityEdit

ffmpeg -i "input_video" -c:v mpeg2video -b:v 4M -refs 1 -bf 0 -c:a ac3 -b:a 192k -async 1 "output.mpg"

SD High QualityEdit

ffmpeg -i "input_video" -c:v mpeg2video -b:v 8M -refs 1 -bf 0 -c:a ac3 -b:a 384k -async 1 "output.mpg"

SD StreamEdit

ffmpeg -i "input_video" -c:v mpeg2video -b:v 8M -refs 1 -bf 0 -c:a ac3 -b:a 192k -async 1 "output.ts"

HD StreamEdit

ffmpeg -i "input_video" -c:v mpeg2video -b:v 20M -refs 1 -bf 0 -c:a ac3 -b:a 384k -async 1 "output.ts"

MP3Edit

MP4Edit

  1. ffmpeg -i source.avi -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320×240 destination.mp4
  1. ffmpeg -v 0 -i in.flv -y -acodec libfaac -ar 22050 -ab 64k -r 25 -vb 384000 -f mp4 -vcodec mpeg4 out.mp4
  1. ffmpeg -i source.mp4 -s 176×144 -vcodec h263 -r 25 -b 12200 -ab 12200 -ac 1 -ar 8000 destination.3gp

SD MPEG4 Part 2Edit

ffmpeg -i "input_video" -c:v mpeg4 -q:v 3 -c:a mp3 -ab 128k -async 1 "output.mp4"

ffmpeg -i "input_video" -c:v mpeg4 -b:v 2000k -c:a mp3 -ab 128k -async 1 "output.mp4"

SD MPEG4 XviD/DivXEdit

ffmpeg -i "input_video" -c:v libxvid -q:v 3 -c:a mp3 -ab 128k -async 1 "output.mp4"

ffmpeg -i "input_video" -c:v libxvid -b:v 2000k -c:a mp3 -ab 128k -async 1 "output.mp4"

H264Edit

SD Quality-based H264Edit

ffmpeg -i "input_video" -c:v h264 -crf 18 -preset slow -profile high -strict -1 -async 1 "output.mp4"

SD Contant Bitrate H264Edit

ffmpeg -i "input_video" -c:v h264 -b:v 2000k -preset slow -profile high -strict -1 -async 1 "output.mp4"

H265Edit

Additional examples and details of the different arguments and codecs can be found on the FFMPEG homepage.

Universal DeliveryEdit

Common file types: .mpg, .mp4, .ts, .mkv

CDEdit

VCD and SVCD

DVDEdit

DVD-Video are the most used format for final delivery of footage. This section is only looking at standard DVD-Video as a delivery format.

Some useful information to know. DVD decodes tend to work up to a maximum of about 8Mb/s and a minimum of 1.5Mb/s (assuming MPEG2, MPEG1 can go smaller, though we advise you don't use it). Constant bit rate is faster to encode to but variable bit rate will give to much better size and possibly quality. Please see the section on variable bit rate.

For older DVD players you should not go above 6Mb/s, though the rule of thumb is unless its specifically asked for, 8Mb/s should work 90% of the time and buy you grandma a new DVD play.

Constant Bit rate DVDsEdit

Best quality: 8Mb/s, 55 minutes of video.

  • 1 Hour: 7350Kb/s.
  • 2 Hours: 4550Kb/s

(these are guide lines you may need to adjust to the length of your footage.)

You should avoid going below 4500kb/s as the quality become awful.

  • Highest quality: 8Mb/s
  • Average quality: 5Mb/s-7Mb/s
  • Lowest quality: 5Mb/s
  • Poor quality: 4Mb/s

Final encoded content must fit either a 4.7GB Single-sided DVD or 8.4GB Double-sided DVD.

Variable Bit Rate DVDsEdit

BLU-RAY and HDDVDEdit

25Mb/s - 60Mb/s

BroadcastEdit

15Mb/s

Long Term, High Quality StorageEdit

50 - 880Mb/s

StreamingEdit

It's hard to provide an example table as many sources vary their bitrate and quality based on video resolution and server bandwidth.

Interlaced FootageEdit

To deinterlace video and convert it to progressive, add the -deinterlace option if you know its interlaced. Otherwise use the -vf yadif option for safety.

Also note that converting from interlaced to progressive is destructive on your video content and can cause loss of quality or introduce additional artifacts during conversion.

Useful linksEdit