organising classes
--HG-- branch : sandbox
This commit is contained in:
@@ -17,8 +17,7 @@ Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=ISO-8859-1"
|
||||
http-equiv="content-type">
|
||||
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -37,8 +36,7 @@ Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=ISO-8859-1"
|
||||
http-equiv="content-type">
|
||||
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
94
src/transcode/wtv2mp4.py
Normal file
94
src/transcode/wtv2mp4.py
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: cp1252 -*-
|
||||
# Copyright (c) 2014 Andreas
|
||||
# See LICENSE for details.
|
||||
|
||||
""" compress Panasonic HDR mts video files to mp4 """
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import datetime as dt
|
||||
|
||||
|
||||
def transcode(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
# parse options and arguments
|
||||
parser = ArgumentParser(description="handbrake")
|
||||
parser.add_argument("-d")
|
||||
parser.add_argument("-o")
|
||||
args = parser.parse_args(argv)
|
||||
print("starting '{} {}'".format(os.path.basename(argv[0]), args))
|
||||
# handbrake = r'C:\Program Files\Handbrake\HandbrakeCLI.exe'
|
||||
handbrake = r'C:\Apps\handbrake\HandbrakeCLI.exe'
|
||||
# startup application
|
||||
for dir_, _, files in os.walk(args.d):
|
||||
for file in files:
|
||||
root, ext = os.path.splitext(file)
|
||||
if ext not in (".wtv"):
|
||||
continue
|
||||
if "arte" not in root:
|
||||
continue
|
||||
fn = os.path.join(dir_, file)
|
||||
# unix_mod_mtime = os.stat(fn).st_mtime
|
||||
# mtime = dt.datetime.fromtimestamp(unix_mod_mtime)
|
||||
mp4_fn = "%s.mp4" % root # mtime.strftime("%Y%m%d-%H%M%S")
|
||||
mp4_fp = os.path.join(args.o, mp4_fn)
|
||||
if not os.path.exists(mp4_fp):
|
||||
hbargs = [handbrake, '-i', fn, '-o', mp4_fp]
|
||||
# WMC
|
||||
# opts = '-t 1 --angle 1 -c 1 -f mp4 -O --decomb --strict-anamorphic --keep-display-aspect -e x264 -b 1350 --vfr -a 1 -E av_aac -6 stereo -R Auto -B 160 -D 0 --gain 0 --audio-fallback ac3 --encoder-preset=faster --encoder-tune=film --verbose=1'
|
||||
# WMC arte
|
||||
opts = '-t 1 --angle 1 -c 1 -f mp4 -O --decomb --strict-anamorphic --keep-display-aspect -e x264 -b 1350 --vfr -a 1,1 -E av_aac,av_aac -6 stereo,stereo -R Auto,48 -B 160,160 -D 0,0 --gain 0,0 --audio-fallback ac3 --encoder-preset=faster --encoder-tune=film --verbose=1'
|
||||
# opts = '-t 1 --angle 1 -c 1 -f mp4 --decomb --strict-anamorphic --keep-display-aspect --optimize -e x264 -b 1350 -2 -T --cfr -a 1 -E faac -6 stereo -R Auto -B 160 -D 0 --gain 0 --audio-fallback ffac3 --x264-tune=film --verbose=1'
|
||||
hbargs.extend(opts.split())
|
||||
print(" ".join((shlex.quote(a) for a in hbargs)))
|
||||
try:
|
||||
subprocess.run(hbargs, timeout=30 * 60)
|
||||
except subprocess.TimeoutExpired as e:
|
||||
# mark as failed
|
||||
with open(mp4_fp) as f:
|
||||
pass
|
||||
else:
|
||||
shutil.copystat(fn, mp4_fp)
|
||||
print("done.")
|
||||
|
||||
|
||||
REMTS = r'(?P<no>\d{5})\.MTS'
|
||||
|
||||
|
||||
def rename_mts(argv=None):
|
||||
# 2002-07-28 02.22.56 Werne.mp4
|
||||
# DV, SD, HD
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
parser = ArgumentParser(description="batch rename")
|
||||
parser.add_argument("-d")
|
||||
args = parser.parse_args(argv)
|
||||
print("starting '{} {}'".format(os.path.basename(argv[0]), args))
|
||||
reo = re.compile(REMTS)
|
||||
files = os.listdir(args.d)
|
||||
for fn in sorted(files):
|
||||
file = os.path.join(args.d, fn)
|
||||
root, ext = os.path.splitext(fn)
|
||||
mo = reo.match(fn)
|
||||
if not mo:
|
||||
print(file)
|
||||
continue
|
||||
st = os.stat(file)
|
||||
mt = dt.datetime.fromtimestamp(st.st_mtime)
|
||||
fn2 = "{:04}{:02}{:02}-{:02}{:02}{:02}-HD{}".format(mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second, ext)
|
||||
dest = os.path.join(args.d, fn2)
|
||||
print("{} -> {}".format(file, fn2))
|
||||
os.rename(file, dest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
transcode(["-d", r"I:\Users\Public\Recorded TV", "-o", r"E:\Videos"])
|
||||
# rename_mts(["-d", r"E:\Shared Documents\Raw\Panasonic HDC-SD99\20140720"])
|
||||
Reference in New Issue
Block a user