2

I'm facing a big problem. I use MediaMuxer to create a mp4 file. Here 's constructor of MediaMuxer:

public MediaMuxer (String path, int format)

For example:

sMediaMuxer = new MediaMuxer("/storage/emulated/0/OuputVideos/output1.mp4",OutputFormat.MUXER_OUTPUT_MPEG_4

The problem is that: Everything is ok with primary storage (internal storage), but I can not save output video to secondary SD card (external). My app runs in Lollipop devices (5.0). I read a lot of topics about working with SD card on Lollipop (for example: How to use the new SD card access API presented for Android 5.0 (Lollipop)?). All of them talk about using new Intent ACTION_OPEN_DOCUMENT_TREE to pick an output directory.

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, 42);

On result of this Intent:

public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
if (resultCode == RESULT_OK) {
    Uri treeUri = resultData.getData();
    DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);

But I don't know how to use pickedDir for MediaMuxer. Can any body help me? Thanks a lot!

Community
  • 1
  • 1
TOP
  • 2,574
  • 5
  • 35
  • 60
  • Did you find a solution for this problem? – PerracoLabs Jan 02 '16 at 12:24
  • 1
    @PerracoLabs Unfortunately I think we cannot do it. Have a look at the source code of `MediaMuxer` class. It has only one constructor. It is a `final` class, so we cannot `extend` it. Maybe you have to create your own class. – TOP Jan 05 '16 at 10:48
  • https://android.googlesource.com/platform/frameworks/base.git/+/master/media/java/android/media/MediaMuxer.java – TOP Jan 05 '16 at 10:48
  • 1
    I've posted a new bug to Android Issue Tracker. Maybe you want to add your notes, or you want to starred it to get any notifications about this problem when (if) Google answers it. Next comes the link. – PerracoLabs Jan 05 '16 at 11:41
  • https://code.google.com/p/android/issues/detail?id=198117&thanks=198117&ts=1451851626 – PerracoLabs Jan 05 '16 at 11:41

0 Answers0