YUNPM - a Java Media Player

There is a shortage of code flying around that works on just the 5 machines i test on. What is the point if you can’t deploy easily?

Even apps that use gstreamer have a huge list of “you need to do this with your local gstreamer for xxx to work” for more than half the faq. Its not like i haven’t tried these things. They mostly just don’t work consistently. And claiming that “they can”… well i don’t care if they won’t even work on 5 very similar machines i test on. Claiming PEBKAC is not winning points either (yes i was told that when gst seg faulted on one of my machines).

mplayer works consistently, which is based on ffmpeg. ffmepg works well too. So static binary’s with pipes seems like a great idea.

Don’t pay too much attention to what I’m saying, I literally have no idea what I’m talking about :slight_smile: That might sound like sarcasm, but it’s true. I didn’t do any field research, didn’t even google for existing solutions, just wrote some code.

When I browse through the (j)gstreamer code, it feels like it’s rather lowlevel, introducing many new concepts - like a bus that is somehow crucial to whatever it is crucial to*. If there is anything I learned from dumping my code/projects on JGO, is that the amount of code to get it to work should be less than 10 easy to grasp lines or it will be discarded.

  • among similar lines, their example ‘hello world’ code contains this:
GstElement *pipeline;

Now wtf is it? an element or a pipeline? They are not synonymous in the slightest, eventhough interchangeably used in the tutorial.

gst_bus_timed_pop_filtered(...)

Say what? Can I say ‘poor API design’ yet? Do I really have to read method specifications before I can grasp the tutorial?

Odd. The first result in google for ‘gstreamer’ is gstreamer.net, which looks… pretty old school. ???

I spent I don’t know how long at Sony trying to get all these solutions to work. In the end Gstreamer is effectively an amateurish effort when compared to ffmpeg which is the granddaddy of video tools. Likewise VLC is similarly ramshackle.

At the end of the day Java only needs support for about 2 formats to be useful to 99.999% of any of us in here - Theora and MPEG2. Whichever one of these monoliths does those two perfectly correctly wins.

Cas :slight_smile:

As of late the .com domain is all new and now the way to go, unfortunately the old page still exists.

I have always said Bink would be killer - at least the principle…

Just a short question: Technically, by law, you are not allowed to bundle a media file with a licensed codec right ? so even bundling a mp3 isnt allowed just like that. Theora and Vorbis are free which is why I use them. I love H.264/MPEG-4 AVC but I’m not entirely sure… is it open and ok to use ? maybe the decoders are licensed ? I assumed only Theora&Vorbis were truly open n stuff.

I will release a package like this with the GStreamer stuff we came up with.
@nsigma I have only Win32 & 64 on hand… I know you posted the mac binaries which are part of praxis, but in case of linux, I never added those yet as I said.

@delt0r The stuff we, mainly nsigma wrote is very reliable and stable. We package gStreamer and it never failed on any machine or desynced. The worst I could ever do is tearing on really weak machines…

I have asked… properly asked. at least for H264 you require a license to encode/ to decode and on the transport layer. So yes if you include H264 files and a decoder, you need to pay for both.

That is what you have to agree to when you get a license for the patents.

I don’t know why so much fuss is made over H264. Once you have bitrates that don’t look like total crap, it does not perform any better than even mpeg2 (or theora). Sure it hides crap better at low bitrates, but then whats the point of HD if my effective resolution is more like half that? Encoding at a lower resolution with higher quality works better IMO and hides the artifacts better when scaling up anyhow.

I intend to use theora.

Yeah lets do that.

Not to mention that you don’t get JPEG compression artifacts. >_> I’m waiting for this until I try it. :wink:

ah yeah maybe we I didn’t have any mac binaries

and not sure how to “extract” them from a dmg file - So I could basically just release the windows thing

Hm I beg to differ about H264 quality. Bit for bit it blows any other format into the weeds, pretty much, at any significant quality level. But that’s in the digital video archiving / editing world, where I came from.
In a game? Who cares. MPEG2 is good enough; Theora is just yummier because it’s unencumbered.

Cas :slight_smile:

just to let others know. Currently this works really well. On linux. Windows… not so much. ffmpeg does not buffer writes to pipes, so on windows its not good for 1080p or anything like that.

