Compare commits
2 Commits
ddbf16504a
...
605d777572
Author | SHA1 | Date | |
---|---|---|---|
605d777572 | |||
f7efbab2aa |
17
vid_convert.py
Executable file → Normal file
17
vid_convert.py
Executable file → Normal file
@ -97,7 +97,7 @@ def is_interlaced(file, infos):
|
|||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
pct = 100
|
pct = 100
|
||||||
if pct > 10:
|
if pct > 10:
|
||||||
logging.debug("Vidéo entrelacée à {pct}%")
|
logging.debug(f"Vidéo entrelacée à {pct}%")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logging.debug("Vidéo non entrelacée")
|
logging.debug("Vidéo non entrelacée")
|
||||||
@ -167,7 +167,7 @@ def convert_audio(file, track, volume_adj, channels, channel_layout, language, t
|
|||||||
logging.error(result)
|
logging.error(result)
|
||||||
|
|
||||||
|
|
||||||
def convert_video(file, infos, start, crop, crf, animation):
|
def convert_video(file, infos, start, crop, crf, animation, interlaced, vhs):
|
||||||
str_start = "{:05d}".format(start)
|
str_start = "{:05d}".format(start)
|
||||||
output = f'{file}_video_t{str_start}.mkv'
|
output = f'{file}_video_t{str_start}.mkv'
|
||||||
fmt = "yuv420p10le"
|
fmt = "yuv420p10le"
|
||||||
@ -178,6 +178,10 @@ def convert_video(file, infos, start, crop, crf, animation):
|
|||||||
tune = "-tune animation"
|
tune = "-tune animation"
|
||||||
else:
|
else:
|
||||||
tune = ""
|
tune = ""
|
||||||
|
if interlaced:
|
||||||
|
crop = f"{crop},yadif"
|
||||||
|
if vhs:
|
||||||
|
crop = f"{crop},hqdn3d,unsharp=5:5:0.8:3:3:0.4"
|
||||||
if 'side_data_list' in infos['video'].keys():
|
if 'side_data_list' in infos['video'].keys():
|
||||||
try:
|
try:
|
||||||
light_level = f"{infos['video']['side_data_list'][1]['max_content']},{infos['video']['side_data_list'][1]['max_average']}"
|
light_level = f"{infos['video']['side_data_list'][1]['max_content']},{infos['video']['side_data_list'][1]['max_average']}"
|
||||||
@ -273,8 +277,8 @@ def create_mkv(filename):
|
|||||||
|
|
||||||
|
|
||||||
def mkv_to_mp4(filename):
|
def mkv_to_mp4(filename):
|
||||||
options = "-map 0 -c:a copy -c:v copy -c:s copy -movflags faststart"
|
options = "-c:a copy -c:v copy -c:s copy -movflags faststart"
|
||||||
command = f"ffmpeg -loglevel error -i {filename}_FINAL.mkv {options} -y NEW_{filename[:-4]}.mp4"
|
command = f"ffmpeg -loglevel error -i {filename}_FINAL.mkv -map 0 {options} -y NEW_{filename}.mp4"
|
||||||
result = subprocess.getoutput(command)
|
result = subprocess.getoutput(command)
|
||||||
if result != "":
|
if result != "":
|
||||||
logging.error(result)
|
logging.error(result)
|
||||||
@ -290,6 +294,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument("-s", "--stabilise", dest="stab", action="store_true")
|
parser.add_argument("-s", "--stabilise", dest="stab", action="store_true")
|
||||||
parser.add_argument("-t", "--starttime", dest="starttime")
|
parser.add_argument("-t", "--starttime", dest="starttime")
|
||||||
parser.add_argument("-a", "--animation", dest="animation", action="store_true")
|
parser.add_argument("-a", "--animation", dest="animation", action="store_true")
|
||||||
|
parser.add_argument("-c", "--vhs", dest="vhs", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.debug:
|
if args.debug:
|
||||||
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.DEBUG, datefmt='%d/%m/%Y %H:%M:%S')
|
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.DEBUG, datefmt='%d/%m/%Y %H:%M:%S')
|
||||||
@ -297,7 +302,7 @@ if __name__ == '__main__':
|
|||||||
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.INFO, datefmt='%d/%m/%Y %H:%M:%S')
|
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.INFO, datefmt='%d/%m/%Y %H:%M:%S')
|
||||||
file = args.f_input
|
file = args.f_input
|
||||||
infos = get_infos(file)
|
infos = get_infos(file)
|
||||||
# interlaced = is_interlaced(file, infos)
|
interlaced = is_interlaced(file, infos)
|
||||||
cropsize = cropping(file, infos)
|
cropsize = cropping(file, infos)
|
||||||
volumes = volume_audio(file, infos)
|
volumes = volume_audio(file, infos)
|
||||||
if args.stab:
|
if args.stab:
|
||||||
@ -317,7 +322,7 @@ if __name__ == '__main__':
|
|||||||
vid_part_time = 0
|
vid_part_time = 0
|
||||||
while vid_part_time < infos['duration']:
|
while vid_part_time < infos['duration']:
|
||||||
crf = 19
|
crf = 19
|
||||||
convert_video(file, infos, vid_part_time, cropsize, crf, animation)
|
convert_video(file, infos, vid_part_time, cropsize, crf, animation, interlaced, args.vhs)
|
||||||
vid_part_time += 300
|
vid_part_time += 300
|
||||||
create_mkv(file)
|
create_mkv(file)
|
||||||
mkv_to_mp4(file)
|
mkv_to_mp4(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user