Hello, I'm using Open Camera with phone plugged to computer over USB. I've noticed I can't play recorded videos straight away over computer, because on SD card they are showing they have 0 bytes and content is not able to be read. I'm also using ffmpeg to tweak some .mp4 files into another .mp4 files and result is the same. Basically, recording a video and saving it, shows as a zero byte file on my computer over USB.
The solution is to unplug my USB and plug it in again and then it reads the content and I can play the video. This is a bad solution and I searched around and tried to tweak my code to get it working, but am not able to. Links I've gone through:
I really thought MediaScannerConnection scanFile will solve the problem, but it doesn't, even though I get the "Finished scanning" message after video is saved. I'm not sure what else I can do.
private void scanFile(String path) {
MediaScannerConnection.scanFile(this,
new String[] { path }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("TAG", "Finished scanning " + path);
}
});
}
Hello, I'm using Open Camera with phone plugged to computer over USB. I've noticed I can't play recorded videos straight away over computer, because on SD card they are showing they have 0 bytes and content is not able to be read. I'm also using ffmpeg to tweak some .mp4 files into another .mp4 files and result is the same. Basically, recording a video and saving it, shows as a zero byte file on my computer over USB.
The solution is to unplug my USB and plug it in again and then it reads the content and I can play the video. This is a bad solution and I searched around and tried to tweak my code to get it working, but am not able to. Links I've gone through:
https://commonsware.com/blog/2011/08/31/mtp-external-storage.html
https://sourceforge.net/p/opencamera/discussion/general/thread/69a70c5c/
https://stackoverflow.com/questions/49586487/ffmpeg-output-files-not-available-immediately-for-use
https://stackoverflow.com/questions/45694030/sd-card-new-written-file-is-zero-bytes-until-reboot
I really thought MediaScannerConnection scanFile will solve the problem, but it doesn't, even though I get the "Finished scanning" message after video is saved. I'm not sure what else I can do.