bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.58k stars 1.58k forks source link

Motion blur to make animation less jerky With FFmpegFrameRecorder in android #1291

Open ZeroOneZeroR opened 5 years ago

ZeroOneZeroR commented 5 years ago

Is there any way to do this?

saudet commented 5 years ago

It looks like there is a filter for this, yes: https://ffmpeg.org/ffmpeg-filters.html#minterpolate

ZeroOneZeroR commented 5 years ago

I want to move an object from 0 to 700 pixel position and capture the bitmap and record video with 30 frame rate. But moving seems so jerky with 30 fps. But it is so smooth with 60 fps. But i want 30. How to overcome this situation?

saudet commented 5 years ago

Motion blur seems like a fine way to achieve that, yes.

ZeroOneZeroR commented 5 years ago

Will i have to use FFmpegFrameFilter to use mininterpolate?

saudet commented 5 years ago

Yes, something like that: https://github.com/bytedeco/javacv/blob/master/samples/DeinterlacedVideoPlayer.java If you just need to process files though, the ffmpeg program is probably easier to use: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

ZeroOneZeroR commented 5 years ago

I want first kind.

ZeroOneZeroR commented 5 years ago

I use like this . But app crash while pushing and for the 3rd time without giving error message `FFmpegFrameFilter filter = new FFmpegFrameFilter("minterpolate=60,tblend=all_mode=average,framestep=2", videoWidth, videoHeight); filter.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); filter.start();

                filter.push( videoFrame );
                videoFrame = filter.pull();`
ZeroOneZeroR commented 5 years ago

It gives "Changing frame properties on the fly is not supported by all filters." after FFmpegLogCallback.set();

saudet commented 5 years ago

That means you'll need to set the pixel format of your frames before calling start().

ZeroOneZeroR commented 5 years ago

i have set filter.setPixelFormat(avutil.AV_PIX_FMT_YUV420P) before starting

saudet commented 5 years ago

Your frames have a different pixel format, but if you're sure that's correct, pass it to push() as well.

ZeroOneZeroR commented 5 years ago

if i set frame rate 60 to recorder and set "minterpolate=60,tblend=all_mode=average,framestep=2" fas filter then no crash occurs but video is only green frame and video size is half of expected... i think i am not getting how the filter should be used. Could you please explain to me?

saudet commented 5 years ago

You'll need to set the pixel format of your frames, or it won't work properly!

ZeroOneZeroR commented 5 years ago

after setting pixel format when pushing crash disappears but output video is scewed and so far from my expectation.....

ZeroOneZeroR commented 5 years ago

i think i am not using the filters in correct way....

ZeroOneZeroR commented 5 years ago

Now there is no crash .You just tell why the video is skewed and many lines of different colours are on the video.

ZeroOneZeroR commented 5 years ago

using AV_PIX_FMT_BGR24 video content becomes triple.