remotion
remotion copied to clipboard
getVideoMetadata: Obtain FPS
First of all, big thanks for creating Remotion! It's awesome! 🥳
Feature Request 🛍️
We have a utility function for getting video metadata- can we expand this to include the FPS?
Use Case
I want to take a source video of arbitrary resolution, duration, and FPS and add some overlays to it. This means a composition that loads in the source video via the Video
component, and adds some Sequence
s that appear over the top of it.
I can use getVideoMetadata
to get the source video dimensions and duration in seconds, but not the FPS. I can hardcode a different FPS for the composition, but ideally want to retain the original properties of the source video.
Possible Solution
getVideoMetadata
is just a utility to access the metadata exposed from the loadedmetadata
event of a video
element, which does not include the FPS. It seems like we can't retrieve the FPS of a loaded video via browser APIs, but maybe I'm wrong.
We could add some integration with ffmpeg
to retrieve the FPS of a local video (see: https://askubuntu.com/questions/110264/how-to-find-frames-per-second-of-any-video-file), however it feels like this shouldn't be part of getVideoMetadata
due to not being able to work for remote videos.
Thoughts:
- Is there a place for such a utility within Remotion? Should this FPS check just happen outside of the library (and the FPS could be passed in via props)?
- If it could live within Remotion, how do you see it working and where would it live?
- I've thought about this in a very limited way specific to my use case- there may be factors involving SSR/Preview/CLI rendering I haven't considered or come across yet.
I'm happy to investigate and do the work with a bit of guidance on how the solution should look/work.
Hi Tom!
Thanks for the thoughtful issue! I see it similarly as you. It would be useful, but I would not add it to @remotion/media-utils which at the moment is a lightweight package with no dependencies.
To get the FPS, we would make another package (maybe: https://mediainfo.js.org/, maybe: FFMPEG.wasm). I think the API could still be similar to getVideoMetadata
.
Important for us is that documentation is added and the code is functional and written in Typescript. I would recommend looking at the CONTRIBUTING.md to get started, and start with a draft PR, I would also occasionally work on it and give guidance whenever needed 😊
Is there an existing CLI tool that can find FPS? If so, then use Node to call or CLI script & pipe to text file.
On Linux I use this to determine FPS: ffprobe out.mp4 2>&1 | grep fps
You can now use https://www.remotion.dev/docs/renderer/get-video-metadata (this is not the same API as the browser-based getVideoMetadata()
) to determine the FPS on the server programmatically!