bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.45k stars 1.57k forks source link

how to change frame rate and keep duration unchanged #2034

Closed Snow-Chen closed 1 year ago

Snow-Chen commented 1 year ago

Hi, I use FFmpegFrameGrabber to grabber frame from flv stream address like "http://xxx.flv” then try to record frame and save to local mp4 file by FFmpegFrameRecoder

how can i change the fps from 30/s to 10/s, and keep the duration unchanged at same time In other words, i want keep aduio stream and drop 2/3 frames of image stream

I have tried FFmpegFrameRecoder.setFrameRate(10); however the duration of mp4 is tripled of flv

saudet commented 1 year ago

We can use the fps filter with FFmpegFrameFilter for that purpose: https://ffmpeg.org/ffmpeg-filters.html#fps-1

saudet commented 1 year ago

You can refer to issue https://github.com/bytedeco/javacv/issues/1398#issuecomment-613208633 for a working example.