I am capturing video using default camera in Android and compressing it using ffmpeg-android-java library.
After successful compression, video is playing in MXPlayer app, but fails to play in Web browsers like Google Chrome, Firefox.
What can be the reason?
I have shared my compression logic. What changes can I make here so it can play on browsers?
String[] str=new String[]{"-y" ,"-i",sourceFilename,"-strict","experimental","-s", "160x120","-r","25", "-vcodec", "mpeg4", "-b", "150k", "-ab","48000", "-ac", "2", "-ar", "22050", destinationFilename};
try{
FFmpeg ffmpeg = FFmpeg.getInstance(getActivity());
ffmpeg.execute(str, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {}
@Override
public void onProgress(String message) {
Log.e("onProgress",message);
}
@Override
public void onFailure(String message) {
Log.e("onFailure",message);
}
@Override
public void onSuccess(String message) {
Log.e("onSuccess",message);
}
@Override
public void onFinish() {}
});
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
Your vcodec should be libx264
. The browsers, likely, can't play MPEG-4 Part 2. You should add "-movflags","+faststart"
for quick start of playback.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.