Javacv: FFmpegFrameFilter does not work.

Created on 7 Apr 2017  路  18Comments  路  Source: bytedeco/javacv

Hi @saudet!

I have a problem...again.
FFmpegFrameFilter does not work in javacv 1.3.2.

my source

//mWatermarkPath is image's physical path
String filterString = ("movie=" + mWatermarkPath + " [logo]; [in] [logo] overlay=0:0:1:format=rgb [out]");
mFilter = new FFmpegFrameFilter(filterString, PREVIEW_WIDTH, PREVIEW_HEIGHT);
mFilter.setPixelFormat(avutil.AV_PIX_FMT_NV21);

try {
        mFilter.start();
} catch (FrameFilter.Exception e) {
        e.printStackTrace();
}

//Camera onPreviewFrame
public void onPreviewFrame(byte[] data, Camera camera) {
   long t = 1000 * (System.currentTimeMillis() - mStartTime);
   if (t > mRecorder.getTimestamp()) {
      mRecorder.setTimestamp(t);
   }

   try {
            Frame tempFrame;
            mFilter.push(mFrame);

           while ((tempFrame = mFilter.pull()) != null) {
               mRecorder.record(tempFrame);
           }

   } catch (FrameRecorder.Exception | FrameFilter.Exception e) {
      e.printStackTrace();
   }
}

I tested with the same environment, the same code, and only changed the version of javacv.

version 1.2
https://www.youtube.com/watch?v=1ZUOEXSLWQY

version 1.3.2
https://www.youtube.com/watch?v=ZQbA8G7QCVI

Thanks.

bug duplicate enhancement

All 18 comments

Are you sure this is caused by newer JavaCV and not newer FFmpeg? How did you confirm?

Sorry @saudet .
I will check this out.

Could you also let me know if this happens only on Android? Or does the same thing happen on other platforms as well?

Unfortunately, I could not tested it on other platforms. If I'm going to test on a different platform, I'll comment.
anyway... I've been testing it using other ffmpeg commands, but I have not been able to fix it yet.

ps. I can not speak English well and it may be awkward sentences or rude. I apologize.

Your English is fine, don't worry :)

I'm not expecting you to fix this by yourself, but it would help to get more information, so please post anything you find. Thanks a lot!

Yes, I will.
Thanks too!!!

@ninyess have you found any solution? I am strugling to implement video filter using image overlay.
I manage to do converting Frame to Bitmap and manipulating the bitmap, but it takes 40min for a 3min video.

Hi @joaonh. Sorry for the delay.
I have not solved this problem yet.
But... I think your issue is a little different from me.

It still does not work!!

I've just released JavaCV 1.4, which is based on FFmpeg 3.4.1. Does the issue persist? If it does, could someone please report this bug upstream so they can fix it? Thanks!

It does not work yet. It seems to be a problem with ffmpeg commands rather than javacv.

I get the same issues after upgrade to newest version. Did someone fix it?

This is most likely a duplicate of issue #887. Use version 1.4.1-SNAPSHOT and call something like this:

recorder.record(filteredFrame, frameFilter.getPixelFormat()) 

Hi @saudet, I did not get version 1.4.1-SNAPSHOT.

compile group: 'org.bytedeco', name: 'javacv', version: '1.4.1-SNAPSHOT'        
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: ' 3.4.1-1.4', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.0-1.4', classifier: 'android-arm' 

Error:Failed to resolve: org.bytedeco:javacv:1.4.1-SNAPSHOT

Btw, Can I add a png Mat to another Mat?
opencv_core.Mat input = opencv_imgcodecs.imread(Environment.getExternalStorageDirectory() + "/overlay1.png");
It only a black instead of transparent when i use png.

OpenCV doesn't support alpha channels. Use Java 2D, or in your case Android Graphics.

This has actually been fixed with commit https://github.com/bytedeco/javacv/commit/35dd7f8134ff4b31e6ff94ab6049f2a13418cc5a so please give it a try with JavaCV 1.4.2-SNAPSHOT: http://bytedeco.org/builds/

Still cares thank you for this issue.
I will test and comment soon. THANK YOU.

Was this page helpful?
0 / 5 - 0 ratings