To avoid confusion, that refers to the RGB streamer, not the MJPEG streamer - so we’re working on it, while everybody else can play 1080p just fine with the current version.

I’m using 100% jpeg quality, so the artifacts are really hard to see.

Version 0.7.5

  • Pause, resume (from any thread)
  • Adjusting volume (from any thread)
  • Removed MJPEG transcoder (credits: delt0r for finding the commandline args to stream rgb8)

Download files
[x] http://indiespot.net/files/projects/medialib/

Hilarious sample code


class VideoPlaybackTest {
	public static void main(String[] args) throws Exception {

		File movieFile = new File(args[0]);

		VideoRenderer videoRenderer = new OpenGLVideoRenderer(movieFile.getName());
		AudioRenderer audioRenderer = new OpenALAudioRenderer();

		VideoPlayback playback = new FFmpegVideoPlayback(movieFile);
		playback.startVideo(videoRenderer, audioRenderer);

		/**
		 * oldskool controls!!
		 */

		BufferedReader br = new BufferedReader(
			new InputStreamReader(new BufferedInputStream(System.in)));

		while (true) {
			String line = br.readLine();

			if (line.equals("mute")) {
				playback.setVolume(0.0f);
			} else if (line.equals("half")) {
				playback.setVolume(0.5f);
			} else if (line.equals("full")) {
				playback.setVolume(1.0f);
			} else if (line.equals("pause")) {
				playback.pause();
			} else if (line.equals("resume")) {
				playback.resume();
			} else {
				System.out.println("wait what?");
			}
		}
	}
}

Two performance-related contributions:

PBO texture updates: OpenGLVideoRenderer (much faster, especially for HD videos)
Minor stream reading optimization: Rgb24VideoStream (1 temp buffer instead of 2)

Version 0.7.6

  • Significant performance increase for sending RGB8 to GPU using PBOs (credits: spasi)
    (observed performance increase: 5ms -> 1ms for ‘rendering’ phase of 720p video)

If you don’t mind, I’ll keep that the way it is. I think that additional byte[] results in more readable code, and doesn’t affect performance.

Surprised no mention of WebM / VP8 as a useful unencumbered format - surely better than Theora anyway?

That’s comparing apples and oranges (not to mention GStreamer and VLC’s use of FFMPEG underneath). Interested (genuinely) in why you consider it amateurish, and when you last looked at it. There’s been a lot of work and investment in it more recently, and it’s gaining a lot of traction - a few years ago I may have agreed with you.

The bus, element and pipeline terminology does make sense if you need to look into the low level stuff, but for just “getting things done” :slight_smile: there’s a number of higher-level constructs that automatically set things up - you basically just need to use PlayBin2

The basics of playing a video file are lines 41-56 here - http://www.java-gaming.org/index.php?action=pastebin&hex=54a6b8d341c

Thanks for the backup that I’m not just spouting crap. :wink: Also noticed you’d posted the code up here - http://www.java-gaming.org/topics/gstreamer-in-lwjgl/24852/msg/241915/view.html#msg241915 - so now you can all test it and prove I am spouting crap! ;D

btw - while thanks for the credit, most of this code (the bit that links in local GStreamer libs) is ported from Processing code by Andres Colubri - I just made it work outside Processing, and fixed a couple of bugs. The actual write to texture could be improved a lot - I just did enough fixes to what Cero had - but it works.

WebM/VP8 are relatively young even compared to Theora and their legality is still questionable. I admit it’s been 2 years since I looked at gstreamer so I expect things have moved on since then; but then, ffmpeg was already working perfectly back then too.

Cas :slight_smile:

Version 0.7.7

  • Attempts to use PBOs, and rolls back to normal texture updates when PBOs are slower (performance degradation reported by kappa)
    (video starts with 5 frames doing texture updates, then switches to PBO for the next 5 frames, then picks the fastest)

Download files
[x] http://indiespot.net/files/projects/medialib/

So in this case, even if we dont use H264 files but Theora with “YUNPM”, we still could not bundle it legally for free with our game, because it includes a H264 decoder.
If its possible to seperate those parts, it would work out. With VLC and GStreamer we have all these dlls and can delete them one by one, depending on license and requirement.