Android视频无法流式传输 [英] Android video not valid for streaming
问题描述
我试图以下code播放视频。
公共类VidplayerActivity延伸活动{ 私人的MediaController MC;
字符串link =HTTP://***/test.3gp // 5 MB @覆盖
公共无效的onCreate(捆绑savedInstanceState){
尝试{
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
VideoView VD =(VideoView)findViewById(R.id.delta); URI URI = Uri.parse(LINK); MC =新的MediaController(本);
vd.setMediaController(MC); vd.setVideoURI(URI);
vd.start();
}
赶上(例外五){
的System.out.println(e.getStackTrace());
}
}}
它显示的抱歉,该视频无法流式传输到该设备在Android的1.5和1.6。而视频的细节低于
编辑:
输入#0,MOV,MP4,M4A,3GP,3G2,MJ2,从
/home/cvbcvb/Desktop/test.3gp
元数据:
major_brand:3gp4minor_version:512compatible_brands:isomiso23gp4
时间:00:03:00.04,启动:0.000000,码率:150 kb / s的
流#0.0(UND):视频:H263,YUV420P,176×144 [PAR 12:11 DAR
4:3],138 kb / s的,每秒25帧,25 TBR,25 TBN,29.97 TBC
流#0.1(UND):音频:amrnb,8000赫兹,渠道,FLT,8 kb / s的
[STREAM]
指数= 0
codec_name = H263
codec_long_name = H.263 / H.263-1996,H.263 + / H.263-1998 / H.263
版本2
codeC_TYPE =视频
codec_time_base =三万分之一千○一
codec_tag_string = S263
codec_tag = 0x33363273
宽度= 176
高= 144
has_b_frames = 0
sample_aspect_ratio = 12:11
display_aspect_ratio = 4:3
pix_fmt = YUV420P
r_frame_rate = 25/1
avg_frame_rate = 25/1
那么time_base = 1月25日
语言= UND
START_TIME = 0.000000
持续时间= 180.040000
nb_frames = 4501
标签:语言= UND
[/ STREAM]
[STREAM]
指数= 1
codec_name = amrnb
codec_long_name =自适应多速率窄带
codeC_TYPE =音频
codec_time_base = 0/1
codec_tag_string = SAMR
codec_tag = 0x726d6173
SAMPLE_RATE = 8000.000000
频道= 1
bits_per_sample = 0
r_frame_rate = 0/0
avg_frame_rate = 0/0
那么time_base =8000分之1
语言= UND
START_TIME = 0.000000
持续时间= 180.000000
nb_frames = 9000
标签:语言= UND
[/ STREAM]
块引用>解决方案请阅读本文件:的的Android支持的媒体格式。
只是被带codeD使用^ h 263
这是不够的,是有效的格式在Android的流媒体。决议必须是:
176×144像素
或480 * 360像素
,并在底部更说明文档:
对于流是通过HTTP或RTSP视频内容,还有额外的要求:
有关3GPP和MPEG-4容器中,MOOV原子必须precede任何MDAT原子。
有关3GPP,MPEG-4和WebM容器,对应于相同时间偏移的音频和视频样本可以是不超过500 KB的分开。为了减少这种音频/视频漂移,考虑更小的块大小交错的音频和视频。
块引用>i'm trying following code playing video.
public class VidplayerActivity extends Activity { private MediaController mc; String LINK = "http://***/test.3gp"; // 5 mb @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); setContentView(R.layout.main); VideoView vd = (VideoView) findViewById(R.id.delta); Uri uri = Uri.parse(LINK); mc = new MediaController(this); vd.setMediaController(mc); vd.setVideoURI(uri); vd.start(); } catch(Exception e) { System.out.println(e.getStackTrace()); } } }
it shows "Sorry,this video is not valid for streaming to this device" in android 1.5 and 1.6. And the video details is below
EDIT:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/cvbcvb/Desktop/test.3gp':
Metadata:
major_brand : 3gp4 minor_version : 512 compatible_brands: isomiso23gp4
Duration: 00:03:00.04, start: 0.000000, bitrate: 150 kb/s
Stream #0.0(und): Video: h263, yuv420p, 176x144 [PAR 12:11 DAR
4:3], 138 kb/s, 25 fps, 25 tbr, 25 tbn, 29.97 tbc
Stream #0.1(und): Audio: amrnb, 8000 Hz, 1 channels, flt, 8 kb/s
[STREAM]
index=0
codec_name=h263
codec_long_name=H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2
codec_type=video
codec_time_base=1001/30000
codec_tag_string=s263
codec_tag=0x33363273
width=176
height=144
has_b_frames=0
sample_aspect_ratio=12:11
display_aspect_ratio=4:3
pix_fmt=yuv420p
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/25
language=und
start_time=0.000000
duration=180.040000
nb_frames=4501
TAG:language=und
[/STREAM]
[STREAM]
index=1
codec_name=amrnb
codec_long_name=Adaptive Multi-Rate NarrowBand
codec_type=audio
codec_time_base=0/1
codec_tag_string=samr
codec_tag=0x726d6173
sample_rate=8000.000000
channels=1
bits_per_sample=0
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/8000
language=und
start_time=0.000000
duration=180.000000
nb_frames=9000
TAG:language=und
[/STREAM]
解决方案Please read this document : Android Supported Media Formats. Just being encoded using
H 263
it is not enough for be in a valid format for streaming in Android.The resolutions has to be :
176 x 144 px
or480 x 360 px
and also at the bottom of the documentation it is stated:For video content that is streamed over HTTP or RTSP, there are additional requirements:
For 3GPP and MPEG-4 containers, the moov atom must precede any mdat atoms.
For 3GPP, MPEG-4, and WebM containers, audio and video samples corresponding to the same time offset may be no more than 500 KB apart. To minimize this audio/video drift, consider interleaving audio and video in smaller chunk sizes.
这篇关于Android视频无法流式传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!