Log in

View Full Version : Force film in Robot4Rip


zap_path
7th April 2005, 23:27
I'm not sure how the auto force film used to work when Robot4Rip used the old DVD2AVI, but since it is now broken with DGDecode, I thought I'd write a simple fix. The attached Python script can be invoked from the "finalize" step in Robot4Rip. It checks the film percentage setting at the end of the d2v file against a specified threshold and alters the force film setting and frame rate if necessary. Also, the iDCT setting is altered to the user specified value.

-zap_path

Edit: My attached script doesn't seem to have appeared; perhaps I need moderator permision? I'd post it as text, but the line breaks get messed up.

Edit 2: Python script follows. Enjoy.

import sys
import re

#check arguments
usageString = "usage: python forceFilm.py d2v iDCT threshold"
if len(sys.argv)!=4:
print usageString
sys.exit()

threshold = float(sys.argv[3])

#open file
d2vFile = open(sys.argv[1],'r')
contents = d2vFile.read()
d2vFile.close()

#Change iDCT
iDCTHeader = re.compile(r"^iDCT_Algorithm\s*=\s*\d*",re.M)
#iDCTHeaderMatch = iDCTHeader.search(contents)
#print contents[iDCTHeaderMatch.start():iDCTHeaderMatch.end()]
contents = iDCTHeader.sub("iDCT_Algorithm="+sys.argv[2],contents,1)
#print contents[iDCTHeaderMatch.start():iDCTHeaderMatch.end()]

#Check wheter we should force film
filmContentHeader = re.compile(r"^FINISHED\s*(\d+(\.\d*)?)%\sFILM",re.M)
filmContentHeaderMatch = filmContentHeader.search(contents)
#print contents[filmContentHeaderMatch.start():filmContentHeaderMatch.end()]
#print filmContentHeaderMatch.group(1)
filmContent = float(filmContentHeaderMatch.group(1))

frameRateHeader = re.compile(r"^Frame_Rate\s*=\s*(\d*)",re.M)
frameRateHeaderMatch = frameRateHeader.search(contents)
#print contents[frameRateHeaderMatch.start():frameRateHeaderMatch.end()]
#print frameRateHeaderMatch.group(1)

#if so, change fields for force film
if (filmContent>=threshold) and (frameRateHeaderMatch.group(1)=="29970"):
#print "do IVTC"
#change the frame rate
contents = frameRateHeader.sub("Frame_Rate=23976",contents,1)
#print contents[frameRateHeaderMatch.start():frameRateHeaderMatch.end()]
#and change the field operation
fieldOperationHeader = re.compile(r"^Field_Operation\s*=\s*\d*",re.M)
#fieldOperationHeaderMatch = fieldOperationHeader.search(contents)
#print contents[fieldOperationHeaderMatch.start():fieldOperationHeaderMatch.end()]
contents = fieldOperationHeader.sub("Field_Operation=1",contents,1)
#print contents[fieldOperationHeaderMatch.start():fieldOperationHeaderMatch.end()]

#write back file
d2vFile = open(sys.argv[1],'w')
d2vFile.write(contents)

jggimi
8th April 2005, 14:12
Hello, and welcome to the forum.

Attachments don't appear until approved by one of the forum's moderators -- in this case, DaveEL, len0x, manono, or TheWEF.

But you can always use the "[code]" vB tag, or "#" vB tag button, if you want a fixed pitch font with no breaks. See the section labelled The Code and PHP Tags in http://forum.doom9.org/misc.php?action=bbcode#buttons.