android – 从VideoView录制视频

栏目: Android · 发布时间: 7年前

内容简介:目前正在做Streaming的项目,我可以播放直播视频.现在我的下一个任务是录制在VideoView中播放的视频.我已经搜索,能够发现捕获视频,但表面(相机),但在这里在VideoView我没有任何表面.任何帮助赞赏

目前正在做Streaming的项目,我可以播放直播视频.现在我的下一个任务是录制在VideoView中播放的视频.

我已经搜索,能够发现捕获视频,但表面(相机),但在这里在VideoView我没有任何表面.

任何帮助赞赏

您可以看到 this

链接.简而言之,您的服务器必须支持下载.如果是,您可以尝试以下代码:

private final int TIMEOUT_CONNECTION = 5000; //5sec
private final int TIMEOUT_SOCKET = 30000; //30sec
private final int BUFFER_SIZE = 1024 * 5; // 5MB

private final int TIMEOUT_CONNECTION = 5000; //5sec
private final int TIMEOUT_SOCKET = 30000; //30sec
private final int BUFFER_SIZE = 1024 * 5; // 5MB

try {
  URL url = new URL("http://....");

  //Open a connection to that URL.
  URLConnection ucon = url.openConnection();
  ucon.setReadTimeout(TIMEOUT_CONNECTION);
  ucon.setConnectTimeout(TIMEOUT_SOCKET);

  // Define InputStreams to read from the URLConnection.
  // uses 5KB download buffer
  InputStream is = ucon.getInputStream();
  BufferedInputStream in = new BufferedInputStream(is, BUFFER_SIZE);
  FileOutputStream out = new FileOutputStream(file);
  byte[] buff = new byte[BUFFER_SIZE];

  int len = 0;
  while ((len = in.read(buff)) != -1)
  {
      out.write(buff,0,len);
  }
} catch (IOException ioe) {
  // Handle the error
} finally {
  if(in != null) {
    try {
      in.close();
    } catch (Exception e) {
      // Nothing you can do
    }
  }
  if(out != null) {
    try {
      out.flush();
      out.close();
    } catch (Exception e) {
      // Nothing you can do
    }
  }
}

如果服务器不支持下载,则无法做任何事情.

代码日志版权声明:

翻译自:http://stackoverflow.com/questions/9091014/record-video-from-videoview


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Wikis For Dummies

Wikis For Dummies

Dan Woods、Peter Thoeny / For Dummies / 2007-7-23 / USD 24.99

Corporations have finally realized the value of collaboration tools for knowledge sharing and Wiki is the open source technology for creating collaborative Web sites, as either a public site on the In......一起来看看 《Wikis For Dummies》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具