ralfbiedert / openh264-rs

Idiomatic Rust wrappers around OpenH264.
66 stars 32 forks source link

How can I encode with constant fps? #33

Closed hanguk0726 closed 1 year ago

hanguk0726 commented 1 year ago

It seems that the default fps is set to approximately 30, but not exactly. I tried setting a specific frame count, but when I opened the resulting h264 file with a video player, the playtime was shorter than expected. I was expecting the video to be 1 hour long if the fps was 30, but the resulting h264 file with 108,000 frames had a playtime of only 59 minutes and 53 seconds.

I tried several options such as changing rate control mode, setting a maximum frame rate of 30.0, and disabling skip frames, but I still can't accurately predict the playtime of the resulting video. The missing seconds make it very difficult for me to sync the audio. Can I get some advice?

ralfbiedert commented 1 year ago

Unfortunately I don't have much experience with playing .h264 files directly, at least in MP4 the frame time comes from the container IIRC. There is a chance that your frame rate is just "randomly" set by your player in absence of any further frame timing information, but YMMV.