gpt4 book ai didi

android - 从 VideoView 录制视频

转载 作者:可可西里 更新时间:2023-11-01 18:47:50 27 4
gpt4 key购买 nike

目前正在做直播项目,并成功播放直播视频。现在我的下一个任务是录制正在 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
}
}
}

如果服务器不支持下载,你也无能为力。

关于android - 从 VideoView 录制视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9091014/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com