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

Fix bug on vflip filter #977

Merged
merged 1 commit into from
Apr 30, 2018
Merged

Fix bug on vflip filter #977

merged 1 commit into from
Apr 30, 2018

Conversation

SIY1121
Copy link
Contributor

@SIY1121 SIY1121 commented Apr 27, 2018

Fixed a bug on using vfilter.

@saudet
Copy link
Member

saudet commented Apr 28, 2018

I think the correct fix for that would be to change frame.imageStride = filt_frame.linesize(0) to frame.imageStride = Math.abs(filt_frame.linesize(0)). Though, does that work?

@SIY1121
Copy link
Contributor Author

SIY1121 commented Apr 28, 2018

You have got a point.

In fact, I corrected frame.imageStride = filt_frame.linesize(0) to frame.imageStride = Math.abs(filt_frame.linesize(0)) first. But it didn't work.

To be exact, jvm crashed when I pushed the frame to FFmpegFrameRecorder.
Here is a simple code I tested:

        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("in.mp4");
        grabber.start();

        FFmpegFrameFilter filter = new FFmpegFrameFilter("vflip", grabber.getImageWidth(), grabber.getImageHeight());
        filter.start();

        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(new File("out.mp4"), grabber.getImageWidth(), grabber.getImageHeight());
        recorder.setFrameRate(grabber.getFrameRate());
        recorder.start();

        while (true) {
            Frame frame = grabber.grabImage();
            if (frame == null) break;
            filter.push(frame);
            recorder.record(filter.pull());
        }

        grabber.stop();
        filter.stop();
        recorder.stop();

and error log:
hs_err_pid6300.log

First of all, I think behavior of returning a negative stride is not bug on ffmpeg.
I found a article about the negative stride.

I'm not good at ffmpeg, but making image stride negative seems to be one of vflip processes.
Also I think you musn't modify frame data from outside ffmpeg because it can cause crashes like above.

@saudet saudet merged commit 8ab52b7 into bytedeco:master Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants