Here is my videoview code :
Uri uri = Uri.parse(vidurl);
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.setVideoURI(uri);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
videoView.start();
}
});
Videos I try to play are stored in my server. They are sent there from the same app, using a custom camera. Here is video capturing parameters: ( Just in case something were wrong with those , I tried every combination, VP8 Format did stream , except the output had no audio and was rotated sideways)
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
if (currentCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
mMediaRecorder.setOrientationHint(90);
} else {
mMediaRecorder.setOrientationHint(270);
}
mMediaRecorder.setVideoSize(list.get(sizex).width, list.get(sizex).height);
mMediaRecorder.setVideoEncodingBitRate(1500000);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setMaxDuration(15000);
mMediaRecorder.setOutputFile(getVidFile().getAbsolutePath());
I've been trying to solve this for a long time but I am out of ideas now. I would like to stream those videos in a videoview. But instead of that , I have to wait 10-20 seconds. After that ,either video starts or it gives me an error that video can't be played.
Additional information:
Project minimum sdk is 18 , but I can change it if that will help.
My testing device is Asus Zenfone 2 (5.0)
I didn't test with any other device
Videos are stored in godaddy linux host. www.mydomain.com/videos/
Video encoding is h264 Baseline Profile
Moov atom is at top ( after fytp(or something like that) ) just as recommended
I tried using third party video player libraries like exomedia
Some videos do work , for example :
I checked that videos encoding. It's encoded in h264 MAIN PROFILE ( from my research , main profile isn't supported for most of android devices , baseline profile is recommended instead) AND MOOV ATOM IS AT LAST POSITION. But this video plays just fine... dafuq?
EDIT:Properties of that toystory video which works:
And here is a video captured from my app with parameteres given above(notice the moov atom is at right place, but this still doesn't work )