Problem with JME Theora video player

Hi All

I grabbed this old jme3.newvideo package from 3.0 branch to test ogv video playing on JME.

Here is the test class

package com.jme3.newvideo;

import com.fluendo.jst.BusHandler;
import com.fluendo.jst.Element;
import com.fluendo.jst.Message;
import com.fluendo.jst.Pipeline;
import com.fluendo.utils.Debug;
import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.jme3.texture.Texture2D;
import com.jme3.ui.Picture;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.concurrent.Callable;

public class TestNewVideo extends SimpleApplication implements BusHandler {

    private Picture picture;
    private JmeVideoPipeline p;
    private int frame = 0;

    public static void main(String[] args){
        TestNewVideo app = new TestNewVideo();
        AppSettings settings = new AppSettings(true);
        settings.setFrameRate(24);
        app.setSettings(settings);
        app.start();
    }

    private void createVideo(){
        Debug.level = Debug.INFO;
        p = new JmeVideoPipeline(this);
        p.getBus().addHandler(this);
        try {
            p.inputStream = new FileInputStream("PATH_TO_VIDEO.ogv");
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        p.setState(Pipeline.PLAY);
    }

    @Override
    public void simpleUpdate(float tpf){
        if (p == null){
            System.err.println("Pipeline is null!");
            return;
        }
            

        Texture2D tex = p.getTexture();
        if (tex == null)
        {
            System.err.println("Texture is null!");
            return;
        }

        if (picture != null){
            synchronized (tex){
                try {
                    tex.wait();
                } catch (InterruptedException ex) {
                    // ignore
                    System.err.println("Wait exception : "+ex);
                }
                tex.getImage().setUpdateNeeded();
                renderer.setTexture(0, tex);
                ((VideoTexture)tex).free();
                System.out.println("PLAY  : " + (frame++));
            }
            return;
        }
        
        picture = new Picture("VideoPicture", true);
        picture.setPosition(0, 0);
        picture.setWidth(settings.getWidth());
        picture.setHeight(settings.getHeight());
        picture.setTexture(assetManager, tex, false);
        rootNode.attachChild(picture);
    }

    public void simpleInitApp() {
        // start video playback
        createVideo();
    }

    @Override
    public void destroy(){
        if (p != null){
            p.setState(Pipeline.STOP);
            p.shutDown();
        }
        super.destroy();
    }

    public void handleMessage(Message msg) {
        switch (msg.getType()){
            case Message.EOS:
                Debug.log(Debug.INFO, "EOS: playback ended");
                /*
                enqueue(new Callable<Void>(){
                    public Void call() throws Exception {
                        rootNode.detachChild(picture);
                        p.setState(Element.STOP);
                        p.shutDown();
                        p = null;
                        return null;
                    }
                });
                
                Texture2D tex = p.getTexture();
                synchronized (tex){
                    tex.notifyAll();
                }
                */ 
                break;
            case Message.STREAM_STATUS:
                Debug.info(msg.toString());
                break;
        }
    }
}

but it returns null texture in Texture2D tex = p.getTexture();

here is output :

:core:jme3-media-player:run
[INFO] registered plugin: com.fluendo.plugin.HTTPSrc
[INFO] registered plugin: com.fluendo.plugin.VideoSink
[INFO] registered plugin: com.fluendo.plugin.AudioSinkJ2
[INFO] registered plugin: com.fluendo.plugin.AudioSinkSA
[INFO] registered plugin: com.fluendo.plugin.Queue
[INFO] registered plugin: com.fluendo.plugin.FakeSink
[INFO] registered plugin: com.fluendo.plugin.Overlay
[INFO] registered plugin: com.fluendo.plugin.Selector
[INFO] registered plugin: com.fluendo.plugin.OggDemux
[INFO] Ogg payload com.fluendo.plugin.TheoraDec found
[INFO] Ogg payload com.fluendo.plugin.VorbisDec found
[INFO] Ogg payload com.fluendo.plugin.KateDec found
[INFO] registered plugin: com.fluendo.plugin.TheoraDec
[INFO] registered plugin: com.fluendo.plugin.VorbisDec
[INFO] registered plugin: com.fluendo.plugin.KateDec
[INFO] registered plugin: com.fluendo.plugin.KateOverlay
[INFO] create element: Element: [audiosink]
[INFO] using high quality javax.sound backend
[INFO] mixer description: Direct Audio Device: default, default, default, vendor: ALSA (http://www.alsa-project.org)
[INFO] Mixer supports line: interface SourceDataLine supporting 512 audio formats, and buffers of at least 32 bytes
[INFO] Format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, 
[INFO] Format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, 
[INFO] Format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, 
[INFO] Format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, 
.
.
.
[INFO] Format: PCM_SIGNED unknown sample rate, 32 bit, 31 channels, 124 bytes/frame, big-endian
[INFO] Format: PCM_SIGNED unknown sample rate, 32 bit, 31 channels, 124 bytes/frame, little-endian
[INFO] Format: PCM_SIGNED unknown sample rate, 32 bit, 32 channels, 128 bytes/frame, big-endian
[INFO] Format: PCM_SIGNED unknown sample rate, 32 bit, 32 channels, 128 bytes/frame, little-endian
[INFO] Format: ULAW unknown sample rate, 8 bit, mono, 8 bytes/frame, 
[INFO] Format: ULAW unknown sample rate, 8 bit, stereo, 16 bytes/frame, 
.
.
.
[INFO] Format: ALAW unknown sample rate, 8 bit, 32 channels, 256 bytes/frame, 
[INFO] Attempting to get a line from ALSA mixer
[INFO] [Message]: Pad: InputStreamSource:src type: STREAM_STATUS, start, reason: ok, activating
[INFO] using typefind contentType: application/ogg
[INFO] Ogg payload com.fluendo.plugin.TheoraDec found
[INFO] Ogg payload com.fluendo.plugin.VorbisDec found
[INFO] Ogg payload com.fluendo.plugin.KateDec found
[INFO] create element: Element: [OggFileDemuxer]
[INFO] create element: Element: [BufferQueue]
[INFO] [Message]: Pad: BufferQueue:src type: STREAM_STATUS, start, reason: ok, activating
[INFO] ogg: got discont
[INFO] new stream -667506712, mime video/x-theora
[INFO] new stream 305187160, mime audio/x-vorbis
Texture is null!
[INFO] pad added Pad: OggFileDemuxer:serial_-667506712
[INFO] create element: Element: [v_queue]
[INFO] create element: Element: [v_queue2]
[INFO] create element: Element: [videodec]
[INFO] pad added Pad: OggFileDemuxer:serial_305187160
[INFO] all streams detected
[INFO] file has no audio, remove audiosink
[INFO] file has no video, remove videosink
[INFO] [Message]: Pad: v_queue2:src type: STREAM_STATUS, start, reason: ok, activating
[INFO] [Message]: Pad: v_queue:src type: STREAM_STATUS, start, reason: ok, activating
[ERRO] does not contain Theora video data.
[INFO] got EOS Pad: videodec:sink
[INFO] got EOS: Pad: v_queue2:sink
[INFO] [Message]: Pad: v_queue:src type: STREAM_STATUS, stop, reason: error, flow stopped
[INFO] Pad: TextureVideoSink:sink got EOS
[INFO] [Message]: Pad: v_queue2:src type: STREAM_STATUS, stop, reason: ok, flow stopped, EOS
.
.
.
Texture is null!
.
.
.
[INFO] [Message]: Pad: v_queue2:src type: STREAM_STATUS, stop, reason: wrong-state, stopping
[INFO] [Message]: Pad: v_queue:src type: STREAM_STATUS, stop, reason: wrong-state, stopping
[INFO] [Message]: Pad: BufferQueue:src type: STREAM_STATUS, stop, reason: wrong-state, flow stopped
[INFO] [Message]: Pad: BufferQueue:src type: STREAM_STATUS, stop, reason: wrong-state, stopping
[INFO] [Message]: Pad: InputStreamSource:src type: STREAM_STATUS, stop, reason: wrong-state, stopping
[INFO] [Message]: Pad: InputStreamSource:src type: STREAM_STATUS, stop, reason: wrong-state, reason: wrong-state
[INFO] cleanup

as you see above it gives error [ERRO] does not contain Theora video data.

I already tested it with a few ogv files but no success.

Curious if anyone ever was able to use this API before ?

Thanks

It didn’t really work back then so I doubt it will work now. Better to use established solutions like JavaFX media player: GitHub - empirephoenix/JME3-JFX: JFX Gui bridge for JME with usefull utilities for common usecases

Thanks for replying.

Unfortunately JavaFX media player only supports patent formats (H264, VP6).

Currently I am looking for royalty free options because I want to use them in commercial game.
Will inform you if I made any success.

You can use VP6, it is obsolete, you only need to have license for encoder, not encoded data or decoder, so use some online encoding solution, like zencoder. They do it well and they must worry about licenses.
The problem is that using VP6 contained in FLV you must use MP3 for audio (or not use audio at all), but you can play audio manually, not from player.

1 Like

Really !!
I did not know.
Thanks you let me know that. :slight_smile:

I am going to use it then.

Yes will use mp3.

Don’t use MP3, it is not free. Use OGG via JME’s audio and sync it manually with movie.

https://app.zencoder.com/docs/faq/codecs-and-formats/licensing

Additional information about licensing: As it’s said in above faq, VP8 is free. It’s because Google purchased On2, the owner of VP6, developed VP7 and VP8 to use it with HTML5 and made it free. In the meantime Sun purchased license for VP6 and made a decoder for JavaFX.

If you want to be 100% legit you can mail Google and ask if you can use VP6.

1 Like

In the long run I see libvpx with VP9 as the winner (I dont know about the audio though) but it is not so easy to integrate with jme

Hmm, I thought I can use it after patent expires. As declared here

http://www.osnews.com/story/24954/US_Patent_Expiration_for_MP3_MPEG-2_H_264/

MP3 patent expires in 2017.

But yeah, I can use OGG via JME’s audio and sync it manually with movie.

Interesting… I was reading about MP3’s licensing in 2016 ^^
I need to update. Thanks.