when I try to upload videos from various formats (including .mp4 and .3gp files) to facebook from my Android application, I get a notification in my facebook account saying: "Your video cannot be processed. to find out about common problems " Please help me with this. The postToWall function sends the video to facebook.
private void postToWall(String accessToken) {
String dataPath = "/mnt/sdcard/DCIM/Camera/video-2013-04-11-04-30-05.mp4";
InputStream is = null;
byte[] data = null;
try {
is = new FileInputStream(dataPath);
data = readBytes(is);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, mFacebook.getAccessToken());
params.putString("filename", "Video_02.mp4");
params.putByteArray("video", data);
params.putString("contentType", "video/quicktime");
params.putString("message", "video message");
mAsyncRunner.request("me/videos", params, "POST", new PostRequestListener(), null);
}
public byte[] readBytes(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int len = 0;
while ((len = inputStream.read(buffer)) != -1) {
byteBuffer.write(buffer, 0, len);
}
return byteBuffer.toByteArray();
}
source
share