Worker: include -r {fps} in FFmpeg command

This should force the output created by FFmpeg to match the desired FPS.
This commit is contained in:
Sybren A. Stüvel 2022-04-11 12:09:28 +02:00
parent cb494a4c03
commit c79983bafb
2 changed files with 8 additions and 2 deletions

@ -13,6 +13,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"github.com/google/shlex"
@ -185,6 +186,8 @@ func cmdFramesToVideoParams(logger zerolog.Logger, cmd api.Command) (CreateVideo
parameters.exe = exeArgs[0]
parameters.argsBefore = allArgsBefore
}
parameters.args = append(parameters.args,
"-r", strconv.FormatFloat(parameters.fps, 'f', -1, 64))
return parameters, nil
}

@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package worker
import (
@ -12,8 +13,6 @@ import (
"git.blender.org/flamenco/pkg/api"
)
// SPDX-License-Identifier: GPL-3.0-or-later
func TestCmdFramesToVideoSimplePosix(t *testing.T) {
// Windows and non-Windows platforms differ in how they communicate globs to FFmpeg.
if runtime.GOOS == "windows" {
@ -31,6 +30,7 @@ func TestCmdFramesToVideoSimplePosix(t *testing.T) {
"exe": "/path/to/ffmpeg -v quiet",
"argsBefore": []string{"-report"},
"inputGlob": "path/to/renders/*.png",
"fps": 10.0,
"args": []string{
"-c:v", "hevc",
"-crf", "31",
@ -45,6 +45,7 @@ func TestCmdFramesToVideoSimplePosix(t *testing.T) {
"-report", // argsBefore
"-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
"-r", "10", // fps
"path/to/renders/preview.mkv", // outputFile
}
mocks.cli.EXPECT().CommandContext(gomock.Any(), "/path/to/ffmpeg", cliArgs).Return(nil)
@ -70,6 +71,7 @@ func TestCmdFramesToVideoSimpleWindows(t *testing.T) {
"exe": "/path/to/ffmpeg -v quiet",
"argsBefore": []string{"-report"},
"inputGlob": "path/to/renders/*.png",
"fps": 10.0,
"args": []string{
"-c:v", "hevc",
"-crf", "31",
@ -84,6 +86,7 @@ func TestCmdFramesToVideoSimpleWindows(t *testing.T) {
"-report", // argsBefore
"-f", "concat", "-i", "this-is-random.txt", // input glob
"-c:v", "hevc", "-crf", "31", "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2", // args
"-r", "10", // fps
"path/to/renders/preview.mkv", // outputFile
}
mocks.cli.EXPECT().