java调用ffmpeg直播流_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > java调用ffmpeg直播流

java调用ffmpeg直播流

 2017/9/26 18:43:02  samson870830  程序员俱乐部  我要评论(0)
  • 摘要:publicstaticvoidgetThumb()throwsIOException,InterruptedException{//ffmpeg-re-i/Users/samson/Desktop/apple-iphone4-design_video-us-20100607_848x480.mov-vcodeccopy-fflvrtmp://localhost:1935/live1/room2ProcessBuilderprocessBuilder=newProcessBuilder
  • 标签:Java
public static void getThumb() throws IOException,
            InterruptedException {

        //ffmpeg -re -i /Users/samson/Desktop/apple-iphone4-design_video-us-20100607_848x480.mov -vcodec copy -f flv rtmp://localhost:1935/live1/room2
        ProcessBuilder processBuilder = new ProcessBuilder("ffmpeg",
                "-re","-i", "/Users/samson/Desktop/apple-iphone4-design_video-us-20100607_848x480.mov",
                "-vcodec", "copy" ,
                "-f", "flv","rtmp://localhost:1935/live1/room2");

        Process process = processBuilder.start();

        InputStream stderr = process.getErrorStream();
        InputStreamReader isr = new InputStreamReader(stderr);
        BufferedReader br = new BufferedReader(isr);
        String line;
        while ((line = br.readLine()) != null) ;
        process.waitFor();

        if (br != null)
            br.close();
        if (isr != null)
            isr.close();
        if (stderr != null)
            stderr.close();
    }

    public static void main(String[] args) {
        try {
            getThumb();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
发表评论
用户名: 匿名