Use os.path.join for files path

This commit is contained in:
Yorick Barbanneau 2015-12-09 10:37:36 +01:00
parent 2a716b526f
commit d3d81f0eed

View file

@ -90,6 +90,7 @@ def list_file(directory, pattern, recursive):
return return
for i in dirs: for i in dirs:
logging.debug(' working on file / dir %s', i)
if os.path.isdir(directory + "/" + i) and recursive: if os.path.isdir(directory + "/" + i) and recursive:
logging.info('directory found : %s', i) logging.info('directory found : %s', i)
files_list.extend(list_file( files_list.extend(list_file(
@ -110,7 +111,7 @@ def get_file_name(path):
path (string) : complete path + file path (string) : complete path + file
""" """
return os.path.splitext(os.path.basename(path))[0] return os.path.splitext(os.path.basename(path))[0]
def process_arg(sysarg): def process_arg(sysarg):
""" """
@ -187,7 +188,9 @@ def encode_h264(src, dest):
] + params["h264_acommand"] + [ ] + params["h264_acommand"] + [
dest+".mp4" dest+".mp4"
] ]
logging.debug("First Pass command %s", firstpass)
execute(firstpass) execute(firstpass)
logging.debug("Second pass command %s", secondpass)
execute(secondpass) execute(secondpass)
else: else:
logging.debug("one pass encoding started ...") logging.debug("one pass encoding started ...")
@ -226,14 +229,19 @@ if __name__ == "__main__":
) )
for f in video_files: for f in video_files:
logging.info('batch encode | file %s', f) logging.info('batch encode | file %s', f)
encode_h264(f, params["file_output"] + get_file_name(f)) encode_h264(f, os.path.join(
params["file_output"], get_file_name(f)
))
else: else:
if os.path.isfile(params["file_input"]): if os.path.isfile(params["file_input"]):
if not params["file_output"]: if not params["file_output"]:
params["file_output"] = get_file_name(params["file_input"]) params["file_output"] = get_file_name(params["file_input"])
else: else:
if os.path.isdir(params["file_output"]): if os.path.isdir(params["file_output"]):
params["file_input"] += get_file_name(params["file_input"]) params["file_input"] = os.path.join(
params["file_input"],
get_file_name(params["file_input"])
)
logging.info('%s is a file', params["file_input"]) logging.info('%s is a file', params["file_input"])
encode_h264(params["file_input"], params["file_output"]) encode_h264(params["file_input"], params["file_output"])
else: else: