I'm trying to use JMF (Java Media Framework) to play a video. I've tried sample code from four different websites now. I'm using a Mac running Lion.
Everytime I load an mpg file I have, I get:
Unable to handle format: MPEG, 352x240, FrameRate=29.9, Length=126720
What does this mean? Are there problems with JMF? I'm using the cross platform version.
The cross-platform version will probably not support too many formats. There are performance packs which might help. But there isn't a performance pack for MAC and probably never will be.
You can try Jffmpeg, which provides MPEG codecs (among many other formats) for JMF. However, bear in mind that the last release is 2006.
Another alternative if FMJ.
Related
I am using the javax.comm API to help my program communicate with hardware over serial port. I am using the Windows 7 and NetBeans IDE 9.
I used the common Java program to check the available ports on my PC. The program compiled and ran without error. However it returned nothing.
What can I do to use the javax.comm API on Windows? It seems win32com.dll does not work with a 64-bit operating system.
This is how I got it to work.
I've tested it using JDK 1.6 (32bit) on my Windows 7 64bit machine.
Install 32bit JDK.
Copy 'win32com.dll' to JDK_HOME\jre\bin.
Copy 'javax.comm.properties'to to JDK_HOME\jre\lib.
Copy 'comm.jar'to to JDK_HOME\jre\lib\ext.
Now run your program and it should work.
Recent 2.2pre versions of RXTX include binaries for 64-bit windows. I think the latest RXTX information source has changed to this: http://rxtx.qbang.org instead of http://www.rxtx.org though.
At one point the RXTX library included drop-in support for using the javax.comm api. I'm not sure if it still does, but the main change then to use the "native" RXTX packaging was primarily just a package name change.
it seem the win32com.dll does not work with 64-bit Operating system
I think that is correct. In fact, according to the relevant download page, Oracle no longer supports the javax.comm API for any Windows platform.
However, I found this page which has a 64bit build of the DLL, among other things.
EDIT
By an astounding piece of research (i.e. following the links and reading stuff) I found the download page for the latest RXTX, which claims to have binaries for various platforms. If your platform is not there, try building from source. If that doesn't work, consider investing the effort in making it work.
I've integrated RXTX libraries into some of my earlier projects and i found out this bug it has while working with comm ports under windows, so you might want to check this first before going into some serious app design.
Communication works fine, never had any problem with that, but once you open the port you cannot close it and reopen, if you use method provided for closing port, your app just hangs, no exception no nothing. I found later the same behavior described by users on web, but never really found the solution to this problem.
Again, this might help you save some time, check it first.
Latest release, which is this http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip, doesn't have this issue no more. Unfortunately i think its solved only for windows, its still there on Linux binaries, and i haven't tried it on mac.
Have you got a look on RXTX ? I think it is still active.
I had this issue...on a 64 bit machine..running windows 7
a legacy application developed in jdk 1.4, for 32 bit windows... and using the win32 comm api binary
i tried the RXTX binary for 64 bit and i was able to communicate with my device on some level... but... there were other problems as my application referenced a version of the jpos library that internally was using the comm-api (had import javax.comm.*... in some Serial...Listener class)....
I installed a 32 bit jdk and setup the comm-api binaries for 32 bit windows as directed here...setup comm api on windows
all was fine afterwards
You might be interested at an alternative library I've authored: http://code.google.com/p/jperipheral/
I want to take an image from webcam. How can I do this?
If is there any sample codes for your advice library, it's better than other for me.
I examined these:
Jmyron
Java Media Framework
JavaCV
lt-civil
These are not useful. These do not work or do not have sample code.
Have you got any advice?
Try this project:
http://github.com/rladstaetter/isight-java/
and the corresponding blog post
http://ladstatt.blogspot.co.at/2013/04/using-isight-camera-with-javafx.html
Keep in mind that you'll have to have the correct opencv dll for your architecture (x64)
I stripped down OpenIMAJ Core Video Capture Library to get images from webcam. It works well on my macbook, linux deskdop and windows 7 env.
You don't need to install anything, two jars are all you need. You can find the example from my site:
http://www.sleepingdumpling.com/blog/download/jvideoinput/
Here is a link to a Demonstration JavaFX Camera capture application using LTI-CIVIL
You are correct that the LTI-CIVIL library is 32 bit only, so perhaps not useful In your case if 64 bit is an imperative.
I want to build java app, which will record some application. Could you provide me any links or solutions, which codecs should I use for windows , mac and linux, should I use three diffirent codecs for each OS or there is standard codecs for every OS. I want to create video in divx codecs or avi, but preffered is flv. I'll be thankfull if you help me.thanks. (and: it has to be java app)
Take a look here for a java codec pack for JMF
Well...you can refer Java Complete Reference book where there is a chapter dedicated to multimedia...maybe you'll get some info from that...I'm not sure about any other resource...
When I run FreeTTS examples, I get this error:
LINE UNAVAILABLE: Format is pcm_signed 16000.0 Hz 16 bits 1 channel big endian
In this post, Freetts problem in Java
someone claims it's a known Linux/Java sound bug and has a workaround,
linking to http://forums.sun.com/thread.jspa?threadID=5189363 .
But this link does not work anymore since Oracle screwed it.
Archive.org seems not to have this page archived.
Does anyone have the workaround / patch for FreeTTS?
Thanks,
Ondra
Linux's ALSA is one large, complex API. OpenJDK and Sun's JDK seem to use it differently. Most modern Linux distributions also use PulseAudio, which virtualizes ALSA so that all audio goes through PulseAudio for software mixing before going to ALSA for playback.
When nothing is accessing the sound card, and Java is the only user, it tends to work. However when something else has the sound card open, Java apps quickly break with both your error and "javax.sound.sampled.LineUnavailableException: Audio Device Unavailable".
One potential workaround is to enumerate all mixers in the system with AudioSystem.getMixerInfo(), then try to open the line with AudioSystem.getSourceDataLine(format, mixerInfo) for the mixers you want. Some will work better than others. In particular the "Java Sound Audio Engine" and the "default [default]" mixers, if they exist, tend to work.
The only solution if you don't want to modify the FreeTTS source code though, is to install pulse-java. This registers a special PulseAudio sound provider, which bypasses the ALSA virtualization and goes directly to PulseAudio. Ubuntu installs this as part of its OpenJDK package.
Someone should really patch Java Sound to play with ALSA in a friendlier way. For one ALSA device names should be prefixed with plug: to get ALSA to convert sound formats and sample rates on the fly. And the other rules for safe ALSA subset should also be followed.
Hmm, I had better luck googling after asking the question, so...:
http://workorhobby.blogspot.com/2011/02/java-audio-freetts-line-unavailable.html
A big thanks to the author.
Update: Actually, this is not a nice workaround since it will keep FreeTTS on hold until the line is free.
FWIU, the mentioned patch had better solution - not demanding exclusive access or such.
Update: I've compiled a FreeTTS troubleshooting page.
A program based on FreeTTS, the free text-to-speech engine for Java, was getting occasional errors
"LINE UNAVAILABLE: Format is ..."
Turns out there is no Java Exception or other mechanism to detect this error that occurs inside the FreeTTS library. All you get is the message on System.out, so there is no good way to react programatically.
Workaround: Configure the FreeTTS audio player to attempt accessing the audio device more than once until it succeeds. In this example, a short delay of 0.1 seconds is used to not miss an opportunity to grab the audio device; we keep trying for 30 seconds:
System.setProperty("com.sun.speech.freetts.audio.AudioPlayer.openFailDelayMs", "100");
System.setProperty("com.sun.speech.freetts.audio.AudioPlayer.totalOpenFailDelayMs", "30000");
If the audio device is permanently used by another program, there is of course no way to get access. Under Linux, this command will display the ID of the process that is currently holding the audio device, so you can then try to get rid of the offending program:
/sbin/fuser /dev/dsp
Regarding the link screwed by Oracle - given that older SO answer you refer mentions horrendous java linux sound bug that is still not fixed and suggests to check the third post, it is likely that lost thread was migrated to:
https://forums.oracle.com/forums/thread.jspa?threadID=2206163
above thread starts with reference to JMF Bug 4352921 at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4352921_
third post in the thread says "Yes, according to the API docs it's a "catastrophic" error from which no player can return safely. Which is why it's so strange to be able to trigger it so easily..."
workaround to the problem discussed is described in the sixth post as follows:
I stumbled upon a blog post that suggested that Java needs to be told to use the OSS libraries as it's not yet up to ALSA. The command to use was "padsp" which forces the application to use OSS. So if I call "padsp jmstudio", it now plays and mixes the audio just fine. I tried it with my application also, which prefetches a number of players in the same JVM, and they all prefetched perfectly. So it would seem, for now, JMF applications on Linux may need to be called through padsp.
I need an extremely efficient webcam library (I'll explain later) that works on all platforms.
Basically there will be two webcams and I need to alternate between them at a very fast rate (a least 50fps, it has to be a fluid video still)
Anybody have experience in this field and have some suggestions?
While developing my Webcam Capture project I've tested several frameworks and decided to use part of OpenIMAJ framework. I actually had to extract part of its core-video-capture subproject and refince code to remove all necessary dependencies it has. When I included refine code in my project I was able to stream 250 FPS (EDIT: due to bug in Windows impl) 50 FPS as BufferedImage objects (on Windows XP, without painting, just fetch image from webcam). I can honestly recommend it since it is compatible with most operating systems - Windows (x86 and x64), Linux (x86, x64 and ARM), Mac OS. If you are interested, you can find refined code here.
JMF is also very fast, but its pretty outdated and not maintained any more. It's not portable - when you want to use it, you have to install JMF.
I don't recommend JavaCV, it require huge OpenCV installation package (~100MB), have no Java documentation and it's not portable.
LTI-CIVIL / FMJ are also outdated, not being maintained any more.
VLCj work correctly only on Linux (since it is using V4L4j) and you have to have VLC installed on your PC (not portable).
I have used OpenCV for Java ( http://ubaa.net/shared/processing/opencv/ )
It is very "user-friendly", but I do not know the exact parameters about its efficiency.
A while ago I used Java Media Framework to process and save stream from webcam (Didn't had any performance issues with it). Maybe it could help you in your task.