bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.51k stars 1.58k forks source link

Create rtsp stream #723

Open salvo19881 opened 7 years ago

salvo19881 commented 7 years ago

Hello i've one question. I create a rtp strem, and sdp file, from webcam. Now i have to obtain one rtsp stream. How i can do it?, i read online that i need rtsp server. Can i made it in java code? or can i excecute line command from ffmpeg to obtain it from rtp stream?

saudet commented 7 years ago

Yes sure we can use FFmpegFrameRecorder the same way as the ffmpeg command line program for that. Contributions of sample code are welcome.

salvo19881 commented 7 years ago

of course.

                        recorder = new FFmpegFrameRecorder("rtp://192.168.88.241:5056", CAPTUREWIDTH, CAPTUREHRIGHT);
                        recorder.setInterleaved(false);
                        // video options //
                        recorder.setVideoOption("tune", "zerolatency");
                        recorder.setVideoOption("preset", "ultrafast");
                        recorder.setVideoOption("crf", "25");
                        recorder.setVideoBitrate(150000);
                        recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
                        recorder.setFormat("rtp");
                        recorder.setFrameRate(FRAME_RATE);
                        recorder.setGopSize(GOP_LENGTH_IN_FRAMES);

this is the code for rtp stream, if i try to substitute rtp with rtsp not work. When run code, it blocks in record.start();