SiliCompressor
SiliCompressor copied to clipboard
Video is not compressed
Here is my code: `public class MainActivity extends AppCompatActivity {
private static final String TAG = "Video Compressor";
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
File sourcePath = new File("/storage/emulated/0/Video/sample.MP4");
Log.d(TAG, "onClick: sourcepath==== " +sourcePath);
Uri sourceURI = Uri.fromFile(sourcePath);
File desPath = new File("/storage/emulated/0/","");
Uri desURI = Uri.fromFile(desPath);
try {
String path = SiliCompressor.with(getApplicationContext()).compressVideo(sourceURI.toString(), desURI.toString());
Log.d(TAG, "onClick: gfsdgfsg=== "+ Uri.parse(path.substring(5)));
File file = new File(path.substring(5));
FileOutputStream fos = new FileOutputStream(file);
fos.flush();
fos.close();
float length = file.length() / 1024f; // Size in KB
String value;
if(length >= 1024)
value = length/1024f+" MB";
else
value = length+" KB";
Log.i("Silicompressor", "Path: "+value);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}`
Here is the log:
08-03 15:19:21.575 5653-5653/com.solo.vinay.videocompression D/Video Compressor: onClick: sourcepath==== /storage/emulated/0/Video/sample.MP4 08-03 15:19:21.615 5653-5653/com.solo.vinay.videocompression W/HTCLOG: use specified tag [MediaMetadataRetriever], func [0]. 08-03 15:19:21.615 5653-5653/com.solo.vinay.videocompression W/HTCLOG: mask=0x18 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression E/tmessages: file:/storage/emulated/0/VIDEO_20170803_151921.mp4: open failed: ENOENT (No such file or directory) 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression E/tmessages: time = 29 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression E/ViratPath: /storage/emulated/0/Video/sample.MP4 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression E/ViratPath: file:/storage/emulated/0/VIDEO_20170803_151921.mp4 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression E/ViratPath: /storage/emulated/0/Video/sample.MP4 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression V/SiliCompressor: Video Conversion Complete 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression D/Video Compressor: onClick: gfsdgfsg=== /storage/emulated/0/VIDEO_20170803_151921.mp4 08-03 15:19:21.685 5653-5653/com.solo.vinay.videocompression I/Silicompressor: Path: 0.0 KB
@Tourenathan-G5organisation Can u help me out??
'open failed: ENOENT (No such file or directory)' looks like it couldn't find the file
your path does not exist, you must create it after desPath
desPath.mkdirs();
Helo @DEV-NEP , sorry for this very late response. I was sick and absent all this while. I'm back. have you succeeded in going through this? Did you tried @josinaldobarbosa solution and it worked?
has anyone solved this issue?
Do you have this error? which library version are you using?