[MPlayer-users] perfect playback from dvd, jerky from mpg4?
Andres Meyer
andres.meyer at computer.org
Thu Apr 3 02:26:08 CEST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> maybe -ofps 23.976 (at encoding) help?
> (mplayer autodetects it after a few seconds but mencoder can't)
why is that? Whatever. I now just look for TELECINE messages in stdout of
mplayer...
> btw you don't need to mess w/ loopdev, -dvd-device something.iso is just
> fine
makes things easier... cool.
thx, that was a fast response. I will see the result tomorrow morning...
Andres
PS: small adjustments
#!/usr/bin/python
#
# mencoder dvd backup script
#
# Andres Meyer, 2003
import os
import re
import sys
import getopt
usage = "enc.py {{-i | --iso} movie.iso | {-d | --dvd} /dev/dvd} [{-o |
- --output} movie.avi] [{-l | --language} en] [-p | --pretend] [-t |
- --telecine]\n"
try:
opts, tmp = getopt.getopt(sys.argv[1:], "i:o:l:d:pt", ["iso=", "output=",
"language=","dvd=", "pretend", "telecine"])
except getopt.GetoptError:
print usage
sys.exit(2)
source = None
target = None
lang = "en,de,fr"
pretend = None
telecine = None
for o, a in opts:
if o in ("-i", "--iso"):
if target == None:
path, ext = os.path.splitext( a)
target = "%s.avi" % path
source = a
if o in ("-d", "--dvd"):
source = a
if o in ("-o", "--output"):
target = a
if o in ("-l", "--lang"):
lang = a
if o in ("-p", "--pretend"):
pretend = 1
if o in ("-t", "--telecine"):
telecine = 1
if source == None:
print usage
sys.exit(2)
print "source: %s, target: %s, lang: %s\n" % (source, target, lang)
cx = 10000
cy = 10000
cw = 0
ch = 0
trackNum = 1
cropNum = None
dvdInfo = ""
while cropNum == None:
for minute in range( 20, 30):
cmd = "mplayer -vo null -dvd %s -dvd-device \"%s\" -vop cropdetect -ss
00:%s:00 -frames 12" % (trackNum, source, minute)
print "cmd :%s" % cmd
dvdInfo = os.popen( cmd).read()
cropNum = re.compile( r".*\(-vop crop=(.*):(.*):(.*):(.*)\).*").search(
dvdInfo)
print "*************************************************\n"
print dvdInfo
if cropNum == None:
trackNum = trackNum + 1
if trackNum > 9:
sys.exit("************ error *************\n")
break
x = int( cropNum.group(3))
y = int( cropNum.group(4))
w = int( cropNum.group(1))
h = int( cropNum.group(2))
cx = min( cx, x)
cy = min( cy, y)
cw = max( cw, w)
ch = max( ch, h)
if re.compile( r".*3:2 TELECINE.*").search( dvdInfo) != None:
telecine = 1
print "**********"
print "Crop=(%s:%s:%s:%s)" % (cw, ch, cx, cy)
resMatch = re.compile( r".*Movie-Aspect is (.*):1.*").search( dvdInfo)
aspect = float( resMatch.group(1))
print "Aspect=%s" % aspect
resMatch = re.compile( r".*VIDEO: MPEG2 (.*)x(.*) \(aspect.*\) (.*) fps
.*").search( dvdInfo)
resX = int( resMatch.group(1))
resY = int( resMatch.group(2))
fps = float( resMatch.group(3))
print "fps from dvd = %s\n" % fps
if telecine != None:
print "fps override = 23.976\n"
ofps = "-ofps 23.976"
else:
ofps = " "
newAspect = (float(cw) / float(resX))/(float(ch) / float(resY)) * aspect
cmd = "nice -18 mencoder -dvd %s -dvd-device \"%s\" %s -ovc lavc -vop
crop=%s:%s:%s:%s -alang %s -oac copy -lavcopts
vcodec=mpeg4:aspect=%s:vhq:v4mv:vbitrate=2000" % (trackNum, source, ofps, cw,
ch, cx, cy, lang, newAspect)
cmd1 = "%s:vpass=1 -o /dev/null" % cmd
cmd2 = "%s:vpass=2 -o \"%s\"" % (cmd, target)
print
print
print "%s; %s" % (cmd1, cmd2)
if pretend == None:
os.popen( cmd1).read()
os.popen( cmd2).read()
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+i3+ksOmBKjmDDSMRAvYOAJ4sfKxmcTFLd6iagUvhwVAiog2kqgCfTED0
5wsapvMU7gRi+5rn358e5lo=
=H+ER
-----END PGP SIGNATURE-----
More information about the MPlayer-users
mailing list