I have .h264 videos in server, how to decode that video and playing in android?
I am using the FFMPEG to play those videos but in FFMPEG sample it takes the video from SD-card and successfully play's the video. I am using the surface view to play those videos. My question is how to play .h264 video from amazon s3 server in android?
Thanks in advance.
Make your videos(files) in the s3 bucket public,
and use that public url, it will be accessible everywhere.
EDIT
You can use a VideoView . Here is an example:
VideoView videoView = (VideoView) findViewById(R.id.videoView);
//Use a media controller so that you can scroll the video contents
//and also to pause, start the video.
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI(Uri.parse(videoUrl));
videoView.start();
You should provide the URI (having a String url
variable, where it has the url of the video) with this code Uri.parse(url)
. And also be sure if the url is appropriate. Also provide the appropriate permissions to your app (since it uses the internet you will need to add <uses-permission android:name="android.permission.INTERNET" >
in your app's Manifest.xml
Finally you should define your activity MediaPlayerActivity
in in your app's Manifest.xml
You can also use MediaPlayer . The Android developers site has a good tutorial here .
H.264
According to this , Android supports h.264 Baseline Profile playback. So your h.264 video is not Baseline Profile or possibly it contains an unsupported audio.
You should note that there are many h.64 flavors, so you should check your video file: http://www.niallkennedy.com/blog/2010/07/h264-video.html
您需要确保H.264视频在Android设备可以接受的编解码器中,否则,您需要对其进行重新编码。
I have Complete solve my issue by this code May be It will Help you.
layout.xml
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
.class
String FileUrl="decoded url";
MediaController mediacontroller = new MediaController(this);
mediacontroller.setAnchorView(videoView);
Uri video = Uri.parse(FileUrl);
videoView.setMediaController(mediacontroller);
videoView.setVideoURI(video);
manifesto.xml
permitions
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
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.