In-browser video (de)coding and processing - java

For our web app we need some (preferably) client side video processing.
I think of the following workflow:
ask a user for a video file
decode it
do some processing on selected frames
combine these frames to the new video
encode it
upload it to the server
play it to our users
Reasons to do this client side:
output video is much smaller, so we have to upload less
video processing is too costly for the server, we prefer to use client's CPU
It is OK to install something once but then everything should work as an ordinary web app.
I've spent few days googling, but it is just too much to digest. So I ask for help.
Here are my findings/assumptions/questions.
Is there a simple way to do it with Flash?
1.1. Can access user-selected file from local file system
1.2. Has some decoders built-in, but these are rather specific and do NOT cover common video formats
1.3. Can NOT use locally installed codecs
1.4. It is impractical to implement codecs in ActionScript, so there are no such libraries
1.5. Can process frames
1.6. Has built-in coder(s)
Is there a simple way to do it with Silverlight?
2.1. Can access user-selected file from local file system
2.2. Has some decoders built-in, but these are rather specific and do NOT cover common video formats
2.3. Can NOT use locally installed codecs from in-browser sandbox
2.4. Can bring external executable (ffmpeg) to the in-browser sandbox but can NOT run it
2.5. Can only use DLLs specifically built for Silverlight runtime inside in-browser sandbox, so ffmpeg proxy (COM?) and alikes are of NO use
2.6. Can be right-click-installed from web page and maybe #2.3, #2.4 or #2.5 will work, but this will NOT make on-page app work, user will need to run it separately outside browser
2.7. It is OK to implement codecs natively (port ffmpeg?), but I was not able to find such a pack
2.8. Can process frames
2.9. Has built-in coder(s)
Is there a simple way to do it with Java?
3.1. Can access user-selected file from local file system
3.2. JMF has basic codecs built-in
3.3. Jffmpeg could add more codecs
3.4. Can process frames
Is there something else that could do the job?
Looks like due to #1.2, #1.3 and #1.4 Flash is not an option.
Looks like Silverlight could do the trick if only there exists natively implemented codecs pack.
Java looks most promising.
Before diving into it I still want an answer about Flash (due to install base) and Silverlight (.NET already used in the project).
Please advice if my findings/assumptions/reasonings are correct.
Thank you.

Related

Java SIP Plugin for Cordova or Phonegap for Audio and Video streaming

