For some reasons I have to work under windows 10 OS with Android-Studio as IDE. My problem is that, exoplayer uses software and hardware decoders of Android-TV device to decode video streams.
Apparently, most of the Android-TV devices have no built-in decoder for decoding mpeg-2 sounds and therefore, the sound of the mpeg-2 streams are mute however, mpeg-2 videos are playing well. In order to solve such problems, I believe that I have to embed Ffmpeg extension into exoplayer. To do this, I followed the instruction of here under Windows PowerShell as recommended, but there are some problems.
First: What should be the value of HOST_PLATFORM variable for windows when using PowerShell?
Second: For unknown reasons I am receiving the following messages when executing Shell script "build_ffmpeg.sh".
What I receive when I execute shell script
Now, how can I embed ffmpeg extension for exoplayer (under windows 10 OS), enable it for decoding and solve these problems? My programming language is java. Thanks.
Note: Please tell me if you have any other (Other than embedding Ffmpeg into exoplayer) suggestions to solve my problem.
To build FFmpeg for ExoPlayer under Windows, you can use Git Bash for Windows to perform the building process.
All commands are almost the same (we'll get to the differences in a minute). Please note that NDK_PATH is the path of your NDK's folder (it's usually the version number, you can find it in default cases in YourAndroidSDK\ndk\yourNDKversion).
As for the differences, it's only for HOST_PLATFORM, you should use windows-x86_64, by inspecting the build_ffmpeg.sh, there is a line that says:
TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
The variable HOST_PLATFORM is only utilized to get the correct NDK tools for Windows. If you go and check the above path, you'll find a folder named windows-x86_64 under 'prebuilt'. That's what goes in HOST_PLATFORM.
If you get the NDK path correctly, HOST_PLATFORM correctly, FFMPEG_MODULE_PATH correctly, and last but not least the ENABLED_DECODERS, you should be able to build FFmpeg very easily.
If you don't want to go through setting the variables all over again, just edit the build_ffmpeg.sh file using Notepad, and edit the variable to make 'em be as you want without having to do it in the PowerShell terminal all over again.
Related
Is there any way to change the system volume on Windows with Java or CMD programmatically?
I've found some command lines for Linux and Mac, but so far nothing for stupid Windows.
Take a look at a form post on oracles website https://forums.oracle.com/thread/2390172 you can see it is not possible from inside java using native libraries.
Quote from the oracle post: "Because Java is cross-platform, it cannot do platform-specific stuff like changing the volume or whatever you want to do to control the OS. You need to use the operating system's unique API layer to do it."
For command line I found this utility that seems to have what you are looking for http://www.nirsoft.net/utils/nircmd.html
If you don't want to rely on 3rd party executables you could either make your own exe or make a dll and look into using JNI.
I am looking for a way to mimic operating-system (Windows in specific) actions through Java. Preferably, the program should run in the background, but it is not a big deal if it does not. I got the background part covered thanks to this question. I was looking for the following specific features :
Maximizing/Minimizing the currently active window. (Can be any window, not just the Java application window.)
Closing the currently active window.
Open installed programs, and system utilities like the calculator, paint, etc. (I figured out this one from this question.)
Shutdown/Restart (This one's done too, thanks to the question here.)
So, my actual question is:
Is it possible to minimize/maximize or close an application window from a java program? (in Windows)
Example Scenario:
Firstly the java program is started, and it runs either as a background process or as a window. Bottom-line is that it should be able to accept triggers like maybe a keyboard shortcut or microphone input to trigger the action. After that suppose a Chrome window is opened and is currently active. Now on pressing the pre-defined shortcut, the Chrome window will minimize/maximize or close.
If the answer to the question is yes, I could use some pointers to start with my application. Thanks!
What you need is like an OS shell programming interface.
In Java side you will define a few interfaces.
Another Java layer will detect which OS is used and will return an implementation of interface: Windows, Linux, Macosx.
Some functionality you can have with simple bash command: in windows cmd, in linux .. to many. Eg shut down, launch MSPaint, Calculator.
Other functionality you can have it with windows API: you will need to write some JNI functions and call it. eg minimize, maximize. It is possible.
Edit:
I see there is no accepted answer, although it is answered properly.
Here is a C# code which does what you need in Java.
Now you need to migrate this code to Java:
In your java class declare a function:
private native maximizeOrMinimizeWindowWithName(String windowName, boolean maximize);
Compile -it
use Javah.exe - it will generate the necesary .h files
Use a C editor, configure environment, use the generated .h file.
-include windows api headers
-load user32.dll
- do more stuf..
compile your C code to .dll
put the your.dll into your app PATH environment variable. ( windows has the . in path, linux not)
-text, bugfix,
for more info you should see a basic JNI tutorials.
-upvote accept :)
This can be initiated from Java, but not actually implemented in Java. In other words, it will take a lot of platform-specfiic JNI library code to get it working.
Java will give you almost no benefit for your use case; you should avoid it altogether for this project.
You should look into Autohotkey. It's an system dedicated to simulate user programmaticly.
Using AH scripts you can easily access all open windows, installed programs and even control mouse and keyboard.
I'm currently developing a programm with Java to interact with an Arduino module. Now in Windows, it's running pretty well so far (I receive what I expect; I can work with the data), but in Linux (Ubuntu in my case); it's like the opposite. I installed Arduino and rxtx-java packages.
When I tried to use the Arduino program to connect to the Arduino board, I had to set a softlink on the ACM module to some serial or USB module. For example,
ln -s /dev/ttyACM0 /dev/ttyS99
Otherwise it won't even show up in the list in the Arduino program. So what I did then was starting the serial monitor tool (Ctrl + Shift + M) and sent it my start sequence waiting for an answer. It worked without a problem there (it was binary data so I couldn't verify if it was correct, but I got an answer at least).
The next thing I did was trying to do the same with my program, so the Arduino was connected to the PC, the softlink was set correctly, the device listed along with two normal COM-ports I have in my PC in my program, and I tried to connect, but it didn't work.
No error, no nothing, simply no answer of the board. After I waited a couple of minutes, it still didn't do anything, so I disconnected it from the PC, and then I got an array of zero-bytes as the answer.
What could cause this kind of problems and how would I fix it?
Thanks for your help
Volker
PS: the program is a jar file with all libraries/dependencies included
EDIT:
Hardware is an Arduino UNO Board Model R3,and on windows i'm using Arduino 1.0 to program it
Your symlink to /dev/ttyACM0 is double dubious:
Disconnecting+reconnecting or powering off+on might change the number of the dev.
ttyACM usually refers to modems, not to plain USB-serial converters like that used by Arduino (at least those with the FT232 chip). I would expect something like ttyUSB0. For those you also would not need a symlink.
If you installed from the Ubuntu packages you're bound to have problems. I tried this first myself only to find that there are serious issues. I would recommend downloading the most recent version of the IDE arduino-1.0-src.tar.gz.
You'll notice it's the source, I think you'll like it better that way. Or you can get the repository from Git, you'll find that information plus how to build the IDE in Building Arduino, Steps for First Time Setup. Besides the fact that the Ubuntu distribution version is buggy, it's also like old, big time.
I'm trying to build a pipeline with gst-launch in Windows 7 that will view a stream from a VC500 Video Capture device (Captures composite video and inputs to computer via USB). I think my biggest issue here is the fact that it MUST be done in Windows. I'm finding a lot of the plugins for gstreamer-java are supported in Linux instead of Windows. So I'm having issues finding the element and syntax to get this working. Any help would be greatly appreciated. Another thing is I don't have to use the gstreamer framework for this, it just seems to be the easiest. If anyone knows another good media framework with good Java bindings that might be better let me know? Haha. (Tried DirectShow, VLCJ, neither are very stable for Java.)
Thanks a lot.
Brayden
EDIT:
From more reading I'm pretty sure the element I need here is ksvideosrc.
So I've been trying:
gst-launch -v ksvideosrc ! autovideosink
But I get:
ERROR: from element
/GSTPipeline:pipeline0/GstKsVideoSrc:ksvideosrc0:
could not start capture Additional
debug info:
..........\Source\gst-plugins-bad\sys\winks\gstvideosrc.c(970):
gst_ks_video_src_create ():
/GstPipeline:pipeline0/GstKsVideoSrc:ksvideosrc0:failed
to change pin state to KSSTATE_RUN
Execution ended after 1000000 ns.
Alright well.. I ended up using Direct Show Java (dsj) instead. It was able to play video from the capture device very easily.
I am calling MATLAB with Java but I want to suppress the command window of MATLAB to make users feel that I use only one program which is Java.
In addition I read about something called standalone executable for MATLAB, but it didn't work; will that help me?
Check out the Matlab Engine. The engine runs in the background (without a GUI or visible command-line) and you call it from your code. The examples are in C and Fortran, not Java, unfortunately. I got it working with Python once but I don't recall the details.
Also see: 2 ways to use the engine with Java.
ETA: 'matlab -r "statement"' on the (Windows) command line will execute "statement" in Matlab. My Python hack was putting my Matlab code in a .m file and my data into a text file referenced by the .m file then sending 'matlab -r myFile.m' to the Windows command line. See the matlab Windows command. Again, there's no visible GUI for Matlab this way.
When you say "calling it from Java", are you shelling out to Matlab for batch computations, or do you want to embed a long-lived Matlab session in your process and call M code repeatedly from Java code? What OSes do you want to run on?
Matlab has some deployment tools that let you embed a Matlab interpreter and a collection of Matlab source code inside a host language, such as C/C++ or Java. This is what the "Matlab compiler" is - not a real compiler, but a tool that packages a Matlab runtime along with .m source code in a package that looks like a DLL or application. A Matlab "standalone application" is Matlab code that has been packaged this way along with a thin C wrapper that calls an application entry point in your M code.
The Matlab Java Builder is a similar thing that bundles this deployed Matlab engine inside a Java class. If you want to get a license for it, that could make it easy and cosmetically clean to embed Matlab inside your Java application. This is probably what you want.
These deployed Matlab apps do not have a command window because they're intended to blend in with your application. They live in the same process. And, importantly, they do not require license fees for running the deployed app. Shelling out to regular Matlab requires all users running it to have licenses for Matlab and each toolbox that is used.
If shelling out, the "matlab -nosplash -nodesktop" command line will suppress the GUI on Unix. But on Windows you'll still get a minimal Matlab command window. The "-automation" switch on Windows will at least make it minimized. I don't know a way to suppress it entirely on startup.
However, once Matlab is running, you can take advantage of the fact that the Matlab GUI is itself implemented in Java, and have it hide itself. Get your Matlab session to run this hidematlab() using the "-r" command line switch or a startup.m. Note that this is a hack using undocumented Matlab internals and is surely unsupported by MathWorks.
function hidematlab()
%HIDEMATLAB Hide the main Matlab desktop window (HACK)
dtWin = desktopwindow();
if ~isempty(dtWin)
dtWin.setVisible(0);
end
function out = desktopwindow()
%DESKTOPWINDOW Find the main Matlab desktop window (HACK)
wins = java.awt.Window.getOwnerlessWindows();
out = [];
for i = 1:numel(wins)
if isa(wins(i), 'com.mathworks.mde.desk.MLMainFrame')
out = wins(i);
return;
end
end
Beware of gotchas when shelling out on Windows, where Matlab is inherently a GUI app. If your M code throws errors that bubble up to the top level or segfaults, you may find your Matlab session hung, waiting for nonexistent user input, instead of returning you an error.
I don't know of a way to do what you're asking entirely. If your script does an exit manually instead of naturally terminating, you may be able to start the script so that the window that pops up is minimized.
See Launch Application in a minimized state from Java
Start the script with
matlab -nojvm -nosplash -nodesktop -wait -r script_name
You will want the "-wait", otherwise MATLAB will immediately return.
See How can I stop MATLAB from returning until after a command-line script completes?
matlabcontrol is a Java API which will allow you to interact with a running session of MATLAB. It will launch the session and then you will be able to invoke eval and feval as well as set and get variables. By default the session of MATLAB will be visible, but it can be hidden. On Windows it will not be entirely hidden because that is not supported by MATLAB, but it will be started minimized and no splash screen will be shown. To get started using matlabcontrol, take a look at the walkthrough.