0

This is my code, but the second split of the video is different, therefore when combining the split parts the video plays the first split but the second part it does not.

int bufferSize = (int) video_size_bytes;
byte[] buffer = new byte[bufferSize];
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
int len = 0;
try {
    while ((len = inputStream.read(buffer)) != -1)
    {
        byteBuffer.write(buffer, 0, len);
    }
} catch (IOException e) {
    e.printStackTrace();
    Log.i(PostsActivity.TAG, "IOException: " + e.getMessage());
}

int offset = 0;
int addition = 100000;
int length = 100000;
int limit = (int) video_size_bytes;
boolean stop_loop = false;
boolean loop_mock = true;

do{
    //Converting bytes into base64
    String video_string_raw = Base64.encodeToString(byteBuffer.toByteArray(), offset, length, Base64.DEFAULT);
    String video_string_raw_refined = video_string_raw.trim();
    video_string = video_string_raw_refined.replaceAll("\n", "");

    video_parts_array_string.add(video_string);

    if(stop_loop){
        break;
    }

    offset = offset + addition;

    if((offset+addition) > limit){
        length = limit-offset;
        stop_loop = true;
    }else{
        offset = offset + addition;
    }
}while(loop_mock);
MosesSoftEng
  • 485
  • 5
  • 13
  • Try [using a chunk size that's a multiple of 3](https://stackoverflow.com/a/7920834/300836)? – Matt Gibson Apr 02 '18 at 09:28
  • I have read the post but it a bit hard to comprehend for me at the moment am just a beginner. Can you show me how that is done in my case? – MosesSoftEng Apr 02 '18 at 09:34

0 Answers0