问题
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]
回答1:
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
or 480 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.
回答2:
try this ::
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
VideoViewDemo.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
videoview.xml
<VideoView
android:id="@+id/surface_view"
android:layout_width="320px"
android:layout_height="240px"
/>
And also view this
来源:https://stackoverflow.com/questions/7481193/android-video-not-valid-for-streaming