Describe the bug
When exporting a tape to .mp4 and using the Set Framerate command (example Set Framerate 50), the resulting video is still encoded at 25 fps. This happens regardless of the framerate set in the tape file.
I dug into the source and it seems to be caused by two things in the ffmpeg pipeline:
- If you use a
MarginFill color, WithMargin() creates the background using ffmpeg's lavfi color filter (color=%s:s=%dx%d). Since no rate is passed, lavfi defaults to 25 fps. Because this 25fps stream is used as the base for the overlay filter, ffmpeg forces the entire output video to match that 25fps.
- Even without a margin, the final ffmpeg command built in
video.go is missing an explicit -r <framerate> flag right before the output file. Without it, libx264 often just falls back to 25fps anyway.
Setup
- OS: Linux
- Shell: bash
- Terminal Emulator: N/A (VHS rendering)
- Terminal Multiplexer: N/A
To Reproduce
Steps to reproduce the behavior:
- Create a tape file with
Output demo.mp4 and Set Framerate 50 (or 60).
- Run
vhs demo.tape.
- Check the framerate of the resulting video using
ffprobe demo.mp4.
- See that the video is
25 fps instead of 50.
Source Code
Output demo.mp4
Set Framerate 50
Set Margin 20
Set MarginFill "#000000"
Type "echo hello"
Enter
Sleep 1s
Describe the bug
When exporting a tape to
.mp4and using theSet Frameratecommand (exampleSet Framerate 50), the resulting video is still encoded at 25 fps. This happens regardless of the framerate set in the tape file.I dug into the source and it seems to be caused by two things in the ffmpeg pipeline:
MarginFillcolor,WithMargin()creates the background using ffmpeg'slavficolor filter (color=%s:s=%dx%d). Since norateis passed, lavfi defaults to 25 fps. Because this 25fps stream is used as the base for theoverlayfilter, ffmpeg forces the entire output video to match that 25fps.video.gois missing an explicit-r <framerate>flag right before the output file. Without it,libx264often just falls back to 25fps anyway.Setup
To Reproduce
Steps to reproduce the behavior:
Output demo.mp4andSet Framerate 50(or 60).vhs demo.tape.ffprobe demo.mp4.25 fpsinstead of 50.Source Code