Merge pull request #66 from peter-tar/output_fix
Some checks failed
Git clone and run / linux-git-clone-and-run (push) Has been cancelled
Git clone and run / windows-git-clone-and-run (push) Has been cancelled
Installing via pip and running / install-and-run-on-python-3-11 (push) Has been cancelled
Installing via pip and running / install-and-run-on-python-3-12 (push) Has been cancelled
Installing via pip and running / install-and-run-on-python-3-10 (push) Has been cancelled
Installing via pip and running / windows-git-clone-and-run (push) Has been cancelled

Fix: Output folder not taken into account
This commit is contained in:
Claudio Santini 2025-02-16 22:10:11 +01:00 committed by GitHub
commit f2ffaf7daa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -267,13 +267,14 @@ def create_m4b(chapter_files, filename, cover_image, output_folder):
print('Converting to Mp4...') print('Converting to Mp4...')
combined_audio.export(tmp_file_path, format="mp4", bitrate="128k") combined_audio.export(tmp_file_path, format="mp4", bitrate="128k")
final_filename = Path(output_folder) / filename.replace('.epub', '.m4b') final_filename = Path(output_folder) / filename.replace('.epub', '.m4b')
chapters_txt_path = Path(output_folder) / "chapters.txt"
print('Creating M4B file...') print('Creating M4B file...')
if cover_image: if cover_image:
cover_file_path = Path(output_folder) / 'cover' cover_file_path = Path(output_folder) / 'cover'
with open(cover_file_path, 'wb') as f: with open(cover_file_path, 'wb') as f:
f.write(cover_image) f.write(cover_image)
cover_image_args = ["-i", cover_file_path.name, "-map", "0:a", "-map", "2:v"] cover_image_args = ["-i", f'{cover_file_path}', "-map", "0:a", "-map", "2:v"]
else: else:
cover_image_args = [] cover_image_args = []
@ -281,7 +282,7 @@ def create_m4b(chapter_files, filename, cover_image, output_folder):
'ffmpeg', 'ffmpeg',
'-y', '-y',
'-i', f'{tmp_file_path}', '-i', f'{tmp_file_path}',
'-i', 'chapters.txt', '-i', f'{chapters_txt_path}',
*cover_image_args, *cover_image_args,
'-map', '0', '-map', '0',
'-map_metadata', '1', '-map_metadata', '1',