This discussion is archived
11 Replies Latest reply: Feb 11, 2013 12:24 AM by 989491 RSS

AdvancedMedia Sample doesn't run video (MediaPlayer)

989491 Newbie
Currently Being Moderated
Hi!

Running the AdvancedMedia sample from JavaFX everything works OK.
Using MediaPlayer class it shows the flash video from http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv

The problem is if I try to read other flash video... There is no video!

Looking at the video file example oow2010-2.flv the properties say it is a FLV4 video with format VP6.
And with this configuration it works fine.

I've tried to convert a several MP4 videos in to Flash(flv) but I never found a FLV4/VP6 format option to do it.

So, is there anyway to read "normal" FLVs files using the AdvancedMedia sample ?

Regards
Pedro
  • 1. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    jsmith Guru
    Currently Being Moderated
    flv videos must be vp6 encoded for JavaFX to be able to play them.

    You can find instructions on vp6 encoding videos by searching the forums.
  • 2. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    989491 Newbie
    Currently Being Moderated
    Well, after more than 2 hours reading all the messages from the JavaFx forum I didn't found the solution for this problem.
    Oracle says that JavaFX2.1 can run FLV, VP6 and also MP4.
    So, lets forget the VP6 and try the more common MP4.

    Looking at [JavaFX2.1 Oracle Page|https://blogs.oracle.com/javafx/entry/mpeg_4_multimedia_support_in] they have a Java code example to run mediaPlayer.

    I just changed the line:
    private static final String MEDIA_URL = "http://someserver/somedir/somefile.mp4";
    to a specified mp4 video path in the web. Running it in the IDE Netbeans with JavaFX2.2 installed it doesn't work! The application open the Java window but there is no sound, no video and no errors.

    I also tried with different MP4 videos but I suppose the proble is in the MP4 format.
    What video converter Oracle recommends to create MP4 video file format that can be read in MediaPlayer from JavaFX?

    Regards
    Pedro
  • 3. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    805536 Journeyer
    Currently Being Moderated
    >
    Well, after more than 2 hours reading all the messages from the JavaFx forum I didn't found the solution for this problem.
    Oracle says that JavaFX2.1 can run FLV, VP6 and also MP4.
    >

    Here is an old thread explaining FLV and the format you need: Playing video media

    >
    I just changed the line:
    private static final String MEDIA_URL = "http://someserver/somedir/somefile.mp4";
    to a specified mp4 video path in the web. Running it in the IDE Netbeans with JavaFX2.2 installed it doesn't work! The application open the Java window but there is no sound, no video and no errors.
    >

    Can you give us a self contained example of what you are doing between \
    \
    tags?
  • 4. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    jsmith Guru
    Currently Being Moderated
    What is the system config you are using for mp4 playback (OS/javafx version/installed codecs)?

    If you are using a system such as Linux, Vista or XP which requires you to manually install a compatible codec, have you installed one?
  • 5. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    989491 Newbie
    Currently Being Moderated
    >
    Here is an old thread explaining FLV and the format you need: Playing video media

    Can you give us a self contained example of what you are doing between  tags?
    >


    Thanks for your answer.
    First I did the example reading the video file from the Web.
    To be more comprehensive I show a small code reading the file locally with the same problem.

    Here is the Java code that I use:
    package mediaplayer;
    
    import java.io.File;
    import javafx.application.Application;
    import javafx.collections.ListChangeListener;
    import javafx.collections.MapChangeListener;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaView;
    import javafx.scene.media.Track;
    import javafx.stage.Stage;
    
    /**
     * A sample media player which loops indefinitely over the same video
     */
    public class MediaPlayer extends Application {
    
        @Override
        public void start(Stage stage) {
            stage.setTitle("Media Player");
    
            // This file flv/VP6 from Oracle works fine.
            String filename = "C://VideoFromOracle.flv";
            Media media = new Media(new File(filename).toURI().toString());
    
    
            javafx.scene.media.MediaPlayer mediaPlayer = new javafx.scene.media.MediaPlayer(media);
            mediaPlayer.setAutoPlay(true);
            mediaPlayer.setCycleCount(javafx.scene.media.MediaPlayer.INDEFINITE);
    
    // Print track and metadata information
            media.getTracks().addListener(new ListChangeListener<Track>() {
                public void onChanged(Change<? extends Track> change) {
                    System.out.println("Track> " + change.getList());
                }
            });
            media.getMetadata().addListener(new MapChangeListener<String, Object>() {
                public void onChanged(MapChangeListener.Change<? extends String, ? extends Object> change) {
                    System.out.println("Metadata> " + change.getKey() + " -> " + change.getValueAdded());
                }
            });
    
    // Add media display node to the scene graph
            MediaView mediaView = new MediaView(mediaPlayer);
            Group root = new Group();
            Scene scene = new Scene(root, 520, 200);
            root.getChildren().add(mediaView);
            stage.setScene(scene);
            stage.show();
        }
    
        public static void main(String[] args) {
            Application.launch();
        }
    This code is working OK opening the application and showing the video.
    It reads the Oracle video example in the root "C:\" downloaded before from [https://blogs.oracle.com/javafx/entry/mpeg_4_multimedia_support_in].

    The problem is I can´t read any other videos FLV or MP4.
    All the videos I created/converted to FLV or MP4 never work!

    Edited by: 986488 on 7/Fev/2013 13:30
  • 6. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    989491 Newbie
    Currently Being Moderated
    jsmith wrote:
    What is the system config you are using for mp4 playback (OS/javafx version/installed codecs)?

    If you are using a system such as Linux, Vista or XP which requires you to manually install a compatible codec, have you installed one?
    What is the system config you are using for mp4 playback (OS/javafx version/installed codecs)?


    I am using Windows Vista.
    As far as I know, from JavaFx2.1 all the codecs used come from the JavaFx2.1 package, not from the codecs inside the operating system.
    I don't remember exactly the link where I read this but it was from the JavaFX forum.
  • 7. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    jsmith Guru
    Currently Being Moderated
    As far as I know, from JavaFx2.1 all the codecs used come from the JavaFx2.1 package.
    No they don't - it depends open the OS and external software being used.

    See the Media section of the JavaFX 2.2 system requirements document:
    http://docs.oracle.com/javafx/2/system_requirements_2-2/jfxpub-system_requirements_2-2.htm

    I'll just copy and past it below in case the link moves or something like that:
    JavaFX Media
    
    For Windows XP and Windows Vista, JavaFX Media 2.2 requires that one of the 
    following external modules be installed to play AAC audio and H.264/AVC video:
    
        MainConcept H.264/AVC Pro Decoder Pack
        DivX Plus Codec Pack
        MainConcept Showcase (includes demo version codecs)
    
    Note:
    HTTP Live Streaming is not supported on Windows XP.
    
    For Windows 7, the pre-installed Microsoft AAC and H.264 DirectShow decoder 
    filters are used by default. However, if the MainConcept H.264/AVC Pro
    Decoder Pack is installed on your system, then the first available 
    AAC or H.264 decoder from the following list is used:
    
        MainConcept
        Microsoft (Windows 7 only)
        DivX Plus
        MainConcept trial version (demo codecs from Showcase)
    
    If none of these decoders is available, AAC and H.264 decoding will fail.
    
    VP6 video support does not require any third party modules.
    
    For Linux platform, install the following: libavcodec52 and libavformat52 
    on Ubuntu Linux 10.04, 10.10, 11.04 or equivalent, or libavcodec53 
    and libavformat53 on Ubuntu Linux 11.10, 12.04 or equivalent.
    (Encoding type: AAC audio, MP3 audio, H.264 video, and HTTP Live Streaming.) 
    Note that installing libavformat automatically causes libavcodec to be installed.
    The free DivX codec which you can download and install on your machine which allow you to playback mp4 via JavaFX on Windows Vista is available from here:
    http://www.divx.com/
  • 8. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    jsmith Guru
    Currently Being Moderated
    Well, after more than 2 hours reading all the messages from the JavaFx forum I didn't found the solution for this problem.
    Yep, sometimes it's really hard to find info on these forums . . . anyway the details were hidden in the post:
    Re: padding strings "Video JavaFX".
    For flvs, JavaFX only supports a little used codec called vp6.
    If you want to encode to that format then you could use Wildform's flix encoder > http://www.wildform.com/products/flix/flix_standard.php
    Note: this is not a product recommendation - I have not used this software - it is just one of the few pieces of software which encode to this format.
    To encode to a more common format, then you can encode h.264 to an mp4 container with aac audio.
    A google search will provide multiple software options to encode video to that format.
    Note that linux and xp users may need to have additional software installed to view the h.264 encoded video, but osx and win7+ users should not require additional software.
    I also believe that I used a trial version of Adobe After Effects to encode some videos to VP6 FLV, but that was a while back. You could try it:
    http://www.adobe.com/products/aftereffects.html

    I also posted some related information on this as a StackOverflow answer which you may find useful:
    http://stackoverflow.com/questions/10440152/any-simple-and-up-to-date-java-frameworks-for-embedding-movies-within-a-swing
  • 9. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    989491 Newbie
    Currently Being Moderated
    Hi "jsmith" and thanks for your help.

    Unfortunaly there still no solution.
    I've checked the JavaFx2.2 requirements and
    I installed:
    - MainConcept H.264/AVC Pro Decoder Pack
    and
    - DivX Plus Codec Pack
    but the same happens when opening any ".mp4" video:
    - it opens the JavaFX windows application
    - no video
    - no sound
    - no errors.

    I also tried all this in 2 diferent computers (both with Windows Vista)...

    About the AfterEffects CS6 trail version this only works in 64 bits OS, so is not compatible with my system.

    Conclusion: I dont know why but with JavaFx
    - flv / vp6 video (example from Oracle) works OK
    - any other *.mp4 videos don't work!!!*

    Most probably I will have to leave two weeks of work changing from JavaFx to any other language...!

    Last try question:
    Is there any freeware software to convert "normal" videos to FLV/VP6 format ?

    Regards
    Pedro
  • 10. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    jsmith Guru
    Currently Being Moderated
    - any other .mp4 videos don't work!!!
    Looks like it is an existing logged issue specific to Windows Vista (I can assure that mp4 playback worked fine on other platforms I tried such as XP, win7, osX) =>

    http://javafx-jira.kenai.com/browse/RT-27980 'Attempting to play an mp4 file via the media player on Windows Vista results in "GStreamer encountered a general stream error"'

    That issue is a relatively new one, but perhaps the problem has been around a long time and nobody bothered to log it, because from this thread: why can't JavaFx media player play .m4a file on windows xp sp3? somebody else had the same issue of being unable to play back video in Vista.

    The other thing you might want to check is that mp4 is a container format and video data within the container can be encoded in different formats. JavaFX won't support all possible encodings of the mp4 container format. A comprehensive list of supported encodings is at: http://docs.oracle.com/javafx/2/api/javafx/scene/media/package-summary.html. Specifically for mp4, the currently supported encoding format is limited to H.264/AVC Video H.264/MPEG-4 Part 10 / AVC (Advanced Video Coding) video compression with AAC audio encoding.
    Is there any freeware software to convert "normal" videos to FLV/VP6 format ?
    Not that I know of. Note that Wildform's software which I linked previously is only $19.99

    If you require more flexibility on video formats check out this post where a user embeds the vlcj component in JavaFX: looks pretty straightforward to me.
    Canvas performance
    http://caprica.github.com/vlcj/
  • 11. Re: AdvancedMedia Sample doesn't run video (MediaPlayer)
    989491 Newbie
    Currently Being Moderated
    So,
    - JavaFx in WindowsVista don't run MP4 videos
    and
    - there are no freeware software to convert videos to FLV/VP6.

    I would like to have an official answer from Oracle about this situation!


    Regards
    Pedro

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points