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",
|
||||
"verbose": True,
|
||||
"pattern": "",
|
||||
"twopass": True}
|
||||
"twopass": False}
|
||||
|
||||
VERSION = "0.1dev"
|
||||
exec_ffmpeg = os.path.join("ffmpeg")
|
||||
|
@ -64,6 +64,10 @@ def listFile(directory, pattern):
|
|||
return files_list
|
||||
|
||||
|
||||
def getFileName(path):
|
||||
return os.path.splitext(os.path.basename(path))[0]
|
||||
|
||||
|
||||
def processArg(sysarg):
|
||||
try:
|
||||
opts, args = getopt.getopt(
|
||||
|
@ -106,7 +110,7 @@ def processArg(sysarg):
|
|||
|
||||
|
||||
def encode_h264(src, dest):
|
||||
if (params["twopass"] == True):
|
||||
if (params["twopass"]):
|
||||
log("two pass encoding started ...")
|
||||
firstpass = [
|
||||
exec_ffmpeg,
|
||||
|
@ -136,13 +140,12 @@ def encode_h264(src, dest):
|
|||
log("one pass encoding started ...")
|
||||
encode = [
|
||||
exec_ffmpeg,
|
||||
" -i " + src,
|
||||
" -pass 2",
|
||||
"-codec:v libx264",
|
||||
" -b:v " + params["vbitrate"]
|
||||
"-i", src,
|
||||
"-codec:v", "libx264",
|
||||
"-b:v ", params["vbitrate"]
|
||||
] + params["h264_vcommand"] + [
|
||||
" -b:a "+params["abitrate"],
|
||||
params["h264_acommand"],
|
||||
"-b:a", params["abitrate"]
|
||||
] + params["h264_acommand"] + [
|
||||
dest+".mp4"
|
||||
]
|
||||
subprocess.call(encode)
|
||||
|
@ -161,11 +164,10 @@ if __name__ == "__main__":
|
|||
else:
|
||||
if os.path.isfile(params["file_input"]):
|
||||
if (params["file_output"]):
|
||||
params["file_output"] = os.path.basename(params["file_input"])
|
||||
params["file_output"] = getFileName(params["file_input"])
|
||||
else:
|
||||
if(os.path.isdir(params["file_output"])):
|
||||
params["file_input"] += \
|
||||
os.path.basename(params["file_input"])
|
||||
params["file_input"] += getFileName(params["file_input"])
|
||||
log(params["file_input"] + " is a file")
|
||||
encode_h264(params["file_input"], params["file_output"])
|
||||
else:
|
||||
|
|
Reference in a new issue