I've been doing some research on Phonegap and Cordova, it seems there is no support for creating apps that have SIP and VOIP functionality since HTML5 and Javascript have little or no support for these protocols (webRTC and websockets are not yet supported on most mobile phone browsers). However I found out it is possible to create and use Plugins in order to use native functionality of the Operating Systems (iOS and Android in this case).
My question is that, if for example I write native JAVA codes for my Android-Phonegap application, will I be able to use it as a plugin to stream audio and video in my Android-Phonegap application? what are the limitations of using a plugin (with native functionality) in Phonegap or Cordova? Most of the plugin codes I checked online had a "Result" in the end, does this effect streaming of Audio and Video?
Thanks in advance.
A proof-of-concept Cordova app that uses SIP.js with the PhoneRTC plugin to make WebRTC calls over the internet.
https://github.com/joseph-onsip/sipjs-cordova
Video.... I could potentially see a problem... BUT! HTML5 already has support for that so its OK. If looking to do SIP Video calls, look below.
You have HTML5 SIP clients that have been made:
http://sipml5.org/
It is Open Source. I haven't used it, but I cannot imagine that the back-end of the codebase wouldn't be portable to mobile.
Emdedded SIP - I would take a good long look at the code used in LinPhone (http://www.linphone.org/eng/download/git.html) and CSipSimple (https://code.google.com/p/csipsimple/) for your Java plugin Side ( You will need to build the required C libraries and use them as well ).
Now, PhoneGap provides a great Audio/Video Capture plugin.
https://github.com/apache/cordova-plugin-media-capture/blob/dev/doc/index.md
What you can do is integrate the Stream with some of the returns and tie-ins on the Media Capture plugin.
So, you have two options.
Here you have a SIP plugin for Android devices. Hope it helps!
https://github.com/lglossman/SipManagerPlugin
Anything you need don't hesitate to contact me...

Which option is suitable to replace Java Applet?

I would like to replace Java Applet which currently needs to use client's resources, i.e. external readers, and to communicate with a server via socket.
Reason:
1. I have thousands of client machines using this Java Applet program, and most of them are running out-dated JRE. When the Java Applet program is updated / added new features, all client machines will need updating the latest JRE.
Expected Solution:
The Java Applet program would be expected to be replaced by a web-based application, which allows to compile and run source code at client's side such that the new web-based application could still use client's resources and communicate with server via socket.
Can I use JavaScript to achieve it?
I would very appreciate your help/suggestion for this problem. Thank you!
JavaScript is a scripting language that gets evaluated in the browser.
I would not describe it as compiling and running but yes, it does mean you can run code in the client and is commonly used to create applications that run in the browser.
There's a staggering amount of frameworks that you can use to write your application. Take a look at the TodoMVC site to see the same TODO app created using several different frameworks.
If you come from Java applets, GWT may be interesting to look at.
If you wish to let the JavaScript client listen for messages from the server, take a look at websockets.
The smart card reader is going to be a problem, though!
See Architectures to access Smart Card from a generic browser? Or: How to bridge the gap from browser to PC/SC stack?
By the way:
The real issue with outdated JREs is not that your code will not run on old JREs, you can create perfectly fine applets using java 1.4 or java 5. Any libraries you may need you can deploy alongside your applet. The pain is a security problem. Anything but the latest version Java plugin is getting actively exploited and puts the user at risk. Occasionally, even the latest version is not safe.
try socket.io
I think this is the latest technology you can use to communicate with client browsers. it support the latest browsers and mobile browsers too.
hope this will help you.
Javascript has become very powerful with HTML 5.0. Here is a list of new elements that you can use to access all kinds of resources, including local files, audio, video, GPU rendering (canvas + WebGL) and GPU compute (WebCL). Here are even more things you can do, including database connections and networking. You can even create offline Javascript applications.
jQuery and jQuery layout make robust GUI development a lot easier. Rich tool suites, such as Google Closure offer optimization and a compiler for improving performance and detecting obvious mistakes early in the development process.
W3 offers useful stats for making an informed decision on how many users on average have access to which features. Note that the most annoying guy in that list arguably is IE8 due to it's lack of proper HTML 5.0 support.
In case you want to stick with Java, then one alternative would be to use my http://bck2brwsr.apidesign.org project. It's goal is to create small Java that can run in 100% of modern browsers without any plugin installed.
There are Java bindings to HTML (via knockout - one of the four most popular frameworks for HTML5) and that is why one can code whole business logic in Java and just render it via HTML. Should be enough to replace most of the applet UI.
In addition to that there is an experimental API to render on HTML canvas. People use it to write Java games that run in a pure browser.
There is a simple way to communicate with server via JSON REST API or via WebSockets. A live example is here.

What is a good Java media library?

I want to be able to play video files that were downloaded from a web server, as .mkv files, in a Swing application. What is a good library for doing this? Also, although this isn't really necessary, I would prefer it if it was a jar file, so that it could download it via the application and the end user wouldn't have to install anything manually.
Thanks!
You can use vlcj - Java Framework for the vlc Media Player
Taken from the site:
The vlcj project provides Java bindings to allow an instance of a native vlc media player to be embedded in a Java AWT Window or Swing JFrame. You get more than just simple bindings, you also get a higher level API that hides a lot of the complexities of working with libvlc.
You can try using JMF: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html
or FMJ (open source version with some ffmpeg hooks): http://fmj-sf.net/
I'm not sure how well those projects are maintained though.

GWT audio recording

Are there any options for recording audio in a GWT application ?
Options seem to include flex, perhaps a java applet or some other form of flash ?
Unfortunately it doesn't appear that there is any way to record audio using just JavaScript currently, so it won't be possible using GWT alone (since the GWT compiler only produces JavaScript).
However, Mozilla's Jetpack project includes a proposed Audio API that may make it possible. Keep in mind that this is a cutting-edge feature and will probably not be widely supported for a very long time.
This answer might be helpful, since it's asking a similar question: How does one record audio from a Javascript based webapp?
For our GWT web application we use a Java applet made by Javasonics. They have a free (with limitations) version that you can use. It works very well and supports several audio formats. The applet worked without problems on Windows, Linux and Mac.
You can control the applet using JavaScript. In your GWT client code, you will have to use JSNI to interface between the real JavaScript code and your GWT code.
However, it seems that there is a bug in GWT that makes the applet display on top of dialogs and it is quite annoying. We dealt with this issue by setting the applet's visibility to false when displaying dialog boxes.

Java Media Framework on client side?

If I’m writing an applet that shows a video sequence (eg. streaming from a camera, or the applet itself is running the on the camera), do my clients need to download the Java Media Framework libraries inorder to see the sequence?
They need to install Java Media Framework on their computers, or you'll need to bundle the JMF together with your applet somehow.
If the applet makes use of the JMF libraries they need to be downloaded to the client machine (where the applet executes). However, JMF gets very little development from Sun (read none) and is pretty much legacy now (subjective).
Depending on how modern the camera is and what codecs it can output it may also be worth considering the video support in either javafx of flash.
Distributing the JMF.jar with your applet is sufficient.
Create a JAR ( Java DLL ) and put all the jar files from the install directory, JMF is 32-bit only, so the x86\java\JMF2.1.1e\lib is where it's usually located.
If you customized the customizer.jar you want that one too.
You can download it from a server like an applet and embed the applet inside and then run it. It's worked for me for 14+ years in Adult Pay sites.
Did you consider to use Java FX? This technology is dealing with this problem of downloading media libraries and so no. Of course. It is still in development. If to be first-adopter is option, it will be worth of considering this.

Categories