Is there a simple way to play a rtmp stream in java? - java

I want to play an MP4 videon streamed over rtmp protocol in java.
I found a few rtmp libraries (yuv, red5), but nothing on mp4 display.
Is there a (possibly simple and maybe platform-indenpendent) solution to do it in java?

Most rtmp streams in my experience tend not to be MP4. There's nothing particularly clever about rtmp streaming though, and if you really can't find anything to fit your needs the way to go is to get hold of a copy of rtmpdump, rip the stream to file and play it.
BTW I'm playing with the IBM MP4 sdk toolkit at the moment, downloadable from http://www.alphaworks.ibm.com/tech/tk4mpeg4 . Seems straightforward enough, dled, unzipped and had the Swing demo app playing MP4s in NetBeans in under 5 minutes. If the stream you're talking to is genuinely MP4 you could probably figure out how to hotwire it to the stream fairly quickly from what I'm seeing of the IBM MP4 API.

Related

Real-time video render

We're staring a new project where we should be able to modify on the fly video - add text, insert image.
Project is planing to be written in Java.
I'm a newbie in video processing so I want to understand.
What is the best and fast solution to modify video and return to client (web browser).
I can easy do it using ffmpeg but mp4 is not streamable. And I should write it to file first and then return to client - it's not fast.
Maybe my question is very abstract but I should to start from somewhere :)
Thanks
I'm not sure why you mention java, because it sounds to me as if you need to mix a stream of live video (from a camera) with alpha channel graphics etc. and then distribute it in realtime (like a TV station does?). Correct me if I misunderstand.
I suppose it all depends on the quality of the video you need to distribute, using a digital source like a webcam is not very exiting - although most modern products can do that too. It would be better to use a more professional camera with a decent optic that can send a quality stream to a software controlled video mixer & encoder (input card). Blackmagic do cheap mixers for this kind of thing (ATEM is cheap compared to other products in its class). Wirecast from Telestream is a very cheap alternative solution for doing the whole thing without having to buy additional encoders.
You need to send a stream to a distribution server. Depending on what you choose to buy (eg. you can use rather expensive H.264 or even JPEG2000 encoders and decoders with ATEM) If you do a cheaper rtmp stream with wirecast or such, you can handle the distribution with ffmpeg server - and there are other services and CDNs you can hook into if you use rtmp and want somebody to help you.

Streaming video files users have uploaded

We have a java web application where users can upload all kinds of files including any kind of video files. Now we want to allow them to stream these video files they own. So I need to make sure that they are the owner and then stream video. Also possibly stream a preview.
Do I need to convert these video files before streaming and where should I look to get started?
The best video playback/encoding library I have ever seen is ffmpeg. It plays everything you throw at it. (It is used by MPlayer.) It is written in C but I found some Java wrappers.
FFMPEG-Java: A Java wrapper around ffmpeg using JNA.
jffmpeg: This one integrates to JMF.

HTTP-live steaming on Linux server

I find it hard to find some conclusive information on this. I have a dedicated server in a datacenter with Debian 5.0. I have an iPhone/iPad app which uses a JAVA EE (Glassfish 2.1) backend, and I am in the process of implementing video into the App. This includes live streaming and video's are longer than 10 minutes I need HTTP Live Streaming.
What is the best open-source/free solution to implement? This is only a pilot project, so I don't want to subscribe to any paid service. I have currently nothing in place yet for the live streaming, so am flexible to adapt any system (server or client side).
I came across:
Darwin (but am not sure that project is alive, as there is not a lot of info)
Red5 (but cannot find conclusive if this would allow an easy implementation of HTTP live streaming)
FFMPEG
Regarding the video's, I would ideally like to upload a 720p version to the server (for iPad) and then convert automatic (either on the fly when requested or prepared when the file is uploaded) to the required formats for iPhone/iTouch and low bandwidth. For live streaming I would like to be able to provide the content in about 30 seconds from it streaming into the server.
I am not envisaging high demands (e.g. a lot of simultaneous requests, and if so (e.g. live event) on one stream which should be able to be dealt with using HTTP-live streaming, it only needs encoding and segmenting once).
In the )not so near) future android will probably be made part of the App as well.
Any hints/tutorial/suggestions/advice would be really appreciated.
Wowza is pretty good for live streaming to iOS (as well as flash)
It isn't free though.
Latest development version of VLC supports HTTP live streaming.
You'll have to build from source as this has been added to the git repository not so long ago.
http://wiki.videolan.org/Documentation:Streaming_HowTo/Streaming_for_the_iPhone
I am now using the Xuggler framework, which is Java based. Seems to do exactly the job I am looking for, although no build in segmented etc. is available. Instead I try now to write one myself which at the same time integrates exactly with my system
Refer to Apple's http live streaming document and best practices.
https://developer.apple.com/streaming/
This should be a good point to get started.
What is the source of the live video? The iPhone only supports playback of H.264 baseline profile level 3 or mpeg-4 video with aac audio. The iPhone itself encodes video to these specs, but most other encoders don't (including many Android phones). If your video is not encoded to this spec, you'll first have to transcode. FFMpeg (with libx264) will do this nicely. Then you'll need to generate the dynamic .m3u8 playlist file. Wowza will do this for you out of the box, and will accept an rtmp stream from FFmpeg (but is not free). I don't believe that red5 supports Apple http streaming. There are free servers that claim to, but I've never used them. Take a look at http://erlyvideo.org/. Otherwise, you can do it yourself fairly simply. FFmpeg will output an mpeg-ts stream. All that the playlist generator needs to do, then, is cut this into 188-byte-aligned chunks, and return a playlist containing the last n. You can even use an http byte offset module to make the playlist reference a single file. Read Apple's http streaming docs at https://developer.apple.com/streaming/

Use Xuggle in Java to trancode and streaming video/audio

I create an HTTP streaming server, but the clients can not play all video formats, so my question is, if there is a way, using xuggle in the server to transcode the video in a specific format and streaming it directly, on the fly.
I mean, not have to wait to finish the transcoding and then start the http streaming. I mean that I have a loop for example and get everytime a number of transcoded bytes and writes them to the socket.
Yes, but...
I'd not recommend taking this approach. Encoding videos is generally very CPU intensive. The generally accepted aproach to solving this problem is to transcode the video file off-line and store on the streaming server. Yes, that means a couple of different media files with the same video, but it scales muuuuuuuuch better. Most (all?) successful streaming servers do it this way.

100% Java encoder for AVI animation

I am looking for a 100% Java solution for encoding software generated images into an AVI stream together with an uncompressed audio track.
At the moment I am using JMF, but its size and installation problems make it a bad solution for my purpose.
While it does not support audio, I created an MJPEG AVI Java class some years ago. You basically just tell it the resolution of your output video, along with the frame rate, then you just keep adding images to it. When you are done, you tell it to finish and it'll close out the AVI. It is based off of the Microsoft documentation on AVI, RIFF, and BITMAP file formats.
Other than not supporting audio, the only real problem is it implements the version of the AVI format limited to 2GB per file. While the class will write out a much larger file, I am uncertain that any players or video editors would be able to read it.
The way I've used this code in the past, is to generate an MJPEG AVI for processing in a video editor (adding audio, etc. in the editor). It helped me with automating some tedious slide show generation. Not sure if this code will help you, as is, but it might help if you are trying to roll your own solution. MJPEGGenerator.java is available if you are interested!
You can use JMF, see this nice example.
There is a nice blog entry here:
http://www.randelshofer.ch/blog/2008/08/writing-avi-videos-in-pure-java/
By Werner Randelshofer

Categories