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

How to release resources #455

Open
hnuuhc opened this issue Oct 26, 2022 · 1 comment
Open

How to release resources #455

hnuuhc opened this issue Oct 26, 2022 · 1 comment

Comments

@hnuuhc
Copy link

hnuuhc commented Oct 26, 2022

Code:

public static boolean audioVideoMerge(@NotNull String audio, @NotNull String video, @NotNull String output) {
		boolean success = false;
		try (FileOutputStream fos = new FileOutputStream(output); 
                            DataSource videoDataSource = new FileDataSourceImpl(video); 
                            DataSource audioDataSource = new FileDataSourceImpl(audio)) {
			Movie countVideo = MovieCreator.build(videoDataSource);
			MovieCreator.build(audioDataSource).getTracks().forEach(countVideo::addTrack);
			Container out = new FragmentedMp4Builder().build(countVideo);
			out.writeContainer(fos.getChannel());
			success = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		new File(audio).delete();
                new File(video).delete();
		return success;
}

Result:
audio file exists
video file exists

Is this a bug?
Must use System.gc() and wait time to delete.

@tiro8183
Copy link

I had the same problem

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

No branches or pull requests

2 participants