Supplying a relative output directory "-o <relative_path>" breaks ffmpeg wav concatenation
root@reed-H670M-ITX-ax:/media/hdd/audiblez# nice audiblez -v af_heart -o Dave "Dave.epub"
Found cover image cover.jpg in image/jpeg format
Not easy to recognize the chapters, defaulting to all non-empty documents.
# Chapter Text Length Selected First words
--- ----------------------------------- ------------- ---------- ---------------------
1 text/9780062484406_Dedication.xhtml 121 ✅ This is the Starfish…
2 text/titlepage.xhtml 0
Started at: 10:20:44
Total characters: 121
Total words: 22
Estimated time remaining (assuming 50 chars/sec): 00d 00h 00m 02s
Using espeak library: /usr/lib/x86_64-linux-gnu/libespeak-ng.so.1
Estimated time remaining: 00d 00h 00m 01s
Progress: 28%
Estimated time remaining: 00d 00h 00m 01s
Progress: 56%
Estimated time remaining: 00d 00h 00m 00s
Progress: 102%
Estimated time remaining: 00d 00h 00m 00s
Progress: 127%
Estimated time remaining: 00d 00h 00m 00s
Progress: 128%
Chapter written to Dave/Dave_chapter_1_af_heart_text_9780062484406_Dedication.xhtml.wav
Chapter 1 read in 3.24 seconds (48 characters per second)
[concat @ 0x5c847d543080] Impossible to open 'Dave/Dave/Dave_chapter_1_af_heart_text_9780062484406_Dedication.xhtml.wav'
[in#0 @ 0x5c847d542d80] Error opening input: No such file or directory
Error opening input file Dave/Dave_wav_list.txt.
Error opening input files: No such file or directory
Creating M4B file...
[in#0 @ 0x5a1fe2742fc0] Error opening input: No such file or directory
Error opening input file Dave/Dave.tmp.mp4.
Error opening input files: No such file or directory
Traceback (most recent call last):
File "/usr/local/bin/audiblez", line 7, in <module>
sys.exit(cli_main())
^^^^^^^^^^
File "/root/audiblez/audiblez/cli.py", line 39, in cli_main
main(args.epub_file_path, args.voice, args.pick, args.speed, args.output)
File "/root/audiblez/audiblez/core.py", line 158, in main
create_m4b(chapter_wav_files, filename, cover_image, output_folder)
File "/root/audiblez/audiblez/core.py", line 348, in create_m4b
Path(concat_file_path).unlink()
File "/usr/local/python3.12/lib/python3.12/pathlib.py", line 1342, in unlink
os.unlink(self)
FileNotFoundError: [Errno 2] No such file or directory: 'Dave/Dave.tmp.mp4'
root@reed-H670M-ITX-ax:/media/hdd/audiblez# This is caused by using a relative path "Path(output_folder)" for ffmpeg which then cannot find the file ("Error opening input: No such file or directory":
chapter_wav_path = Path(output_folder) / filename.replace(extension, f'_chapter_{i}_{voice}_{xhtml_file_name}.wav')
To resolve, convert "Path(output_folder)" to an absolute path with ".resolve()":
chapter_wav_path = Path(output_folder).resolve() / filename.replace(extension, f'_chapter_{i}_{voice}_{xhtml_file_name}.wav')
This then allows ffmpeg to work properly. Maybe a better way to fix would be to resolve the path to an absolute path at the beginning of the main function which would ensure this can't happen anywhere else downstream in the function.
Source: santinic/audiblez