Android Extract Decode Encode Mux Audio

后端 未结 1 1244
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 15:03

I am trying to adapt the code found in ExtractDecodeEditEncodeMuxTest.java in order to extract audio and video from a mp4 recorded via Cordova\'s device.capture.captureVideo

1条回答
  •  清酒与你
    2021-01-02 15:54

    Turns out the above code works fine - as long as you're not trying to mux the same file you're extracting, at the same time.

    :-)

    I had a previous version of this that extracted, then muxed tracks to the same file, and forgot to change that in this version.

    This little method saved the day lol.

    private String getMuxedAssetPath() {
        String muxedAssetPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/" + CAMERA_DIRECTORY + "/muxedAudioVideo.mp4";
    
        File file = new File(muxedAssetPath);
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
                muxedAssetPath = null;
            }
        }
    
        return muxedAssetPath;
    }
    

    0 讨论(0)
提交回复
热议问题