A while back, I started tinkering with ffmpeg, looking for the highest quality I could get out of it for DVD. I still author a lot of discs for people for a number of reasons, and there aren't any free, cross-platform, standards-compliant tools that scratch my itch for quality.
At the time, I couldn't get ffmpeg (actually, libavcodec's mpeg2video encoder) to use above about 3500k, no matter which options I used. Through helpful people here, I quickly found that HCenc is in many regards a superior MPEG2 encoder, and I still esteem it as probably the highest quality free MPEG2 encoder available.
HC is very high quality, but doesn't lend itself well to my use case:
- It depends on Windows and AviSynth, as well as knowledge of AviSynth syntax;
- I really want a scriptable encoder that can automatically transcode a batch of sources without a lot of manual intervention;
- I spend most of my time in OSX or Linux, and encoding via VM is burdensome. I like ffmpeg because binaries are available for many platforms.
I ultimately found a few obscure switches that finally gave lavc's ratecontrol what it needed to make use of higher bitrates: lmin, lmax, mblmin, among others. For the past few weeks, I've reawakened my interest in ffmpeg's potential to produce high quality DVD-compliant MPEG2 streams, with possibly comparable quality to the likes of HC. I have confirmed that ffmpeg does not natively support soft pulldown, but all the options below should port fairly easily to mencoder, which does support soft pulldown (see my original script linked above).
So far, I'm very pleased with the script below, which produces very good results with several samples. I'm running ffmpeg 2.2-HEAD on OSX 10.9, for those interested.
I'm still tweaking it, and would appreciate as many sets of eyes on this as possible. I don't claim to be an MPEG2 or ffmpeg expert, so I welcome input from anyone who really knows what will affect both quality and DVD compliance (my two highest priorities).
Currently I'm aware that these settings produce slightly blocky transitions when dissolving from black, especially at bitrates below 4000k. Other than that, my eyes are hard-pressed to find fault (although I'm sure some of you will have no problem finding fault :P)
Code:#!/bin/bash SOURCE=$1 DESTINATION=$2 VB=$3 VF="scale=720:480,\ hqdn3d=2:1:2,\ pp=ac" INTER_MATRIX="\ 08,08,08,09,11,13,14,17,\ 08,08,09,11,13,13,14,17,\ 08,08,11,12,13,14,17,94,\ 09,11,13,13,14,17,17,94,\ 11,11,13,13,14,17,94,94,\ 13,13,14,16,17,20,94,94,\ 13,13,14,17,94,94,94,94,\ 13,14,17,94,94,94,94,94" INTRA_MATRIX="\ 12,12,13,14,15,16,22,26,\ 12,13,14,15,16,22,26,32,\ 13,14,15,16,22,26,32,41,\ 14,15,16,22,26,32,41,53,\ 15,16,22,26,32,41,53,94,\ 16,22,26,32,41,53,70,94,\ 22,26,32,41,53,70,94,94,\ 26,32,41,53,94,94,94,94" # Pass,1 ffmpeg \ -i $SOURCE \ -framerate 30000/1001 \ -vf "$VF" \ -aspect 16:9 \ -inter_matrix $INTER_MATRIX \ -intra_matrix $INTRA_MATRIX \ -dc 10 \ -g 12 \ -b_strategy 2 \ -brd_scale 2 \ -bf 2 \ -lmin 0 \ -lmax '21*QP2LAMBDA' \ -mblmin 1 \ -qmin 1 \ -qmax 7 \ -maxrate 9800k \ -b:v $VB \ -bf 2 \ -pre_dia_size 5 \ -dia_size 5 \ -qcomp 0.7 \ -qblur 0 \ -preme 1 \ -me_method dia \ -sc_threshold 0 \ -sc_factor 4 \ -bidir_refine 4 \ -profile:v 4 \ -mbd rd \ -mbcmp satd \ -precmp satd \ -cmp satd \ -subcmp satd \ -skipcmp satd \ -pass 1 \ -passlogfile ffmpeg \ -threads 4 \ -an \ -f mpeg2video \ -y \ /dev/null # Pass 2 ffmpeg \ -i $SOURCE \ -vf "$VF" \ -framerate 30000/1001 \ -aspect 16:9 \ -inter_matrix $INTER_MATRIX \ -intra_matrix $INTRA_MATRIX \ -dc 10 \ -g 12 \ -brd_scale 2 \ -bf 2 \ -lmin 0 \ -lmax '21*QP2LAMBDA' \ -mblmin 1 \ -qmin 1 \ -qmax 7 \ -maxrate 9800k \ -b:v $VB \ -bf 2 \ -pre_dia_size 5 \ -dia_size 5 \ -qcomp 0.7 \ -qblur 0 \ -preme 1 \ -me_method dia \ -sc_threshold 0 \ -sc_factor 4 \ -bidir_refine 4 \ -profile:v 4 \ -mbd rd \ -mbcmp satd \ -precmp satd \ -cmp satd \ -subcmp satd \ -skipcmp satd \ -pass 2 \ -passlogfile ffmpeg \ -threads 4 \ -an \ -y \ -f mpeg2video \ $DESTINATION
+ Reply to Thread
Results 1 to 1 of 1
Similar Threads
-
ffmpeg: flv encoding high quality
By marcorocchini in forum Newbie / General discussionsReplies: 14Last Post: 21st Nov 2013, 06:44 -
An exercise in high-quality DVD conversion
By diprotic in forum Video ConversionReplies: 49Last Post: 12th Aug 2013, 19:40 -
DVD video conversion revisited, XviD vs mp4
By indijay in forum Video ConversionReplies: 4Last Post: 25th Jun 2013, 10:24 -
Diary of a newbie FFmpeg learn to help others! convert to High quality!
By gugaoforums in forum Video ConversionReplies: 6Last Post: 10th Sep 2011, 03:07 -
ffmpeg command for mp4 to high quality dvd
By mehdi0016 in forum Video ConversionReplies: 3Last Post: 20th Apr 2010, 05:25