使用Android录制的视频无法在Blobstore上播放

时间:2012-12-24 16:59:36

标签: android google-app-engine video-streaming blobstore video-recording

我写了代码来记录Android上的视频,我把它上传到Blobstore,但没有好运从googleappengine上的播放器播放或者在web应用程序上播放它然而,我可以阅读视频下载它。任何的想法 ??我想到了我正在使用的编码或视频格式(.mp4)甚至更多,我将字节发送到blobstore的方式。谢谢。

这是录音代码:

     mCamera = Camera.open();        
     path= Environment.getExternalStorageDirectory().getAbsolutePath().toString();

     Date date=new Date();
     filename="/rec"+date.toString().replace(" ", "_").replace(":", "_")+".mp4";

     //create empty file it must use
     File file=new File(path,filename);
    mrec = new MediaRecorder(); 
    mCamera.lock();
    mCamera.unlock();
    mrec.setCamera(mCamera);    
    mrec.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    mrec.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);     
    mrec.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
    mrec.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
    mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    mrec.setVideoFrameRate(20);
    mrec.setPreviewDisplay(surfaceHolder.getSurface());
    mrec.setOutputFile(path+filename);
    mrec.prepare();
    mrec.start();

这是上传代码:

HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

//HttpPost httppost = new HttpPost(url);
HttpPost httppost = new HttpPost(url);
File file = new File("/sdcard/"+videoName);

MultipartEntity mpEntity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "video/mp4");
mpEntity.addPart("videoFile", cbFile);

httppost.setEntity(mpEntity);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();

“url”参数是blobstore生成的url,用于上传媒体文件,我猜blobstore用户对此很熟悉。

1 个答案:

答案 0 :(得分:0)

尝试使用OutputFormat.MPEG_4VideoEncoder.H264AudioEncoder.AAC