Closed whr2349 closed 1 month ago
console: rtsp://admin:zy123456@192.168.0.7:554 Starting streaming for rtsp://admin:zy123456@192.168.0.7:554 Error: [hevc @ 000001be6d3e43c0] VPS 0 does not exist
Error: [hevc @ 000001be6d3e43c0] VPS 0 does not exist
Info: Input #0, rtsp, from 'rtsp://admin:zy123456@192.168.0.7:554':
Info: Metadata:
Info: title : Info: Media Presentation Info:
Info: Duration: Info: N/A Info: , start: Info: 0.040000 Info: , bitrate: Info: N/A Info:
Info: Stream #0:0 Info: : Video: hevc (Main), yuv420p(tv), 1920x1080 Info: , Info: 20 fps, Info: 25 tbr, Info: 90k tbn Info:
Error: [hevc @ 000001be6f8cdb40] VPS 0 does not exist
Original Frame Rate: 20.0 Image Width: 1920 Image Height: 1080 Audio Channels: 0 Adjusted Frame Rate: 20.0 Video Bitrate: 4000000 Audio Sample Rate: 0 Audio Bitrate: 0 Error: [flv @ 000001be702ea8c0] No streams to mux were specified
Error during streaming: avformat_write_header error() error -22: Could not write header to 'rtmp://localhost/live/livestream' (For more details, make sure FFmpegLogCallback.set() has been called.) org.bytedeco.javacv.FFmpegFrameRecorder$Exception: avformat_write_header error() error -22: Could not write header to 'rtmp://localhost/live/livestream' (For more details, make sure FFmpegLogCallback.set() has been called.) at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:969) at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:437) at com.zydq.video.service.VideoStreamService.toSrsPush(VideoStreamService.java:192) at com.zydq.video.service.VideoStreamService.lambda$startRtspToSrsPushAsync$0(VideoStreamService.java:41) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:842)
Duplicate of #2232
What's wrong with my code? Unable to push to srs server: public void toSrsPush(String cameraId) {
I directly use ffmpeg push can be, the original stream is rtsp: public void executeFFmpegCommand(String rtspUrl, String rtmpUrl) { String command = "ffmpeg -rtsp_transport tcp -re -i " + rtspUrl + " -vcodec libx264 -acodec aac -f flv " + rtmpUrl; try { Process process = Runtime.getRuntime().exec(command); new Thread(() -> { BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; try { while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } }).start(); process.waitFor(); System.out.println("FFmpeg process exited with status " + process.exitValue()); } catch (InterruptedException | IOException e) { e.printStackTrace(); } } This is ok.