From 89d9b96f9d704d070032d04cfbdffa467e350539 Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Fri, 23 Mar 2012 18:41:38 +0100 Subject: [PATCH] Added posibility for CRF-Encoding Bitrate <= 51 will be treated as a CRF-Factor, Bitrate > 52 will be treated as a constant bitrate. --- n900-encode.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/n900-encode.py b/n900-encode.py index 0f06f4e..4772faa 100755 --- a/n900-encode.py +++ b/n900-encode.py @@ -69,7 +69,7 @@ def main(argv): elif opt in ("-a", "--abitrate"): abitrate = int(arg) * 1000 elif opt in ("-v", "--vbitrate"): - vbitrate = int(arg) * 1000 + vbitrate = int(arg) elif opt in ("-t", "--threads"): threads = arg elif opt in ("-f", "--force-overwrite"): @@ -193,6 +193,14 @@ def convert(input, output, res, abitrate, vbitrate, threads, mpopts): # Define ffmpeg command for a/v encoding + + if (vbitrate > 51): + rmode = "-b:v" + vbitr = str(vbitrate*1000) + else + rmode = "-crf" + vbitr = vbitrate + ffmenc = [ ffbin, "-f", "yuv4mpegpipe", "-i", vfifo, @@ -206,7 +214,7 @@ def convert(input, output, res, abitrate, vbitrate, threads, mpopts): "-threads", str(threads), "-vprofile", "baseline", "-tune", "animation", - "-b:v", str(vbitrate), + rmode, vbitr, "-flags", "+loop", "-cmp", "+chroma", "-partitions", "+parti4x4+partp8x8+partb8x8", "-subq", "5", "-trellis", "1", "-refs", "1",