YUNPM - a Java Media Player


Exception in thread "main" java.io.IOException: Cannot run program "./res/ffmpeg32.exe": CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessBuilder.start(Unknown Source)
	at net.indiespot.media.impl.FFmpeg.extractMetadata(FFmpeg.java:73)
	at net.indiespot.media.Movie.open(Movie.java:47)
	at com.drabiter.test.VideoPlaybackTest.main(VideoPlaybackTest.java:56)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(Unknown Source)
	at java.lang.ProcessImpl.start(Unknown Source)
	... 4 more

I tried above code but can’t find the file, and I think the problem doesn’t lie on my path. Also, is there any way to use this version without lwjgl, like your previous simpler sample code (which uses “oldskool controls”)?

ReBirth, its not finding the ffmpeg binary, not lwjgl. This could be because it does not have exe permission, or more likely because you are running the code without the bin directory in the launch directory of your application.

@princec - Yeah it’s great when someone lowers your cost for you. Only reinvent the wheel if you can’t find one in the right size…and then only after you’ve considered if you’re look for the right sized wheel.

@delt0r
It’s not something to do with lwjgl :slight_smile: on last sentence I asked why riven’s previous code which is shorter can’t be used. I fixed problem on that post, I didn’t see that slash. However I got this now

Exception in thread "main" java.lang.IllegalStateException: failed to find framerate of video

Version 0.8.4 of YUNPM

Changes
[x]Changed the directory structure for libraries
[x]Throwing exception if it cannot find the right ffmpeg version, instead of falling back to non-existing ffmpeg version. :persecutioncomplex:

Download files
[x] http://indiespot.net/files/projects/medialib/ (please download indiespot-media-0.8.04-all.zip)

The previous version used LWJGL as well. The controls are independent of the rendering engine.

I added JInput controls (part of LWJGL) to handle pause/resume (spacebar) and volume (scrollwheel), as part of v0.8.5

Then how about these code


VideoRenderer videoRenderer = new OpenGLVideoRenderer(movieFile.getName());
      AudioRenderer audioRenderer = audioEnabled ? new OpenALAudioRenderer() : null;

      if (videoRenderer instanceof OpenGLVideoRenderer) {
         OpenGLVideoRenderer opengl = (OpenGLVideoRenderer) videoRenderer;
         opengl.setFullscreen(false); // uses current desktop resolution
         opengl.setVSync(true);
         opengl.setRenderRotatingQuad(true);
      }

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

they dont work anymore right?

also I dunno what the cause of above exception is until now.

I also don’t know what the cause is, which is why I made the code throw an exception with the required information, instead of useing a fallback that was bound to fail.

Indeed. Version 0.8.x is incompatible with version 0.7.x

Thanks. FYI I use your test code (inside the jar) and same video (that pigeons vid). Will try with above code.

Just download the latest zip and the latest jar. (and use readme.txt if the patch process is not too obvious)

@riven
I tried the lastest zip, and it runs well after I changed the exe. Now that’s rock :slight_smile:

Thanks for testing!

Can you explain what you mean by changing the exe? Did you swap the 32 and 64 bit versions, to make it load ‘the other’ exe?

No, on previous version (I forgot because I overwritted it) I had to add .exe extension to the only one ffmpeg32 file (became ffmpeg32.exe). The size is different from current dist which contains both 32 and 64 bit versions.

It seems I screwed up the previous zip then. Thanks for reporting!

I know it’s an a-few-months-old topic but this looks really useful. Have there been any changes since 0.8.4?

Nope :slight_smile:

Please report it if anything is broken, or if an obvious feature is missing!

I started a discussion on this thread at the JME3 forums, will see what the developers there think about how practical it will be to integrate before I do anything.

http://jmonkeyengine.org/groups/general-2/forum/topic/playing-introloading-video/?#post-194583

Version 0.8.7 of YUNPM

Changes

  • Added support for video frame dropping, in case of hickups
  • Using 2D projection by default in the demo app, keep SHIFT pressed for 3D view

Download files

Snippet from demo app:


			if (movie.isTimeForNextFrame()) {

+				final int maxFramesBacklog = 5;
+				int framesRead = 0;
+				do {
+					if (framesRead > 0) {
+						// signal the AV-sync that we skipped a frame
+						movie.onUpdatedVideoFrame();
+					}

					// grab the next frame from the video stream
					textureReceiveTook = System.nanoTime();
					textureBuffer = movie.videoStream().readFrameInto(textureBuffer);
					textureReceiveTook = System.nanoTime() - textureReceiveTook;

					if (textureBuffer == null) {
-						break;
+						break outer;
					}
+					framesRead++;
@@				} while (movie.hasVideoBacklogOver(maxFramesBacklog));
+
+				if (framesRead > 1) {
+					System.out.println("video frames skipped: " + (framesRead - 1));
+				}

				textureUpdateTook = System.nanoTime();
				glTexSubImage2D(GL_TEXTURE_2D, 0/* level */, 0, 0, movie.width(), movie.height(), GL_RGB, GL_UNSIGNED_BYTE, textureBuffer);
				textureUpdateTook = System.nanoTime() - textureUpdateTook;

				// signal the AV-sync that we processed a frame
				movie.onUpdatedVideoFrame();

				videoFramesLastSecond++;
			}

I wrote an Example of GstLWJGL, another media player to use with Libgdx.
I should post it D:

Well you gotta understand the code. Its not hard but if you cannot program at all…

I have a feature request, can you add a feature so I can set the ffmpeg location where the binaries are? Currently its hard coded

EDIT : One more request. If there is no audio in the video it currently throws an error as it tries to use a null InputStream in the AudioStream (line 52, in Movie.java). Can you add some provisions for this scenario?

Thanks

Ziozio