Ich habe von einem Freund vor einer Weile ein .py script bekommen welches mit Hilfe von ffmpeg .mkv Dateien in .h265 Dateien umwandelt. Leider werden dabei keine Untertitel übernommen und ich bin mit dem ganzen ein bisschen überfordert. Kann mir jemand hier sagen welchen code ich wo einfügen muss?
Ich hoffe jemand kann mir helfen, demjenigen schonmal vielen dank im voraus und hier das aktuell vorhandene Script:
Code: Alles auswählen
import os, time, sys, glob, subprocess, datetime
from sys import platform as curr_os
def clear_screen():
if curr_os == 'linux' or curr_os == 'linux2':
absolutely_unused_variable = os.system('clear')
elif curr_os == 'win32':
absolutely_unused_variable = os.system('cls')
def shutdown():
if curr_os == 'linux' or curr_os == 'linux2':
os.system('shutdown -h now')
elif curr_os == 'win32':
os.system('shutdown -s -t 0')
global counter
global errors
global file_list
global conv_path
global ff_args
counter = 0
errors = 0
file_list = []
doit = ['true', '1', 'y', 'j', 'yes', 'ja', 'Y']
dontdoit = ['false', '0', 'n', 'no', 'nein', 'N']
enable_sub = '0'
ff_args = ''
clear_screen()
print('Make sure you have enough permissions')
conv_path = input('Path: ')
clear_screen()
ff_args = ff_args + '-b:v ' + input('Video bitrate: ')
ff_args = ff_args + ' -b:a ' + input('Audio bitrate: ')
ff_args = ff_args + ' -n -map 0 -c:a aac -c:v libx265 -preset medium -crf 23 -sn -probesize 100M -analyzeduration 100M '
shutdown_end = input('Shutdown after finish? [Y|N] >')
log = open('log.csv', 'a')
log.write('start_time;end_time;filename;time_taken;status\n')
def conv_fl():
global counter
counter = 0
for filename in file_list:
try:
curr_file_time_start = time.time()
os.system('ffmpeg -i "' + filename + '" ' + ff_args + '"' + filename + '"' + '.mp4')
curr_file_time_end = time.time()
curr_file_time_delta = str(round(curr_file_time_end - curr_file_time_start, 3))
ts_end = datetime.datetime.fromtimestamp(curr_file_time_end).strftime('%Y-%m-%d %H:%M:%S')
ts_start = datetime.datetime.fromtimestamp(curr_file_time_start).strftime('%Y-%m-%d %H:%M:%S')
log.write(ts_start + ';' + ts_end + ';' + filename + ';' + curr_file_time_delta + ';success\n')
counter = counter + 1
time.sleep(5)
except:
print()
def conv_sub_scan():
print('scanning for files...')
time.sleep(2)
for root, dirs, files in os.walk(conv_path):
for file in files:
if file.endswith('.mkv'):
file_list.append(os.path.join(root, file))
now = time.time()
conv_sub_scan()
clear_screen
print('scanned all files...')
print('start converting...')
clear_screen()
time.sleep(3)
conv_fl()
log.close()
clear_screen()
elapsed = time.time() - now
print('converted ' + str(counter) + ' files in ' + str(round(elapsed, 3)) + ' seconds' )
if shutdown_end in doit:
shutdown()