2012-02-01 85 views
15

目前正在直播Streaming項目中,並且我成功播放實況視頻。現在我的下一個任務是記錄正在VideoView中播放的視頻。 我已經搜索,能夠發現捕捉視頻,但與表面(相機),但在VideoView我沒有任何表面。從VideoView錄製視頻

任何幫助讚賞

+2

你得到解決 – Suraj 2014-01-08 10:22:03

回答

3

你可以看到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 
    } 
    } 
} 

如果服務器不支持下載,就沒有什麼可以做的。

3

您可以通過使用平臺工具和錄製視頻:

adb shell screenrecord --verbose /sdcard/demo.mp4 

替換演示用任何你想要的文件名。 此外,這將被放置在您的手機上,我相信默認爲6分鐘。 查看屏幕記錄的選項。

要將文件中提取到您的計算機....(以下命令,或使用Android設備監視器

adb pull /sdcard/demo.mp4 

我已經使用這個應用程序來記錄演示的,甚至打出YouTube和有它。錄製 它沒有音響,所以這可能是一個大問題 但這是包含在SDK中,並記錄任何屏幕顯示,同時它記錄

+0

注意:這將只需要記錄你想記錄的時間,而不是編程式的。希望這會有幫助。 – Hite 2015-06-09 20:11:55

+0

將記錄整個應用程序的屏幕,而不是記錄在VideoView中播放的視頻。 – 2015-06-10 04:12:38