Process video streams with Xuggler API - java

I'm trying to build showcase video streaming from a server to a client, but I need to process the stream before sending. I like to do all in java, and client be an Android device.
I just heard about a library called Xuggler which is Java-based and looks promising. Does it provide any functionalities to access the video streams and do some image processing on them before transmission?
Please introduce any other Java-based media streaming / processing libraries if you know of.

For Java video processing, despite being long deprecated, Xuggler has been the best solution that I've found, someone else might know of an alternative.
Since it's not supported anymore you have to do a few things to get started. First find a Xuggler-5.4.jar, Also you need the Java 7 Jdk to run it, it will not work with Java 8, then you need the sl4j-api and sl4j-simple Jars.
It has a complicated but well documented api, but the main gist is you use the MediaToolAdapter interface, create an IMedia Reader and Writer, add something implementing the interface to the reader as a listener, and in the implemented methods for audio and video you can process the data in each frame and pass it to the writer.
This example is a good place to start:
https://github.com/artclarke/xuggle-xuggler/blob/master/src/com/xuggle/mediatool/demos/ModifyAudioAndVideo.java

Related

Java starting and seeking a video using a custom java File System abstraction

I have a custom Java NIO FileSystem. I have to validate it's usability for video playing, seeking, etc. in a demo.
My problem is that I cannot find any library which allows me to play a video from anything other
than a regular File or URL. I tried with vlcj, javafx with no luck.
My question is what library should I use for starting a video from a custom FileSystem abstraction?
LibVLC has support for in-memory stream playback.
This should get you started for Java (credit to caprica)
https://gist.github.com/caprica/52b1793500626cdc88d756175cf9aa4c

Get frame from video in Java

I need to extract a single frame from a video file to use as a thumbnail. I would like to be able to generate thumbnails from most common video formats and would also like to be cross platform, so a pure Java solution is preferential.
It would be also useful to be able to get additional information about the video such as frame rate and total length so I can get a frame from a specific place in the file.
I have looked at Xuggler but it appears to be depreciated.
Assuming you want to do this server side, then it may be easiest to leverage ffmpeg as it is commonly used for this type of video manipulation and it also has a large user community.
As ffmpeg is C based, using it with Java requires some sort of wrapper or JNI approach so it is not strictly speaking pure Java, but it is common to use it this way in Java programs. An example wrapper library, which seems to be regularly maintained, is:
https://github.com/bramp/ffmpeg-cli-wrapper

using FFmpeg for android without any C/C++ or make knowledge

I would like to use FFmpeg library on my android app.
I have no C/C++/Make knowledge and all the threads I've been reading about it talk about stuff I completely don't understand.
Is there any pre-compiled library which I can add to my project, then add a simple 'import' statement on my java class and then call it?
Thanks
Is there any particular reason why you need exactly FFmpeg? I guess it could be possible to get prebuilt binaries, but since it is a C library, you would also need a JNI wrapper code - I don't think anyone would generate that for the whole library since it's quite large, so even with a prebuilt library you still need to have some JNI knowledge to wire through the communication between Java and FFmpeg in C. Just for the purpose of demonstration - here is an example.
Apart from that if there is not a special reason to use FFmpeg, why can't you stick with MediaCodec that is a part of the Android API? It wraps the native StageFright library and could provide hardware support on devices where it is available, while FFmpeg would be a CPU only solution. Of course, if some unpopular codecs or muxers that are not available in MediaCodec are needed, then FFmpeg is the way.
You can use Xuggler for encoding and decoding audio and video. Their wesite says "Xuggler extensively uses FFmpeg to compress and uncompress media".
You could use precompiled libs from the JavaCPP Presets along with FFmpegFrameRecorder from JavaCV to compress images as well as audio samples, as shown in the RecordActivity sample, for example.

how to send video stream from java to flex netstream?

does anybody know how to send a video data stream from one side written by java to another side written by flex and then display it? I just know that on flex one method is to use netstream class get the real-time video stream and bind with a videodisplay to display it. But which class I should use to send this video stream in java and which class I need to use in flex to receive this flow and pass it to the NetStream class?
Does anybody have any ideas about that?
Thanks!
Check out Red5 - http://www.red5.org/
It's a free open source platform for streaming media to flash / flex. It's been around for years and quite mature.
Telling you how to implement it for your particular situation is out of scope of a Q&A format, but I can tell you from experience that red5 is an easy to implement solution relative to rolling your own or flash media server (which is pricey!)
More tutorials and examples here:
http://trac.red5.org/wiki/Documentation
If you decide to write your own (why?) - check out Java Media Framework (JMF) - http://www.oracle.com/technetwork/java/javase/specdownload-136569.html
For android - you're going to want to take a look at :
android.hardware.Camera;
android.media.MediaRecorder;
then something along the lines of :
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); // might try MPEG_4_SP as well
recorder.start();
I specified in the above codecs that are in a format that is friendly to flash.

How to make Tomcat stream media?

I am entirely new to streaming implementation. I have developed some RESTful web services using Jersey/Tomcat. There are few cases where I need to send audio/video files to the clients, which uptil now I have been sending as a file fr download - now I want to stream these files.
Do I need to write some code for this ? Or I need some third party solutions ...I have heard about Wowza / Darwin / Red5...But I dont know if they can be integrated with Tomcat and my existing services. Any third party solutions need to be free / opensource, and they should support both audio and video streaming. In the near future I need to add transcoding support too..for which I am planning to use Xuggler. So it would be good if the server is having such support.
Any pointers would be appreciated. Thanks !!
Red5 is essentially Tomcat with added features. I don't know how far back in time the fork was made but the basic functionality is all there.
Also - Red5 and xuggler play nicely together.
You'd still need to code up the client side of the streaming portion though. Its possible that HTML 5 will give you this for cheap.

Categories

Resources