Your script has fps=1
in the filter section, but still has -r 24
later on, which means “frame rate 24fps”. These two lines are in conflict with each other. They should be set to the same thing.
The reason I chose 24 is because YouTube sometimes has problems with videos that are lower than 8fps. File size is not a concern even at 24fps because compression is so good on static images. May as well play it safe and avoid unnecessary problems.
Yes, with a second FOR statement that scans for PNG files. Put all of this into a batch file:
@Echo Off
SetLocal EnableExtensions EnableDelayedExpansion
For /R %%F In (*.flac) Do (
Call :FirstPNG "%%~dpF"
ffmpeg ^
-loop true -i "!_FirstPNG!" ^
-i "%%F" ^
-map 0:v:0 -map 1:a:0 -shortest ^
-filter:v fps=24,scale=out_color_matrix=bt709:out_range=mpeg,format=yuv420p ^
-pix_fmt yuv420p -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range mpeg ^
-r 24 -vsync cfr ^
-c:v libx264 -crf 27 -g 120 -bf 0 -preset veryfast -movflags +faststart+write_colr ^
-c:a alac ^
-f mp4 ^
-y ^
"Output\%%~nF.mp4"
)
rem Cleanup
Set _FirstPNG=
EndLocal
Exit /B 0
rem Subroutine to get first PNG in folder
:FirstPNG
For %%P In ("%~1*.png") Do (
Set _FirstPNG=%%P
GoTo :EOF
)
Notice the change from %VAR%
to !VAR!
in the ffmpeg call, which returns the run-time value of a variable rather than the parse-time value. More information about this can be found by typing help set
at a Command Prompt.
The idea was to provide YouTube with the original FLAC for maximum quality. YouTube accepts FLAC in MKV. But FLAC cannot go into MP4. Since you prefer MP4, I changed the audio codec to ALAC (Apple Lossless) using -c:a alac
and changed the output filename to an MP4 extension. This should keep audio quality extremely high rather than transcoding to AC-3, or worse, AAC.
This is explained very clearly in the help for
documentation at a Command Prompt. In a batch file, the percent character is used to mark a variable name. To use a file-cursor variable within a FOR statement, use an escaped percent sign, such as For %%F In (*.flac) Do ...
The easiest way is to make all the individual image/audio MKV or MP4 files first. Then dump all the individual track filenames into a text file like this:
cd Output
dir /b *.mp4 > filelist.txt
Then use that filelist.txt to invoke ffmpeg’s concat
muxer which basically stitches a bunch of videos together into one huge output video, with the obvious caveat being that all input videos must be of the same format.
See more about using concat
here:
If cover art changing is a problem, then the alternative is to concat
all the FLAC files together into one giant FLAC file, then use the original ffmpeg command to put a single artwork on the giant FLAC file.