简体   繁体   English

如何在Android中从Amazon S3服务器解码和播放.h264视频?

[英]How to decode and play the .h264 video from amazon s3 server in android?

I have .h264 videos in server, how to decode that video and playing in android? 我的服务器中有.h264视频,如何解码该视频并在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. 我正在使用FFMPEG播放那些视频,但是在FFMPEG样本中,它从SD卡中提取了视频并成功地播放了该视频。 I am using the surface view to play those videos. 我正在使用表面视图播放那些视频。 My question is how to play .h264 video from amazon s3 server in android? 我的问题是如何从Android中的Amazon S3服务器播放.h264视频?

Thanks in advance. 提前致谢。

Make your videos(files) in the s3 bucket public, 将s3存储桶中的视频(文件)公开,
and use that public url, it will be accessible everywhere. 并使用该公共网址,则可以在任何地方访问。

EDIT 编辑

You can use a VideoView . 您可以使用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) . 您应该使用此代码Uri.parse(url)提供URI(具有String url变量,在其中具有视频的Uri.parse(url) And also be sure if the url is appropriate. 还要确保该URL是否合适。 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 同时为您的应用程序提供适当的权限(由于它使用互联网,因此您需要在应用程序的Manifest.xml添加<uses-permission android:name="android.permission.INTERNET" > 。最后,您应在中定义活动MediaPlayerActivity您应用的Manifest.xml

You can also use MediaPlayer . 您也可以使用MediaPlayer The Android developers site has a good tutorial here . Android开发人员站点在此处提供了很好的教程。

H.264 H.264

According to this , Android supports h.264 Baseline Profile playback. 根据这个 ,Android支持H.264 Baseline Profile的播放。 So your h.264 video is not Baseline Profile or possibly it contains an unsupported audio. 因此,您的h.264视频不是“基准配置文件”,或者可能包含不受支持的音频。

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.64版本,因此您应该检查视频文件: 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 manifesto.xml

permitions 许可

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM