Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67556

404 error video file (m3u8) not being read

$
0
0

I am using a Java Servlet and Tomcat to create a video file(HLS-m3u8). I am using a JSP to try and view that file using a hls.js .

CODE

 File folder = (File) getServletContext().getAttribute(req.getServletContext().TEMPDIR);
    File result = new File(folder, "cam.m3u8");

    FFmpeg ffmpeg = new FFmpeg("ffmpeg");
    FFprobe ffprobe = new FFprobe("ffprobe");



    FFmpegBuilder builder =
            new FFmpegBuilder()
                    .setInput("rtsp://xx:xx@192.168.86.00/live")
                    .addOutput(result.getAbsolutePath())
                    .addExtraArgs("-acodec", "copy")
                    .addExtraArgs("-vcodec", "copy")
                    .addExtraArgs("-f", "hls")
                    .addExtraArgs("-safe", "0")
                    .addExtraArgs("-hls_flags", "delete_segments+append_list")
                    .done();
    builder.setVerbosity(FFmpegBuilder.Verbosity.DEBUG);

    FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);

    // Run a one-pass encode
    executor.createJob(builder).run();

JSP

var name; <% File folder = (File) request.getServletContext().getAttribute(request.getServletContext().TEMPDIR); File result = new File(folder, "cam.m3u8"); %> window.onload = function() { name = '<%= result.getCanonicalPath()%>' var video = document.getElementById('video-player'); if(Hls.isSupported()) { var hls = new Hls(); hls.loadSource( '<%= result.getCanonicalPath()%>'); hls.attachMedia(video); hls.on(Hls.Events.MANIFEST_PARSED,function() { video.play(); }); } else if (video.canPlayType('application/vnd.apple.mpegurl')) { video.src ='<%= result.getCanonicalPath()%>'; video.addEventListener('loadedmetadata',function() { video.play(); }); } }

The file is being created at

"/Users/ari.sprung/Library/Caches/IntelliJIdea2018.1/tomcat/Unnamed_webappRunnerSample_6/work/Catalina/localhost/ROOT/"

When I debug the console I see an error 404 when the player tries to load the m3u8 file. I think its adding http://localhost:8080 to the address of the file. Any idea?

enter image description here

enter image description here


Viewing all articles
Browse latest Browse all 67556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>