fix: use absolute paths with forward slashes in FFmpeg concat demuxer to support Windows Unicode paths
This commit is contained in:
parent
8e7c9d374a
commit
dbbaff126c
16
cut_head.py
16
cut_head.py
|
|
@ -112,15 +112,23 @@ def smart_cut(input_video, output_video, cut_timestamp):
|
||||||
return
|
return
|
||||||
|
|
||||||
# 3. Concatenate video parts and cleanly mux with the original extracted audio
|
# 3. Concatenate video parts and cleanly mux with the original extracted audio
|
||||||
|
# Use absolute paths with forward slashes — Windows FFmpeg's concat demuxer
|
||||||
|
# cannot resolve relative paths when the CWD contains Unicode characters.
|
||||||
|
abs_part1 = os.path.abspath(part1).replace('\\', '/')
|
||||||
|
abs_part2 = os.path.abspath(part2).replace('\\', '/')
|
||||||
|
abs_concat = os.path.abspath(concat_list).replace('\\', '/')
|
||||||
|
abs_input = os.path.abspath(input_video).replace('\\', '/')
|
||||||
|
abs_output = os.path.abspath(output_video).replace('\\', '/')
|
||||||
|
|
||||||
with open(concat_list, 'w', encoding='utf-8') as f:
|
with open(concat_list, 'w', encoding='utf-8') as f:
|
||||||
f.write(f"file '{part1}'\nfile '{part2}'\n")
|
f.write(f"file '{abs_part1}'\nfile '{abs_part2}'\n")
|
||||||
|
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
'ffmpeg', '-y', '-v', 'error',
|
'ffmpeg', '-y', '-v', 'error',
|
||||||
'-f', 'concat', '-safe', '0', '-i', concat_list,
|
'-f', 'concat', '-safe', '0', '-i', abs_concat,
|
||||||
'-ss', str(cut_timestamp), '-i', input_video,
|
'-ss', str(cut_timestamp), '-i', abs_input,
|
||||||
'-map', '0:v', '-map', '1:a?',
|
'-map', '0:v', '-map', '1:a?',
|
||||||
'-c:v', 'copy', '-c:a', 'copy', output_video
|
'-c:v', 'copy', '-c:a', 'copy', abs_output
|
||||||
], check=True)
|
], check=True)
|
||||||
print(f"Success! Saved to {output_video}")
|
print(f"Success! Saved to {output_video}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue