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 subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
@ -135,27 +136,28 @@ def set_ffmpeg_metadata_chapters(
|
||||||
lines += _create_metadata_chapters(chapters=chapters, file_duration_sec=file_duration_sec)
|
lines += _create_metadata_chapters(chapters=chapters, file_duration_sec=file_duration_sec)
|
||||||
|
|
||||||
tmp_file_path = FFMPEG.tmp_file_path(relative_file_path=file_path)
|
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.write("\n".join(lines))
|
||||||
metadata_file.flush()
|
metadata_file.flush()
|
||||||
|
|
||||||
FFMPEG.run(
|
FFMPEG.run(
|
||||||
[
|
[
|
||||||
"-i",
|
"-i",
|
||||||
file_path,
|
file_path,
|
||||||
"-i",
|
"-i",
|
||||||
metadata_file.name,
|
metadata_file.name,
|
||||||
"-map",
|
"-map",
|
||||||
"0",
|
"0",
|
||||||
"-map_chapters",
|
"-map_chapters",
|
||||||
"1",
|
"1",
|
||||||
"-bitexact", # for reproducibility
|
"-bitexact", # for reproducibility
|
||||||
"-codec",
|
"-codec",
|
||||||
"copy",
|
"copy",
|
||||||
tmp_file_path,
|
tmp_file_path,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
FileHandler.move(tmp_file_path, 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:
|
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:
|
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)
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue