add getFileName > filename w/o .ext
This commit is contained in:
parent
b22258d88e
commit
6c7ba12990
1 changed files with 13 additions and 11 deletions
|
@ -35,7 +35,7 @@ params = {
|
||||||
"webm_acommand": "-strict -2",
|
"webm_acommand": "-strict -2",
|
||||||
"verbose": True,
|
"verbose": True,
|
||||||
"pattern": "",
|
"pattern": "",
|
||||||
"twopass": True}
|
"twopass": False}
|
||||||
|
|
||||||
VERSION = "0.1dev"
|
VERSION = "0.1dev"
|
||||||
exec_ffmpeg = os.path.join("ffmpeg")
|
exec_ffmpeg = os.path.join("ffmpeg")
|
||||||
|
@ -64,6 +64,10 @@ def listFile(directory, pattern):
|
||||||
return files_list
|
return files_list
|
||||||
|
|
||||||
|
|
||||||
|
def getFileName(path):
|
||||||
|
return os.path.splitext(os.path.basename(path))[0]
|
||||||
|
|
||||||
|
|
||||||
def processArg(sysarg):
|
def processArg(sysarg):
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(
|
opts, args = getopt.getopt(
|
||||||
|
@ -106,7 +110,7 @@ def processArg(sysarg):
|
||||||
|
|
||||||
|
|
||||||
def encode_h264(src, dest):
|
def encode_h264(src, dest):
|
||||||
if (params["twopass"] == True):
|
if (params["twopass"]):
|
||||||
log("two pass encoding started ...")
|
log("two pass encoding started ...")
|
||||||
firstpass = [
|
firstpass = [
|
||||||
exec_ffmpeg,
|
exec_ffmpeg,
|
||||||
|
@ -136,13 +140,12 @@ def encode_h264(src, dest):
|
||||||
log("one pass encoding started ...")
|
log("one pass encoding started ...")
|
||||||
encode = [
|
encode = [
|
||||||
exec_ffmpeg,
|
exec_ffmpeg,
|
||||||
" -i " + src,
|
"-i", src,
|
||||||
" -pass 2",
|
"-codec:v", "libx264",
|
||||||
"-codec:v libx264",
|
"-b:v ", params["vbitrate"]
|
||||||
" -b:v " + params["vbitrate"]
|
|
||||||
] + params["h264_vcommand"] + [
|
] + params["h264_vcommand"] + [
|
||||||
" -b:a "+params["abitrate"],
|
"-b:a", params["abitrate"]
|
||||||
params["h264_acommand"],
|
] + params["h264_acommand"] + [
|
||||||
dest+".mp4"
|
dest+".mp4"
|
||||||
]
|
]
|
||||||
subprocess.call(encode)
|
subprocess.call(encode)
|
||||||
|
@ -161,11 +164,10 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(params["file_input"]):
|
if os.path.isfile(params["file_input"]):
|
||||||
if (params["file_output"]):
|
if (params["file_output"]):
|
||||||
params["file_output"] = os.path.basename(params["file_input"])
|
params["file_output"] = getFileName(params["file_input"])
|
||||||
else:
|
else:
|
||||||
if(os.path.isdir(params["file_output"])):
|
if(os.path.isdir(params["file_output"])):
|
||||||
params["file_input"] += \
|
params["file_input"] += getFileName(params["file_input"])
|
||||||
os.path.basename(params["file_input"])
|
|
||||||
log(params["file_input"] + " is a file")
|
log(params["file_input"] + " is a file")
|
||||||
encode_h264(params["file_input"], params["file_output"])
|
encode_h264(params["file_input"], params["file_output"])
|
||||||
else:
|
else:
|
||||||
|
|
Reference in a new issue