1

i have video file in the sdcard. i want to encode the video file at minute 3 to 5. what im trying to say is,

let say, the complete video file is 10 minute. now i need to retrieve the video data at 3 to 5 minutes of the video to be encode and do the next process.

i have done it before but only encoded the complete video file and i dont have any idea to encoded the video file at specific time of the video. please help with this. Below is my encoded complete video file code:

public void loadVideo(){        
    //convert whole file into byte
    File file = new File("/sdcard/videooutput.mp4");                
    byte[] fileData = new byte[(int) file.length()];

    FileInputStream in; 
    try {
        in = new FileInputStream(file);         
        try {
            in.read(fileData);
            for(int readNum; (readNum = in.read(fileData)) != -1;){                 
            }
        } catch (IOException e) {
            Toast.makeText(this, "IO exc READ file", 2500).show();
            e.printStackTrace();
        }
        try {
            in.close();
        } catch (IOException e) {
            Toast.makeText(this, "IO exc CLOSE file", 2500).show();
            e.printStackTrace();
        }

        String encoded = Base64.encodeToString(fileData, Base64.DEFAULT);
        hantar(encoded);
    } catch (FileNotFoundException e) {
        Toast.makeText(this, "FILE NOT FOUND", 2500).show();
        e.printStackTrace();
    }

Please guide me with this. Thanks for advance.

sara brown
  • 1,057
  • 8
  • 29
  • 46

3 Answers3

2

You can try to use this class. It crops video from start to end position and saves cropped video to the file in your file system. Or you can use it to implement your own solution.

Sergey Pekar
  • 8,555
  • 7
  • 47
  • 54
0

There is already answered question about cutting or trimming video on Android: Android sdk cut/trim video file

Community
  • 1
  • 1
petrsyn
  • 5,054
  • 3
  • 45
  • 48
  • im sorry, i think my previous post bring some confusion of what i really want to do. i have edited back my post and hoping that you could help with this. – sara brown Oct 25 '12 at 03:24
  • OK so you need to cut or trim the video and after that encode it. I'll change the answer. – petrsyn Oct 25 '12 at 08:49
0

You can try INDE Media for mobile - https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials

It has transcoding\remuxing functionality as MediaComposer class and a possibility to select segments for resulted files

enter image description here

Marlon
  • 1,473
  • 11
  • 13