Wie konvertiert man eine Videodatei (.mp4) in ein binäres Format in Android?

Ich möchte ein Video auf den Webserver hochladen. Ich habe den Dienst, den ich eine Datei im Binärformat übergeben möchte. Wie kann ich das tun?

Ich habe versucht, die Videodatei mit Hilfe von base64 in ein Binärformat umzuwandeln.

public class binaryformat extends Activity {
private String strAttachmentCoded;
Button b1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    b1=(Button)findViewById(R.id.button1);
    b1.setOnClickListener(new OnClickListener()
    {

        @Override
        public void onClick(View v)
        {
            // TODO Auto-generated method stub
             File file = new File("/mnt/sdcard/C:/Program Files (x86)/Wowza Media Systems/Wowza Media Server 3.1.2/content/sample.mp4");
                FileInputStream objFileIS = null;
                try
                {
                    objFileIS = new FileInputStream(file);
                } 
                catch (FileNotFoundException e) 
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                ByteArrayOutputStream objByteArrayOS = new ByteArrayOutputStream();
                byte[] byteBufferString = new byte[1024];
                try
                {
                    for (int readNum; (readNum = objFileIS.read(byteBufferString)) != -1;) 
                    {
                     objByteArrayOS.write(byteBufferString, 0, readNum);
                     System.out.println("read " + readNum + " bytes,");
                    }
                } 
                catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }                    
                byte[] byteBinaryData = Base64.encode((objByteArrayOS.toByteArray()), Base64.DEFAULT);
               strAttachmentCoded = new String(byteBinaryData);

        }
    });


}

}

Antworten auf die Frage(1)

Ihre Antwort auf die Frage