HBiSoft / PickiT

An Android library that returns real paths from Uri's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mpossible to open '/storage/emulated/0/Download/first_video.mp4'

MohamedMohy9192 opened this issue · comments

Above android 9

I am using the library to get the path from the URI of videos after selecting them from the download folder using ACTION_PICK like the example code. after generating the path using the library and passing it to FFmpeg Kit the app gives me that error

2022-01-22 06:19:30.751 13954-13998/com.hbisoft.pickitexample E/ffmpeg-kit: [concat @ 0xc5da8000] Impossible to open '/storage/emulated/0/Download/first_video.mp4' 2022-01-22 06:19:30.751 13954-13998/com.hbisoft.pickitexample E/ffmpeg-kit: /data/user/0/com.hbisoft.pickitexample/cache/ffmpeg-list1945350936764214333.txt: Permission denied

@Override
    public void PickiTonMultipleCompleteListener(ArrayList<String> paths, boolean wasSuccessful, String Reason) {
        if (mdialog != null && mdialog.isShowing()) {
            mdialog.cancel();
        }
        StringBuilder allPaths = new StringBuilder();
        for (int i = 0; i < paths.size(); i++) {
            allPaths.append("\n").append(paths.get(i)).append("\n");
        }

        //  Set returned path to TextView
        pickitTv.setText(allPaths.toString());

        //  Make TextView's visible
        originalTitle.setVisibility(View.VISIBLE);
        originalTv.setVisibility(View.VISIBLE);
        pickitTitle.setVisibility(View.VISIBLE);
        pickitTv.setVisibility(View.VISIBLE);

        mVideosList = generateList(paths.toArray(new String[0]));
    }

private static String generateList(String[] inputs) {
        File list;
        Writer writer = null;
        try {
            list = File.createTempFile("ffmpeg-list", ".txt");
            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(list)));
            for (String input : inputs) {
                writer.write("file '" + input + "'\n");
                Log.d(TAG, "Writing to list file: file '" + input + "'");
            }
        } catch (IOException e) {
            e.printStackTrace();
            return "/";
        } finally {
            try {
                if (writer != null)
                    writer.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

        Log.d(TAG, "Wrote list file to " + list.getAbsolutePath());
        return list.getAbsolutePath();
    }

findViewById(R.id.start_combine_button).setOnClickListener(view -> {
            FFmpegKit.executeAsync("-f concat -safe 0 -i " + mVideosList + " -c copy " + mOutputDirectory.getPath(),
                    new FFmpegSessionCompleteCallback() {
                        @Override
                        public void apply(FFmpegSession session) {
                            Log.d(TAG, "getCommand: " + session.getCommand());
                            Log.d(TAG, "getFailStackTrace: " + session.getFailStackTrace());

                        }

                    });

        });

Can you please provide the Uri returned from MediaStore?

commented

This issue has been automatically marked as stale because it has not had activity in the last 14 days. It will be closed if no further activity occurs within the next 3 days. Thank you for your contributions.

Inactive, closing.