I have a java swing app and im trying to display an rtp stream running on the same machine. I have tried using the ip adress or the sdp file with no luck.
public class MediaPlayer {
private final EmbeddedMediaPlayer mediaPlayer;
private boolean playing;
public MediaPlayer(JPanel parent) {
new NativeDiscovery().discover();
EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
this.mediaPlayer = mediaPlayerComponent.mediaPlayer();
parent.add(mediaPlayerComponent, BorderLayout.CENTER);
}
public void Play() {
this.playing = true;
this.mediaPlayer.controls().play();
}
public void Stop() {
this.playing = false;
this.mediaPlayer.controls().stop();
}
public void setMedia(String activeCam) {
String p1 = "src/placeholders/fish.mp4";
String p2 = "src/placeholders/rat.mp4";
String s1 = "rtp://127.0.0.1:2222";
switch (activeCam) {
case "Cam1":
this.mediaPlayer.media().startPaused("rtp://127.0.0.1:2222");
break;
case "Cam2":
this.mediaPlayer.media().startPaused(p2);
break;
}
}
}
Calling setMedia("Cam2") and later Play() will display the video, but calling setMedia("Cam1") and Play() afterwards will bring only a blackscreen. I am able to open the video stream using the sdp file in vlc.
This is the command used to stream the camera
ffmpeg -hide_banner -f dshow -video_size 1920x1080 -framerate 15 -i video="Logitech BRIO" -b:v 5500k -an -f rtp rtp://localhost:2222?pkt_size=800 -sdp_file stream.sdp
Im expecting the Video feed to switch from the video and show the live stream but no luck,
i have tried using the rtp://localhost:2222, rtp://@:2222, the sdp file and no luck