android byte转视频,如何在android中将视频文件(.mp4)格式转换为二进制格式?

我想在网络服务器上传视频。我得到了服务,我想以二进制格式传递文件,我该怎么做?

我试图在base64的帮助下将视频文件转换为二进制格式。?

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);

}

});

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值