How to play video and audio from a video file in Java - java

I understand this question has been asked many times before, but after searching all of the answers seem to be outdated (by two or more years) so I thought it reasonable to ask it again.
What libraries are available to read and display video files (such as .avi and similar) in java? I am currently using lwjgl, and cannot easily change to a different library, so please limit suggestions to those compatible with lwjgl.
What I'm trying to do is create a fullscreen display using lwjgl, display the video (with audio synced) as an intro, then either when the video is finished or forcefully skipped continue to the main menu.

Related

How to embed a 10 second MP4 video in java GUI?

I've looked up multiple options for embedding a MP4 video into my GUI. I seen many people advise against using swing because it's old. I've done many GUI's with adding image icons and such but never tried embedding a MP4 video until now. Is there a simple way to embed my MP4 video into my GUI such as how Image Icons are added? Also is there a method that will keep this video on replay until the application closes? such as a video.repeat(true); or something of that nature? Thanks for all the help ahead of time.
I don't know if/how it is possible in pure Swing, but you can embed a JavaFX MediaPlayer in your Swing application, see details here: https://stackoverflow.com/a/16326393/1149528 or here: Can't play mp4 converted file - JavaFX 2.1

GIF Speed based per computer?

I'm working on a game engine, and want the option to play video to a jpanel or whatever. I've been trying to figure out HOW to do this, preferably using mp4, WITHOUT USING ANY 3RD PARTY SOFTWARE. The only option i've come to is using a combined gif and .wav series.
My question is, does a .gif play faster per computer? for example, if i get the movie synced perfectly on my desktop, would it have the odds of not being in sync with my laptop? would the .gif play slower/faster? If the answer is yes, how in the heck would i fix this?
Thanks!
Since you are building the video in a .gif then you should be able to just take the individual images and paint them at the desired frame rate in your application without using 3rd party software.
This would allow you to sync it with your .wav for sound.

How to play other video formats in JavaFX

I am busy with a movie/video-clip player/library.
I want to do this in JavafX. Almost 90% of the video clips is in AVI format. I cannot for several reasons covert the movies/video-clips.
I also want the program to mark the video files that were played, from start to complete, so that I will know what have been watched. So the program needs to be able to interact with the video player to know when the video has played to the end.
JavafX doesn't allow playback for AVI files. What's the alternative to be able to use this with? And how will I know if the video has fully played from beginning to end.
I read the following
Adding other video codecs / DVD support to JavaFX 2.2
Where they suggest I use portable VLC player. Is this the best way to use it in JavafX and if possible does the API have register hooks to register a method that can be triggered to know when the video has stopped?

Problem recording audio on Android and playing on Swing (PC)

I have an android app that records audio and does other stuff, and I wanted to make a PC applet in java to allow users to listen to what they record on their androids. I got everything to work, but came to a halt at the playing part. Android can only record 3 formats (MPEG4, AMR, and 3GPP). And I'm having trouble finding a java api or code to play any of those formats. Does anyone have any suggestions or solutions?
Thanks in advance.
On this thread you can find numerous java API to playback audio files :
Any good recommendations for MP3/Sound libraries for java?
Also, you probably want to write a desktop application, not an applet. Applets are an old technology that never really catched up (to be honest Microsoft helped quite a lot to kill that tech...).

Converting audio files(.3gp) to video with Album cover and uploading to YouTube

I have an audio file in .3gp format on my Android device which I wish
to upload to YouTube. I know that YouTube is a video upload site and
that I need to convert this sound file to video.
I just want an image to display all the time the audio is playing.
Google tells me there are number of tools that can help me. But I want
to do this via java code from my Android device.
Please help.
Thanks.
There are tools such as FFMPEG available for free that allow you to, essentially, mix and convert heterogenous streams. That is you can add a bitmap to a video, create video from slide shows and then add sound etc. (See a related question I asked here).
These programs can be executed from within java applications by making Runtime.exec(..) calls.
Sun has an example for stitching multiple JPEGs together into a movie, you can find it here. You should be able to take this example, (its fairly robust), and add what you need to it.
I recommend looking into the Java Media Framework (FAQ)
You can find a vast collection of sample applets/code at the Sun Solutions page. You can find the API on this page. I do hope this is compatible on the Android platform, as I haven't had any personal experience developing for it. But it might be a good place to start.

Categories