问题描述
我用Google搜索了很多,发现在all.Not没有成功,甚至单点从中我可以Kickstart中。我使用VideoView播放从URL中的视频,成功它播放视频,同时我要录制当前播放的视频。例如: HTTP://ip/streamname/playlist.m3u8
是URL,我看着它成功,但我需要记录下特定的数据流,并保存它,这样我就可以稍后观看。请给我建议的解决
I have googled a lot and found no success at all.Not even single point from which I can kickstart. I am using VideoView to play the video from url, successfully it's playing the video, at the same time I want to record the currently playing video. e.g: http://ip/streamname/playlist.m3u8
is the url and I watch it successfully, but I need to record the particular stream and save it so that I can watch it later. Please suggest me the solution
推荐答案
试试这个code从网址下载视频一件事记住服务器必须支持从特定字节偏移下载
Try this code to download your video from your url and one thing remember server must support downloading from a specific byte offset
private final int TIMEOUT_CONNECTION = 5000;//5sec
private final int TIMEOUT_SOCKET = 30000;//30sec
URL url = new URL("Video URL");
// long startTime = System.currentTimeMillis();
// Log.i(TAG, "image download beginning: "+imageURL);
//Open a connection to that URL.
URLConnection ucon = url.openConnection();
//this timeout affects how long it takes for the app to realize there's a //connection problem
ucon.setReadTimeout(TIMEOUT_CONNECTION);
ucon.setConnectTimeout(TIMEOUT_SOCKET);
//Define InputStreams to read from the URLConnection.
// uses 3KB download buffer
InputStream is = ucon.getInputStream();
BufferedInputStream inStream = new BufferedInputStream(is, 1024 * 5);
FileOutputStream outStream = new FileOutputStream(file);
byte[] buff = new byte[5 * 1024];
//Read bytes (and store them) until there is nothing more to read(-1)
int len;
while ((len = inStream.read(buff)) != -1)
{
outStream.write(buff,0,len);
}
//clean up
outStream.flush();
outStream.close();
inStream.close();
Log.i(TAG, "download completed in "
+ ((System.currentTimeMillis() - startTime) / 1000)
+ " sec");5
这篇关于我怎么可以记录当前的实时视频流媒体播放器中播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!