Jaffree
Jaffree copied to clipboard
How to use Jaffree with Spring Boot for streaming a RTSP ?
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 i mean, i have rtsp link, so how to stream to front-end from spring boot
All you need is in the example I sent earlier. Shall you have further questions, I'm available for paid consulations
@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();
});
}
}
<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>
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 got it i have fixed as your suggestion , how to reduce .ts . file size ?