How to transmit video over the network using JMF and JMF-RTP. You may want to transmit video from one computer to another. Or you may want to broadcast a live video feed to your company's intranet. The source of the video can be a file, live video using a video capture device or any other source supported by JMF.
The VideoTransmit class is a simple wrapper that can be programmed to take video input from a source of your choice and transmit the video to a destination computer or network in JPEG format.
The JMF API is used to read the source and convert it to packetized JPEG data. The RTP API implementation included in JMF will then transmit the video using the RTP protocol.
The VideoTransmit class takes three parameters in the constructor - the source locator, the destination IP address and the destination port number.
The source locator can be -
a file name such as "file:/C:/media/speech.mov",
an http locator such as "http://mediacentral.com/speech.avi",
or a capture datasource such as "vfw://0" or "sunvideo://0/1/JPEG"
vfw: is used on Windows and sunvideo: is used on Solaris. If you have a more recent PCI based Sun Workstation, then use sunvideoplus:. When using vfw, it will pop-up a format dialog when creating the processor. You should select the size of the video that you would like to transmit at.
The IP address should be the IP address of the computer that should receive your transmission. If you want all the computers on your subnet to receive the transmission, then use 255 as the last number in your IP address. For example, "188.8.131.52" can be used for a point to point transmission and "184.108.40.206" can be used for all computers that are on your subnet. Consult your system administrator if you're not sure what these IP addresses mean. You can also refer to the JMF RTP documentation in the JMF Programmer's Guide for more information on RTP transmission and reception.
The Port number can be any port number that is not in use by any other service on your computer. For example, you can use "22222". Make sure that it is an even number. Once again, refer to the Programmer's Guide.
The sample program can be used as a utility class as well as standalone. There is a main method that takes three command line parameters. If all goes well, the video will be sent out for 30 seconds and then the application will exit. This 30 second limit is because there is no GUI that allows you to specify when to stop the transmission. When doing live video capture it is very important to properly terminate the capture and release the device by calling stop and close on the capturing processor.
Note: The source video, whether its a file or live video, needs to be in a format that can be converted to JPEG/RTP. Cinepak, RGB, YUV and JPEG are good formats. Other formats may not work due to restrictions inside the processor. Also the dimensions of the video should be a multiple of 8x8. For example, 320x240, 176x144 are good sizes and 240x180, 90x60 are not. Experiment with different formats to see what works best for you.