문제

My requirement is that How to read and create mp4 file from live stream video URL.

I have did many R&D's for this topic but failed to get any answer. Following link also not useful to me. When I run ffmpeg command given in this question, it gives me an exception.

I want to use FFMPEG, not xuggle library

Thanks.

도움이 되었습니까?

해결책

Following is the java method which you can use to read data from rtmp url with the integration of FFMPEG library.

   public static void liveRtmpFeed() throws IOException, InterruptedException {
        ProcessBuilder processBuilder = new ProcessBuilder("ffmpeg", "-i",
                "rtmp://192.168.0.90/oflaDemo/livestream", "-ss", "00:00:00",
                "-t", "00:00:10", "-c", "copy", "/home/outputVideo.mp4");
        Process process = processBuilder.start();
        InputStream stderr = process.getErrorStream();
        InputStreamReader isr = new InputStreamReader(stderr);
        BufferedReader br = new BufferedReader(isr);
        while ((br.readLine()) != null)
            ;
        process.waitFor();

        try {
            process.destroy();
            isr.close();
            stderr.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top