fix chapters
This commit is contained in:
parent
82ce526da6
commit
ad0b56002c
2 changed files with 21 additions and 19 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
@ -135,27 +136,28 @@ def set_ffmpeg_metadata_chapters(
|
|||
lines += _create_metadata_chapters(chapters=chapters, file_duration_sec=file_duration_sec)
|
||||
|
||||
tmp_file_path = FFMPEG.tmp_file_path(relative_file_path=file_path)
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", encoding="utf-8") as metadata_file:
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", encoding="utf-8", delete=False) as metadata_file:
|
||||
metadata_file.write("\n".join(lines))
|
||||
metadata_file.flush()
|
||||
|
||||
FFMPEG.run(
|
||||
[
|
||||
"-i",
|
||||
file_path,
|
||||
"-i",
|
||||
metadata_file.name,
|
||||
"-map",
|
||||
"0",
|
||||
"-map_chapters",
|
||||
"1",
|
||||
"-bitexact", # for reproducibility
|
||||
"-codec",
|
||||
"copy",
|
||||
tmp_file_path,
|
||||
]
|
||||
)
|
||||
FileHandler.move(tmp_file_path, file_path)
|
||||
FFMPEG.run(
|
||||
[
|
||||
"-i",
|
||||
file_path,
|
||||
"-i",
|
||||
metadata_file.name,
|
||||
"-map",
|
||||
"0",
|
||||
"-map_chapters",
|
||||
"1",
|
||||
"-bitexact", # for reproducibility
|
||||
"-codec",
|
||||
"copy",
|
||||
tmp_file_path,
|
||||
]
|
||||
)
|
||||
FileHandler.move(tmp_file_path, file_path)
|
||||
os.remove(metadata_file.name)
|
||||
|
||||
|
||||
def add_ffmpeg_metadata_key_values(file_path: str, key_values: Dict[str, str]) -> None:
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ class FileHandlerTransactionLog:
|
|||
)
|
||||
|
||||
if self.is_empty:
|
||||
lines.append(f"No new, modified, or removed files in '{output_directory}'")
|
||||
lines.append(f"No new, modified, or removed files in '{self.format_path_str(output_directory)}'")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue