Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of temporary files ffmpeg is hardcoded to fixed commandline (ultrafast etc.) #16

Closed
jedcooper opened this issue Sep 12, 2023 · 4 comments

Comments

@jedcooper
Copy link

jedcooper commented Sep 12, 2023

As title. So the general settings for ffmpeg commandline is obsolete. As I don't think it's intentionally I file this as an issue.
For example I'm using: "output_parameters": "-preset p7 -tune hq -profile:v high -multipass qres -rc vbr -cq 16 -qmin 16 -qmax 16 -b:v 0k", along with "output_codec": "h264_nvenc",
which is working fine working without temporary files for 3-4 pictures.
But with a bigger pictures count it soon gets out of memory (log shows FFMPEG cancel) so using temporary files gets mandatory and - as said - user's custom ffmpeg quality commandline obsolete, unfortunately.

In slideshow/Queue.py: snippet.txt

@Trekky12
Copy link
Owner

Trekky12 commented Sep 12, 2023

Could you please explain this in more detail? Indeed the ffmpeg command needs high ressources without temporary files. So for many slides it is recommended to use the temporary files option.

The ffmpeg command for the temporary files is optimized for speed. Nevertheless the general settings are used for the final video creation

def getFinalVideoCommand(self, output_file, burnSubtitles, srtInput,
srtFilename, inputs, temp_filter_script, overwrite=False):
cmd = [self.config["ffmpeg"],
"-hide_banner",
# "-v quiet",
"-stats",
"-y" if overwrite else "",
# slides
" ".join(["-i \"%s\" " % (f) for f in inputs]),
" ".join(["-i \"%s\" " % (track.file) for track in self.getBackgroundTracks()]),
# subtitles (only mkv)
"-i %s" % (srtFilename) if self.hasSubtitles() and not burnSubtitles else "",
# filters
"-filter_complex_script \"%s\"" % (temp_filter_script),
# define duration
# if video should be loopable, skip the start fade-in (-ss) and the end fade-out
# (video is stopped after the fade-in of the last image which is the same as the first-image)
"-ss %s -t %s" % (self.getSlideFadeOutDuration(0) / self.config["fps"], self.getOffset(-1, False))
if self.config["loopable"] else "-t %s" % (self.getTotalDuration()),
# "-t %s" % (self.getTotalDuration()),
# define output
"-map", "[out]:v",
"-c:v %s" % (self.config["output_codec"]) if self.config["output_codec"] else "",
# "-crf", "0" ,
# "-preset", "ultrafast",
# "-tune", "stillimage",
self.config["output_parameters"],
"-map [aout]:a" if self.hasAudio() else "",
# audio compression and bitrate
"-c:a aac" if self.hasAudio() else "",
"-b:a 160k" if self.hasAudio() else "",
# map subtitles (only mkv)
"-map %s:s" % (srtInput) if self.hasSubtitles() and not burnSubtitles else "",
# set subtitles enabled (only mkv)
"-disposition:s:s:0 default" if self.hasSubtitles() and not burnSubtitles else "",
"\"%s\"" % (output_file)
]
return cmd

@jedcooper
Copy link
Author

jedcooper commented Sep 12, 2023

Hello, first thank you for your effort making this software! Appreciated! :D

Encoding with user setting be it speed or quality, your method using temporary files renders user quality/commandline obsolete.
The temp files created by hardcoded "-preset ultrafast" are always worse in quality and final reencoded in user commandline quality which can't be in good quality anymore, because the source (temp files) are of "ultrafast/quick quality" and not the user set quality (or better).

The source has to be same or better quality than target. This is not the case with your hardcoded "-preset ultrafast", default bitrate etc. for temporary files, if the user wants more quality than "ultrafast" and default bitrate.

I'd strongly recommend creating lossless or near lossless quality temporary files. You've had something in mind yet I guess with commented CRF = 0.

I don't know how to link code from Queue.py here. Therefore I put a snippet.txt in OP. It contains the hardcoded always same "-preset ultrafast" quality temporary file generation.

What else do you need to know in detail?

@Trekky12
Copy link
Owner

You are right, I will look into it and maybe add a new setting field for the temporary files creation.

Feel free to add a PR for this feature.

@Trekky12
Copy link
Owner

Trekky12 commented Oct 1, 2023

@jedcooper Could you please test the source from the latest development branch?

@Trekky12 Trekky12 closed this as completed Oct 1, 2023
@Trekky12 Trekky12 reopened this Oct 1, 2023
@Trekky12 Trekky12 closed this as completed Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants