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

Is it possible to use a DocumentFile or outputstream for FFmpegFrameRecorder on Android? #427

Closed
pgfsim opened this issue Jun 2, 2016 · 1 comment

Comments

@pgfsim
Copy link

pgfsim commented Jun 2, 2016

I am able to create a video from images by initialising the recorder with a video location to save to, and a video height and width. recorder = new FFmpegFrameRecorder(videosavelocation, reswidth, resheight);

This works perfectly for internal storage, but I'm now interested in saving to the SD card. I'm able to get read/write access by using the Storage Access Framework. However, the issue is you can't use java.io.File to access the SD card, you must use DocumentFile.

If I use getUri().toString() or getUri().getPath() FFmpeg expectedly can't open it:
W/System.err: org.bytedeco.javacv.FrameRecorder$Exception: avio_open error() error -1330794744: Could not open 'content://com.android.externalstorage.documents/tree/3163-6261%3A/%2Fmyvideo.mp4

I can create an empty mp4 file on the SD card like so, with a DocumentFile:

 DocumentFile sdDir = vidsavelocationSD.createFile("video/mp4",videotimeStamp+".mp4");

                try {
                    OutputStream out = getApplicationContext().getContentResolver().openOutputStream(sdDir.getUri());
                    out.write("".getBytes());
                    out.close();

                } catch (IOException e) {
                    e.printStackTrace();
                }

Is there any way to use FFmpegFrameRecorder and be able to save to the SD card?

I'm using the latest javacpp/javacv built from source, and targeting API 23 in my project for android-arm.

@saudet
Copy link
Member

saudet commented Jun 6, 2016

Duplicate of #95. As you can see, it's a frequently requested feature, so it would be very helpful if you could make a contribution. If you run into any problems when implementing it though, let me know! Thanks for your interest

@saudet saudet closed this as completed Jun 6, 2016
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

2 participants