Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add frame rate to VideoEncoder API#1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Dan-Flores wants to merge2 commits intometa-pytorch:main
base:main
Choose a base branch
Loading
fromDan-Flores:output_frame_rate_encode_option

Conversation

@Dan-Flores
Copy link
Contributor

This PR adds outputframe_rate to the API.

Previously, we always encoded videos using the sameframe_rate as the inputframes.

Now, we can set the outputframe_rate when callingto_file/to_tensor/to_filelike (as inAudioEncoder), to adjusts the encoded video's frame durations. If no outputframe_rate is specified, fallback to reusing the inputframe_rate.

Testing:

To test, I addedtest_frame_rate_parameter which slows and speeds up a test video and ensures the video metadata is updated correctly. I also observed the video plays back slower or faster.

API after changes:

The complete API now looks as follows:

  encoder = VideoEncoder(frames=frames, frame_rate=25)  encoder.to_file(      dest="video.mp4",      codec="libx264",      pixel_format="yuv420p",      crf=20,      preset="medium",      extra_options={"tune": "fastdecode","x264-params": "deblock=-1,-1:aq-mode=2  },      frame_rate=25,  )

@meta-clameta-clabot added the CLA SignedThis label is managed by the Meta Open Source bot. labelNov 14, 2025
pixel_format:Optional[str]=None,
crf:Optional[Union[int,float]]=None,
preset:Optional[Union[str,int]]=None,
frame_rate:Optional[int]=None,
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm happy to bikeshed on parameter order.sample_rate is the last param inAudioEncoder, but that constructor is much smaller. Here, having it last might makeframe_rate less discoverable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

My views:

  1. Optional parameters should always be keyword-only.
  2. codec should be the first keyword-only parameter, as it's likely to be the most used.
  3. extra_options should be the last keyword-only parameter, as "catch-all" parameters tend to be last.

I don't have a preference for the order of the rest. 🚲 🛖 !

NicolasHug reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I didn't realizeextra_options wasn't keyword-only, sorry for not catching that earlier. Let's make it keyword-only and keep it as the last parameter (it's probably going to be the least used param).frame_rate can go anywhere betweencodec andextra_options

Copy link
Contributor

@NicolasHugNicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the PR@Dan-Flores !

I think there are different ways to adjust the frame rate: in this PR we're keeping the frames exactly as they are and we adjust their duration. Effectively if the input video is 1 min long and we ask for twice the frame rate, then we just halved the video duration to 30s, so it's running at twice the speed.

I'm not entirely sure this is what we want - I think generally users would expect the same output duration and some frames to be duplicated, dropped, or potentially interpolated in their temporal dimension.

Adding outputsample_rate support to the audio encoder was pretty hard, it involved internal FIFOs etc. I suspect adding outputframe_rate support will be similarly difficult, at the very least we'll have to figure out what the FFmpeg CLI does and reproduce that.

I'd suggest to hold off for now. I think the features we have in the encoder are already fairly complete, we can leave that as future improvement!

Dan-Flores reacted with thumbs up emoji
@NicolasHugNicolasHug mentioned this pull requestNov 17, 2025
@Dan-FloresDan-Flores marked this pull request as draftNovember 17, 2025 14:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@scottsscottsscotts left review comments

@NicolasHugNicolasHugNicolasHug left review comments

Assignees

No one assigned

Labels

CLA SignedThis label is managed by the Meta Open Source bot.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@Dan-Flores@scotts@NicolasHug

[8]ページ先頭

©2009-2025 Movatter.jp