SIPSorceryMedia.FFmpeg icon indicating copy to clipboard operation
SIPSorceryMedia.FFmpeg copied to clipboard

Changing MP4 fps

Open HighOnLemonz opened this issue 10 months ago • 1 comments

Hello, I wish to change the fps of a local MP4 to a desired value between 10-60. The video is recorded in 60 fps so that is the default.

Code is simple:

FFmpegFileSource mediaFileSource = new(streamPath, true, null); mediaFileSource.RestrictFormats(x => x.Codec == VideoCodecsEnum.H264); _peerConnection.OnVideoFormatsNegotiated += (videoFormat) => mediaFileSource.SetVideoSourceFormat(videoFormat.First()); mediaFileSource.OnVideoSourceEncodedSample += _peerConnection.SendVideo; mediaFileSource.Start();

I saw an old issue regarding this but it was changing the framerate of a VideoTestPatternSource. I did not find how to "load" the video in this class to have access to the SetFrameRate() method.

Another idea that came to me was to add code in the OnVideoSourceEncodedSample before SendVideo(). I am not sure of the impact of delaying SendVideo() with regards to the event.

Is there an easier way of doing this? Thank you

HighOnLemonz avatar Jan 22 '25 09:01 HighOnLemonz

In theory the frame rate is being taken from the video stream in the mp4 file via FFmpeg.

If you want to manually adjust that rate there is currently no property exposed to do that. What you'd need to do is bubble the _videoAvgFrameRate up to the public API which shouldn't be too hard and would be a useful addition if you're up for creating a PR.

sipsorcery avatar Jan 22 '25 20:01 sipsorcery