Jaffree icon indicating copy to clipboard operation
Jaffree copied to clipboard

How to use Jaffree with Spring Boot for streaming a RTSP ?

Open longtran84 opened this issue 1 year ago • 7 comments

longtran84 avatar Apr 21 '23 08:04 longtran84

First of all, this project has discussions enabled. And there is already similar topic. You gave no description of what you actually need and tried. Please, take care about other people's time too. Check this https://github.com/kokorin/Jaffree/blob/master/src/test/java/examples/ReStreamWithHls.java

kokorin avatar Apr 21 '23 14:04 kokorin

@kokorin i mean, i have rtsp link, so how to stream to front-end from spring boot

longtran84 avatar Apr 22 '23 10:04 longtran84

All you need is in the example I sent earlier. Shall you have further questions, I'm available for paid consulations

kokorin avatar Apr 22 '23 13:04 kokorin

@kokorin this is my code, it not work

@RestController @RequestMapping("/video") @Log4j2 public class VideoController {

@GetMapping(value = "/live.mp4")
@ResponseBody
public ResponseEntity<StreamingResponseBody> video() {
    return ResponseEntity.ok()
            .contentType(MediaType.APPLICATION_OCTET_STREAM)
            .body(os -> {
                Path dir = Paths.get("/home/j2ee/Downloads/META-INF");
                Path liveStreamSimulation = dir.resolve("/home/j2ee/Downloads/META-INF/1.mp4");
                FFmpeg.atPath()
                        .addInput(
                                UrlInput.fromPath(liveStreamSimulation)
                                        .setReadAtFrameRate(true)
                        )
                        .addOutput(
                                PipeOutput.pumpTo(os)
                                        .setFrameRate(30)
                            .setFormat("hls")
                        )
                        .setOverwriteOutput(true)
                        .execute();
            });
}

}

longtran84 avatar Apr 23 '23 03:04 longtran84

HLS Player - play m3u8 HTTP Live Streaming (HLS)

<script type="text/javascript" src="https://www.hlsplayer.org/assets/js/jquery.min.js?v=1682173024"></script>
<script type="text/javascript" src="https://www.hlsplayer.org/assets/js/common.js?v=1682173024"></script>
<script type="text/javascript" src="https://www.hlsplayer.org/assets/js/helper.js?v=1682173024"></script>

<script type="text/javascript" src="https://www.hlsplayer.org/assets/js/hls.js?v=1682173024"></script>
<script type="text/javascript" src="https://www.hlsplayer.org/assets/js/player.js?v=1682173024"></script>

<style>
    body {
        background-color: black;
    }
    #video {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0px;
        right: 0px;
        bottom: 0px;
        left: 0px;
        margin: auto;
        max-height: 100%;
        max-width: 100%;
    }
</style>

longtran84 avatar Apr 23 '23 03:04 longtran84

Have you checked the link I sent earlier? Do you understand how HLS works? What is the error with your current approach? Another link https://github.com/kokorin/Jaffree/discussions/344

kokorin avatar Apr 23 '23 04:04 kokorin

@kokorin got it i have fixed as your suggestion , how to reduce .ts . file size ?

longtran84 avatar Apr 23 '23 06:04 longtran84