Worker: pass input frame rate to FFmpeg when converting frames to video

FFmpeg needs the input frame rate as well, otherwise it'll default to 25
FPS, and mysteriously drop frames when rendering a 24 FPS shot.
This commit is contained in:
Sybren A. Stüvel 2022-07-19 18:40:58 +02:00
parent de80a09223
commit d553ca5ab9
2 changed files with 6 additions and 2 deletions

View File

@ -214,6 +214,9 @@ func (p *CreateVideoParams) getInputGlob() ([]string, func(), error) {
} }
cliArgs := []string{ cliArgs := []string{
// FFmpeg needs the input frame rate as well, otherwise it'll default to 25
// FPS, and mysteriously drop frames when rendering a 24 FPS shot.
"-r", strconv.FormatFloat(p.fps, 'f', -1, 64),
"-pattern_type", "glob", "-pattern_type", "glob",
"-i", crosspath.ToSlash(p.inputGlob), "-i", crosspath.ToSlash(p.inputGlob),
} }

View File

@ -42,10 +42,11 @@ func TestCmdFramesToVideoSimplePosix(t *testing.T) {
cliArgs := []string{ cliArgs := []string{
"-v", "quiet", // exe "-v", "quiet", // exe
"-report", // argsBefore "-report", // argsBefore
"-r", "10", // input frame rate
"-pattern_type", "glob", "-i", "path/to/renders/*.png", // inputGlob "-pattern_type", "glob", "-i", "path/to/renders/*.png", // inputGlob
"-c:v", "hevc", "-crf", "31", "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2", // args "-c:v", "hevc", "-crf", "31", "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2", // args
"-r", "10", // fps "-r", "10", // output frame rate
"path/to/renders/preview.mkv", // outputFile "path/to/renders/preview.mkv", // outputFile
} }
mocks.cli.EXPECT().CommandContext(gomock.Any(), "/path/to/ffmpeg", cliArgs).Return(nil) mocks.cli.EXPECT().CommandContext(gomock.Any(), "/path/to/ffmpeg", cliArgs).Return(nil)