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

FFmpegFrameRecorder close results in EXCEPTION_ACCESS_VIOLATION/SIGSEGV #1616

Closed
voomdoon opened this issue Mar 31, 2021 · 2 comments
Closed
Labels

Comments

@voomdoon
Copy link

Hi, I am trying to write simple video files (to be used for unit testing of other components reading that files).

example:

import java.awt.image.BufferedImage;

import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.FrameRecorder.Exception;
import org.bytedeco.javacv.Java2DFrameConverter;

public class VideoGenerator {

	private static final int HEIGHT = 48;

	private static final int WIDTH = 64;

	public static void main(String[] args) throws Exception {
		new VideoGenerator().run(args[0]);
	}

	private static BufferedImage getImage(int i) {
		BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
		image.getGraphics().drawString(Integer.toString(i), 10, 10);
		return image;
	}

	private void run(String target) throws Exception {
		FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(target, WIDTH, HEIGHT, 0);

		Java2DFrameConverter converter = new Java2DFrameConverter();

		recorder.start();

		for (int i = 0; i < 1000; i++) {
			recorder.record(converter.convert(getImage(i)));
		}

		System.out.println("flush...");
		recorder.flush();
		System.out.println("close...");
		recorder.close();
		System.out.println("done");
	}
}

the file gets written and is readable, but JVM crashes during close (done is not printed):

  • EXCEPTION_ACCESS_VIOLATION on Windows 10 (avformat-58.dll+0xd9ae7)
  • SIGSEGV on Ubuntu (libavformat.so.58+0x15a64c)

dependencies:

<dependency>
	<groupId>org.bytedeco</groupId>
	<artifactId>javacv</artifactId>
	<version>[1.5.5,1.6)</version>
</dependency>
<dependency>
	<groupId>org.bytedeco</groupId>
	<artifactId>javacv-platform</artifactId>
	<version>[1.5.5,1.6)</version>
</dependency>
@saudet saudet added the bug label Apr 1, 2021
saudet added a commit that referenced this issue Apr 1, 2021
…ailer()` out of `flush()` (issue #1616)

 * Upgrade dependencies for OpenBLAS 0.3.14
@saudet
Copy link
Member

saudet commented Apr 1, 2021

I see what's going on. It's crashing in av_write_trailer() since that "frees the file private data", which means it can't be called twice. I've fixed that in commit e265c82, but we can still get this working correctly with JavaCV 1.5.5 by simply omitting the explicit call to flush(), which gets called in stop() anyway. Thanks for reporting!

@saudet
Copy link
Member

saudet commented Aug 3, 2021

Fix included in JavaCV 1.5.6. Enjoy!

@saudet saudet closed this as completed Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants