H.264 media player with JavaFX
H.264 media player with JavaFX
I am trying to display a H.264 stream (of the Raspberry Pi camera, thanks to uv4l) in a JavaFX app. H.264 is supposed to be supported by JavaFX. However, I keep getting a blank screen and this error :
MediaException: MEDIA_UNSUPPORTED : Unrecognized file signature!
at javafx.scene.media.Media._setError(Media.java:513)
at javafx.scene.media.Media$InitLocator.run(Media.java:566)
at java.lang.Thread.run(Thread.java:745)
Here's my code :
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.stage.Stage;
public class Main extends Application
private static MediaView mv = new MediaView();
private Media media;
public static void main(String args)
launch(args);
@Override
public void start(Stage stage) throws Exception
media = new Media("http://192.168.0.10:8080/stream/video.h264");
MediaPlayer mp = new MediaPlayer(media);
mp.setAutoPlay(true);
mv.setMediaPlayer(mp);
Group root = new Group(mv);
Scene scene = new Scene(root, 640, 480);
stage.setTitle("Pi_Cam");
stage.setScene(scene);
stage.show();
mp.errorProperty().addListener((observable, oldValue, newValue) ->
newValue.printStackTrace();
);
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.