v1.1.4 - Fixed extra metadata information not being saved to M4B files

This commit is contained in:
Deniz Şafak
2025-07-16 07:14:10 +03:00
parent 0b15633995
commit 5f5dc85ae0
5 changed files with 50 additions and 23 deletions
+5 -1
View File
@@ -1,5 +1,9 @@
# 1.1.4
- Fixed extra metadata information not being saved to M4B files, ensuring that all metadata is correctly written to the output file.
- Reformatted the code using Black for better readability and consistency.
# 1.1.3 # 1.1.3
- `M4B (with chapters)` generation is faster now, as it directly generates `m4b` files instead of converting from `wav`, which significantly reduces processing time. - `M4B (with chapters)` generation is faster now, as it directly generates `m4b` files instead of converting from `wav`, which significantly reduces processing time, fixes the issue mentioned by @Milor123 in #39
- Better sleep state handling for Linux. - Better sleep state handling for Linux.
- The app window now tries to fit the screen if its height would exceed the available display area. - The app window now tries to fit the screen if its height would exceed the available display area.
- Fixed issue where the app would not restart properly on Windows. - Fixed issue where the app would not restart properly on Windows.
+1 -1
View File
@@ -1 +1 @@
1.1.3 1.1.4
+40 -19
View File
@@ -493,20 +493,26 @@ class ConversionThread(QThread):
merged_out_file = None merged_out_file = None
ffmpeg_proc = None ffmpeg_proc = None
# Prepare ffmpeg command for m4b output # Prepare ffmpeg command for m4b output
metadata_options = self._extract_and_add_metadata_tags_to_ffmpeg_cmd()
cmd = [ cmd = [
"ffmpeg", "ffmpeg",
"-y", "-y",
"-thread_queue_size", "32768", "-thread_queue_size",
"-f", "f32le", "32768",
"-ar", "24000", "-f",
"-ac", "1", "f32le",
"-i", "pipe:0", "-ar",
"-c:a", "aac", "24000",
"-q:a", "2", "-ac",
"-movflags", "+faststart+use_metadata_tags", "1",
"-i",
"pipe:0",
"-c:a",
"aac",
"-q:a",
"2",
"-movflags",
"+faststart+use_metadata_tags",
] ]
cmd += metadata_options
cmd.append(merged_out_path) cmd.append(merged_out_path)
ffmpeg_proc = create_process(cmd, stdin=subprocess.PIPE, text=False) ffmpeg_proc = create_process(cmd, stdin=subprocess.PIPE, text=False)
elif self.output_format == "opus": elif self.output_format == "opus":
@@ -807,7 +813,7 @@ class ConversionThread(QThread):
tokens_with_timestamps, tokens_with_timestamps,
new_entries, new_entries,
self.max_subtitle_words, self.max_subtitle_words,
fallback_end_time=chunk_start + chunk_dur fallback_end_time=chunk_start + chunk_dur,
) )
if merged_subtitle_file: if merged_subtitle_file:
subtitle_format = getattr( subtitle_format = getattr(
@@ -945,17 +951,27 @@ class ConversionThread(QThread):
orig_path = merged_out_path orig_path = merged_out_path
root, ext = os.path.splitext(orig_path) root, ext = os.path.splitext(orig_path)
tmp_path = root + ".tmp" + ext tmp_path = root + ".tmp" + ext
metadata_options = (
self._extract_and_add_metadata_tags_to_ffmpeg_cmd()
)
cmd = [ cmd = [
"ffmpeg", "ffmpeg",
"-y", "-y",
"-i", orig_path, "-i",
"-i", chapters_info_path, orig_path,
"-map", "0:a", "-i",
"-map_metadata", "1", chapters_info_path,
"-map_chapters", "1", "-map",
"-c:a", "copy", "0:a",
tmp_path "-map_metadata",
"1",
"-map_chapters",
"1",
"-c:a",
"copy",
] ]
cmd += metadata_options
cmd.append(tmp_path)
proc = create_process(cmd) proc = create_process(cmd)
proc.wait() proc.wait()
os.replace(tmp_path, orig_path) os.replace(tmp_path, orig_path)
@@ -1126,7 +1142,11 @@ class ConversionThread(QThread):
return f"{h}:{m:02}:{s:02}.{cs:02}" return f"{h}:{m:02}:{s:02}.{cs:02}"
def _process_subtitle_tokens( def _process_subtitle_tokens(
self, tokens_with_timestamps, subtitle_entries, max_subtitle_words, fallback_end_time=None self,
tokens_with_timestamps,
subtitle_entries,
max_subtitle_words,
fallback_end_time=None,
): ):
"""Helper function to process subtitle tokens according to the subtitle mode""" """Helper function to process subtitle tokens according to the subtitle mode"""
if not tokens_with_timestamps: if not tokens_with_timestamps:
@@ -1222,6 +1242,7 @@ class ConversionThread(QThread):
start, end, text = last_entry start, end, text = last_entry
if end is None or end <= start or end <= 0: if end is None or end <= start or end <= 0:
subtitle_entries[-1] = (start, fallback_end_time, text) subtitle_entries[-1] = (start, fallback_end_time, text)
def cancel(self): def cancel(self):
self.cancel_requested = True self.cancel_requested = True
self.should_cancel = True self.should_cancel = True
+3 -2
View File
@@ -2822,14 +2822,15 @@ class abogen(QWidget):
def restart_app(self): def restart_app(self):
from PyQt5.QtCore import QProcess from PyQt5.QtCore import QProcess
import sys import sys
exe = sys.executable exe = sys.executable
args = sys.argv args = sys.argv
# On Windows, use .exe if available # On Windows, use .exe if available
if platform.system() == "Windows": if platform.system() == "Windows":
script_path = args[0] script_path = args[0]
if not script_path.lower().endswith('.exe'): if not script_path.lower().endswith(".exe"):
exe_path = os.path.splitext(script_path)[0] + '.exe' exe_path = os.path.splitext(script_path)[0] + ".exe"
if os.path.exists(exe_path): if os.path.exists(exe_path):
args[0] = exe_path args[0] = exe_path
+1
View File
@@ -245,6 +245,7 @@ def get_gpu_acceleration(enabled):
def prevent_sleep_start(): def prevent_sleep_start():
from abogen.constants import PROGRAM_NAME from abogen.constants import PROGRAM_NAME
system = platform.system() system = platform.system()
if system == "Windows": if system == "Windows":
import ctypes import ctypes