Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFmpegFrameFilter does not work. #667

Closed
ninyess opened this issue Apr 7, 2017 · 18 comments
Closed

FFmpegFrameFilter does not work. #667

ninyess opened this issue Apr 7, 2017 · 18 comments

Comments

@ninyess
Copy link

ninyess commented Apr 7, 2017

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.

@saudet
Copy link
Member

saudet commented Apr 7, 2017 via email

@ninyess
Copy link
Author

ninyess commented Apr 7, 2017

Sorry @saudet .
I will check this out.

@saudet
Copy link
Member

saudet commented Apr 15, 2017

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

@ninyess
Copy link
Author

ninyess commented Apr 15, 2017

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.

@saudet
Copy link
Member

saudet commented Apr 15, 2017

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!

@ninyess
Copy link
Author

ninyess commented Apr 15, 2017

Yes, I will.
Thanks too!!!

@joaonogueira-hotmart
Copy link

@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.

@ninyess
Copy link
Author

ninyess commented May 1, 2017

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

@fpv999
Copy link

fpv999 commented Nov 30, 2017

It still does not work!!

@saudet
Copy link
Member

saudet commented Jan 18, 2018

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!

@ninyess
Copy link
Author

ninyess commented Jan 18, 2018

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

@supportMyScoopApp
Copy link

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

@saudet
Copy link
Member

saudet commented Feb 24, 2018

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()) 

@saudet saudet closed this as completed Feb 24, 2018
@supportMyScoopApp
Copy link

supportMyScoopApp commented Feb 25, 2018

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.

@saudet
Copy link
Member

saudet commented Feb 25, 2018

@saudet
Copy link
Member

saudet commented Feb 25, 2018

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

@saudet saudet added the bug label Mar 31, 2018
saudet added a commit that referenced this issue Mar 31, 2018
…`overlay` filters behave as expected ([issue #667](#667))

 * Fix crash on `FFmpegFrameRecorder.stop()` when no audio samples are left to write
@saudet
Copy link
Member

saudet commented Mar 31, 2018

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

@ninyess
Copy link
Author

ninyess commented Apr 13, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants