FFMPEG An Intermediate Guide/MPEG
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.
Background
[edit | edit source]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 Guide
[edit | edit source]Usages
[edit | edit source]MPEG1
[edit | edit source]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 MPEG4 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 mpeg1
ffmpeg -i "input_file" -vcodec mpeg1video -acodec mp2 "output_file.mpeg"
For a two pass mpeg1 encoding
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 encoding
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"
MPEG2
[edit | edit source]SD Normal Quality
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 Quality
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 Stream
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 Stream
ffmpeg -i "input_video" -c:v mpeg2video -b:v 20M -refs 1 -bf 0 -c:a ac3 -b:a 384k -async 1 "output.ts"
MP3
[edit | edit source]MP4
[edit | edit source]- ffmpeg -i source.avi -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320×240 destination.mp4
- ffmpeg -v 0 -i in.flv -y -acodec libfaac -ar 22050 -ab 64k -r 25 -vb 384000 -f mp4 -vcodec mpeg4 out.mp4
- ffmpeg -i source.mp4 -s 176×144 -vcodec h263 -r 25 -b 12200 -ab 12200 -ac 1 -ar 8000 destination.3gp
SD MPEG4 Part 2
[edit | edit source]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/DivX
[edit | edit source]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"
H264
[edit | edit source]SD Quality-based H264
[edit | edit source]ffmpeg -i "input_video" -c:v h264 -crf 18 -preset slow -profile high -strict -1 -async 1 "output.mp4"
SD Contant Bitrate H264
[edit | edit source]ffmpeg -i "input_video" -c:v h264 -b:v 2000k -preset slow -profile high -strict -1 -async 1 "output.mp4"
H265
[edit | edit source]Additional examples and details of the different arguments and codecs can be found on the FFMPEG homepage.
Universal Delivery
[edit | edit source]Common file types: .mpg, .mp4, .ts, .mkv
CD
[edit | edit source]VCD and SVCD
DVD
[edit | edit source]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 8 Mb/s and a minimum of 1.5 Mb/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 6 Mb/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 DVDs
[edit | edit source]Best quality: 8 Mb/s, 55 minutes of video
- 1 Hour: 7350 Kb/s
- 2 Hours: 4550 Kb/s
(these are guide lines you may need to adjust to the length of your footage.)
You should avoid going below 4500 kb/s as the quality become awful.
- Highest quality: 8 Mb/s
- Average quality: 5 Mb/s – 7 Mb/s
- Lowest quality: 5 Mb/s
- Poor quality: 4 Mb/s
Final encoded content must fit either a 4.7 GB single-sided DVD or 8.4 GB double-sided DVD.
Variable Bit Rate DVDs
[edit | edit source]BLU-RAY and HDDVD
[edit | edit source]25Mb/s - 60Mb/s
Broadcast
[edit | edit source]15Mb/s
Long Term, High Quality Storage
[edit | edit source]50 - 880Mb/s
Streaming
[edit | edit source]It's hard to provide an example table as many sources vary their bitrate and quality based on video resolution and server bandwidth.
Interlaced Footage
[edit | edit source]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.