Kethsar / ytarchive

Garbage Youtube livestream downloader
MIT License
1.08k stars 87 forks source link

Print ffmpeg command when return code is not 0 #75

Closed ogmacwinux closed 2 years ago

ogmacwinux commented 2 years ago

When for some reason ytarchive fails to mux the files (e.g. disk space isn't enough for processing), it would helpful to print ffmpeg_cmd (like the case when ffmpeg is not installed) so the user can execute it later. E.g.

Download Finished
YYYY/MM/DD HH:MM:SS ERROR: frame=    1 fps=0.0 q=-1.0 size=       <...>

YYYY/MM/DD HH:MM:SS ERROR: Execute returned code 1. Something must have gone wrong with ffmpeg.
YYYY/MM/DD HH:MM:SS ERROR: ***COMMAND THAT WAS BEING RUN***
YYYY/MM/DD HH:MM:SS ERROR: <ffmpeg_cmd>
YYYY/MM/DD HH:MM:SS ERROR: The .ts files will not be deleted in case the final file is broken.
YYYY/MM/DD HH:MM:SS ERROR: Check the issue, then run the above command if the final file is broken.
Press Enter to continue...:

Another way, though perhaps a bit more complicated, would be to check the disk usage before executing ffmpeg_cmd, then prompt the user whether to execute the command now or print the command then manually execute it later. E.g.

Video Fragments: XXXX; Audio Fragments: YYYY; Total Downloaded: 10GiB
Download Finished
YYYY/MM/DD HH:MM:SS ERROR: Cannot mux files. Insufficient disk space.
YYYY/MM/DD HH:MM:SS ERROR: Free up at least 10(+allowance)GiB of space then press y, 
YYYY/MM/DD HH:MM:SS ERROR:  or press n then manually run the command later.
YYYY/MM/DD HH:MM:SS ERROR: Continue? (y/n): 
YYYY/MM/DD HH:MM:SS ERROR: Continue? (y/n): y
Final file: <...>.mp4
Press Enter to continue...:
YYYY/MM/DD HH:MM:SS ERROR: Continue? (y/n): n
The .ts files have not been deleted. Run the ff. command manually to get the final file:
<ffmpeg_cmd>
Press Enter to continue...:
Kethsar commented 2 years ago

Ah yeah that would be a good idea, and an easy change. I already print out the command when the debug flag is enabled so it kinda slipped my mind. I''ll probably go the route of writing the command to a text file first, and outputting to the terminal if that also fails.