Quicktime/Linux
From iA wiki
Contents |
Howto: Watch online Quicktime / Real streams using Linux
MPlayer
MPlayer was mainly developed to run on Linux. But there are also ports for MacOSX, *BSD, Windows, IRIX, and most likely more OSes.
- Supporting: Quicktime
There are basically 2 formats for Quicktime. One is the "AVI" format, which is included in MPlayer in the form of libavcodec library. This library supports many of the most common audio and video formats. Because it is included in MPlayer by default, this isn't much of a problem. This will work on all platforms MPlayer is able to compile on.
The second format is the "MOV" format. This is a proprietary codec used in Quicktime 6 which isn't available native, although HeroineWarrior's Quicktime4Linux, LibQuickTime or OpenQuickTime, might work with this as well albeit not fully. Fortunately, there are, "hacked" DLLs which work together with at least MPLayer. These "hacked" DLL's are binary libraries used on Windows. They have been "hacked" to work with MPlayer on Linux/x86. With additional hacking you might get it working on other platforms, but be aware that requires work and knowledge (*).
(*) This method could be illegal because of the license of DLL/SO's and/or laws in your country.
- Supporting: Real
Also, please take note MPlayer works too with Real's codecs so you can watch RealVideo 2-4 (RealPlayer 7-9) and RealAudio with MPlayer without using the official RealPlayer. In order to do so, MPlayer uses a "hacked" DLLs or native SO's to play the video. The "hacked" DLL's officially only work on Linux/x86 but with additional hacking you might get it working on other OSes too. The native SO's work on any platform to which Real ported them too, most notably Linux/x86 and Linux/alpha (*).
(*) This method could be illegal because of the license of DLL/SO's and/or laws in your country.
- Supporting: Streaming
When using MPlayer to play a streamed video for ie. Quicktime, Real you'll need LIVE.COM RTSP/RTP support for MPLayer. You recognize such stream because the URL ends with .sdp, .qt, .rm or .ram and starts with rtsp://, rtp://, pnm:// or sdp://. RTSP and RTP are protocols commonly used to stream Quicktime and Real video.
- General: Using binaries
What is a binaries? The advantage is the user only has to install the software packet. The MPlayer team doesn't support unofficial binaries which are not listed on the site. Almost all binaries have libavcodec support, but not all have support for the proprietary, non-native Quicktime or Real codec neither do all have RTSP/RTP support. Be sure that the binary you wish to use has proper support for what you want! If you aren't able to find one, you have the ability to compile from source.
- General: Compiling from source
Compiling from source is a cleaner way to get MPlayer working which is also recommended by the MPlayer team. This is cleaner because no computer or GNU/Linux distribution is exactly the same. In contrast to installing a binary, it also a bit harder to achieve. If you can't get binaries working you can always chose to use this method.
If you aren't satisfied with these binaries you can compile MPlayer yourself. Be assured the liblive headers are installed. You can download these from the LIVE.COM RTSP/RTP for MPLayer homepage as TAR.GZ. After this has been installed, download the newest TAR.BZ2 from the MPlayer homepage. Unpack this file using tar -xjf <file.tar.bz2>. After this compile, go to the unpacked directory. MPlayer has a lot more compile options: type ./configure --help for all available options. I won't explain them all, it is however explained on the MPlayer homepage. Now, compile the beast ./configure --enable-live. Eventually, you have to add in which directory your liblive cruft is intalled because sometimes these aren't found automatically by the configure script. If not found automatically, use: ./configure --enable-live --with-livelibdir=DIR. After this is finished do make install as root and you're all set.
- OS specific: Debian GNU/Linux
Due to licensing issues Debian does not provide Debian-official MPlayer binaries. There are 3rd party packages for Stable/Testing/Unstable at Marillat.free.fr. If this page is down try searching at Apt-get.org for mplayer to find a different webpage with 3rd party packages. Note that these are unofficial binaries; they are not supported by the MPlayer team! You'll need to edit /etc/apt/sources.list. Explanation for this is available at the Marillat.free.fr homepage. After that, runapt-get update to update APT's repositories. Then run apt-get install mplayer-386 and MPlayer, optimized for i386, is installed.
If you aren't satisfied with these binaries you can compile MPlayer the "Debian way". Be assured the liblive headers are installed. You can download these from Marillat.free.fr in the form of a DEB file or from the LIVE.COM RTSP/RTP for MPLayer homepage as TAR.GZ. After this has been installed, download the newest TAR.BZ2 from the MPlayer homepage. Unpack this file using tar -xjf <file.tar.bz2>. After this compile, go to the unpacked directory. MPlayer has a lot more compile options: type DEB_BUILD_OPTIONS="--help" fakeroot debian/rules binary for all available options. I won't explain them all, it is however explained on the MPlayer homepage. Now, compile the beast the "Debian way":DEB_BUILD_OPTIONS="--enable-live" fakeroot debian/rules binary. Eventually, you have to add in which directory your liblive cruft is intalled because sometimes these aren't found automatically by the configure script. If not found automatically, use: DEB_BUILD_OPTIONS="--enable-live --with-livelibdir=DIR" fakeroot debian/rules binary. After this is finished, there's a new file in the parent directory named mplayer_<version>.deb. Become root and install it: dpkg -i mplayer_<version>.deb.
- OS specific: Gentoo Linux
For Gentoo you use emerge: emerge live realvideo-codecs openquicktime mplayer.
- Using MPlayer to play an online stream
If you have MPlayer succesfully installed try using one of the following online streams: Quicktime/MPEG4: mplayer rtsp://mediaserver.debalie.nl/debalie.sdp +FIXME: Add link for Quicktime/Sorenson +FIXME: Add link for Real stream
If you want to use RTSP over TCP instead of UDP please add the -rtsp-stream-over-tcp argument after the mplayer command.
As said earlier MPlayer has a number of options. A few of these options have a positive effect on the quality and performance of MPlayer. That's why it is important that you read this documentation thoroughly. See the MPlayer site, man mplayer or mplayer --help.
- Using MPlayer to reencode an online stream
First of all: why reencode?
Reasons differ per situation and person. The most common reason is either to get rid of a proprietary video which uses a proprietary/non-Free codec. Another common reason which sometimes coherent to the first reason stated is to allow one or another to view the video on a wider number of computers or on a specific computer; make the video more cross-platform. Not all computers have support for every specific proprietary video codec.
We'll use the following video from VPRO.nl as an example: http://www.cinema.nl/cinema/events/binders/index.jsp?portals=3142294&events=16055393&binders=16160336
The documentary is about the US investment company Carlyle. It is almost completely in English, subtitles and some speech by the reporter is in Dutch.
Next you see 2 stream URLs over there. They are both in Real format so you better have the proprietary Real codecs installed with supports from MPlayer. You'll also need RTSP support in MPlayer when you'd like to view or dump the stream.
- Smallband (till 100 kbs): http://cgi.omroep.nl/cgi-bin/streams?/tv/vpro/tegenlicht/sb.20040125.rm?title=Bekijk%20hier%20de%20uitzending%20DE%20IJZEREN%20DRIEHOEK%20in%20realvideo%20SMALBAND%20tot%20100%20kbs
- Broadband (till 500 kbs): http://cgi.omroep.nl/cgi-bin/streams?/tv/vpro/tegenlicht/bb.20040125.rm?title=Bekijk%20hier%20de%20uitzending%20DE%20IJZEREN%20DRIEHOEK%20in%20realvideo%20BREEDBAND%20tot%20500%20kbs
Take the one which best suits your connection speed. Everything after the .rm file has to be removed. This leads to the following URL's. Note the difference between smallband (s) and broadband (b); the smallband URLs' filename starts with a s, the broadband URLs' filename starts with a b.
- Smallband (till 100 kbs): http://cgi.omroep.nl/cgi-bin/streams?/tv/vpro/tegenlicht/sb.20040125.rm
- Broadband (till 500 kbs): http://cgi.omroep.nl/cgi-bin/streams?/tv/vpro/tegenlicht/bb.20040125.rm
Download this and chose save as or use a downloading utility like wget. Open up the file with a text editor or text viewer, for example less. It is a simple txt without any macro cruft.
- Smallband (till 100 kbs): rtsp://streams3.omroep.nl/tv/vpro/tegenlicht/sb.20040125.rm
- Broadband (till 500 kbs): rtsp://streams8.omroep.nl/tv/vpro/tegenlicht/bb.20040125.rm
Note that the number behind streams could differ from time to time. Now that you have the exact location of the streaming server you can easily rip it using MPlayer. It is by now obvious you need a program which has RTSP support, given that the URL starts with rtsp://.
- RTSP over UDP
- Smallband (till 100 kbs): mplayer -dumpstream -dumpfile sb.20040125.rm rtsp://streams3.omroep.nl/tv/vpro/tegenlicht/sb.20040125.rm
- Broadband (till 500 kbs):mplayer -dumpstream -dumpfile bb.20040125.rm rtsp://streams3.omroep.nl/tv/vpro/tegenlicht/bb.20040125.rm
- RTSP over TCP (if you are behind a broken connection like a firewall or NAT)
- Smallband (till 100 kbs): mplayer -dumpstream -dumpfile sb.20040125.rm -rtsp-stream-over-tcp rtsp://streams3.omroep.nl/tv/vpro/tegenlicht/sb.20040125.rm
- Broadband (till 500 kbs): mplayer -dumpstream -dumpfile sb.20040125.rm -rtsp-stream-over-tcp rtsp://streams8.omroep.nl/tv/vpro/tegenlicht/bb.20040125.rm
The argument after -dumpfile is the file to which the stream is written. You can ofcourse chose any filename you prefer. In this course i take the filename used in the HTTP/RTSP URL as example.
This streamdumping takes some time, depending on the size of the filename and your connection speed. After MPlayer is done you have the video on your local harddisk. You can view it anytime you want using the official RealPlayer but also with a program which uses its' codecs, like MPlayer. To play it with MPlayer use: mplayer <filename>
By now you can also chose to reencode it to a different audio and/or video codec. If you'd like to be aware that MPlayer needs to have support for this codec. We'll use XviD as an example.
- Smallband (till 100 kbs): mencoder sb.20040125.rm -o sb.20040125.avi -ovc xvid -oac mp3lame
- Broadband (till 500 kbs): mencoder bb.20040125.rm -o bb.20040125.avi -ovc xvid -oac mp3lame
Again you need to chose the correct input filename which is the argument right after mencoder and you can chose any filename you wish after the -o argument.
MEncoder is a part of MPlayer. It has to be enabled when compiling MPlayer or the binary has to be installed. To see which output video codecs mencoder supports type: mencoder -ovc xvid and to see which output audio codecs mencoder supports type: mencoder -oac xvid. Any more codecs need to be compiled in MPlayer during compilation or by getting the library which is needed plus a MPlayer binary package which has support for this library (and it has to be properly linked to the library's location!).
In short, the trick is to become aware of what the RTSP URL is. This is exactly what RealPlayer does if you point it to a URL which contains a .RM/.RAM file. If you have it, you also have access the video it hosts.. for the time being, until stuff like DRM pops up.
Alternatives for MPlayer
- Xine
Xine is a yet another media player for GNU/Linux. On the moment of writing, it doesn't have RTSP/RTP support yet.
- VideoLAN Client
VideoLan Client (aka VLC) is a portable, media player which runs on various platforms and architectures including GNU/Linux. It is included in Debian GNU/Linux: apt-cache search vlc. Other GNU/Linux distributions most likely too have a package. Since it is open-source, you can also chose to compile it yourself. VideoLAN Client has a relatively easy GUI interface. The CVS version has RTSP/RTP support. Eventually this CVS version becomes stable, and you can use it without compiling from source.
- WINE
WINE's implementation of the Windows API's can be used to play Quicktime streams too. After you've install this you install Quicktime for Windows video player which is available at Apple's Quicktime homepage. A user-friendly configuration program for WINE is WineTools. If you find this all too hard you can try out the proprietary frontend for WINE, CrossOver Plugin. This costs money, but there is also a demo. CrossOver Plugin has straightforward Quicktime for Windows video player installation support and the program itself is easy to install as well. In both situations, running Quicktime is not as fast as running it native under Windows; a native video player compiled for your OS gives a much better result.
Common problems
- Problem: Compiling.
Q: MPLayer doesn't compile, or MPlayer doesn't work, MPlayer hasn't got LIVE.COM RTSP/RTP support.
A1: One of the most common problems during or after compiling MPlayer is that the LIVE.COM RTSP/RTP headers aren't installed. These have to be installed, and found by the configure script. These have to be installed when you'd like to use MPlayer to stream a video. If they are installed, they're either found automatically or you have to add --with-live after ./configure, as been explained earlier.
A2 Another common problem is that proprietary Quicktime or Real codec isn't properly installed, or can't be found by the configure script. They have to be installed and in a path the configure scripts finds. You can download them from the MPlayer homepage. The script should detect them automatically, and they should be listed in the list of codecs which are to be compiled.
- Problem: Firewalls.
Q: When using a firewall or broken connection it can occur it blocks or doesn't forward UDP packets. There are 2 solutions.
A1: The first solution is to use RTSP over TCP. For MPlayer you'll have to add --rtsp-stream-over-tcp to ./configure. This results in: mplayer --rtsp-stream-over-tcp rtsp://mediaserver.debalie.nl/debalie.sdp. Xine doesn't support RTSP at the moment and therefore this solution won't work, sorry. VideoLAN Client has only RTSP over TCP support in the CVS version. In newer versions it'll most likely be included by default, but at the moment of writing, unfortunately it isn't.
A2: A second solution is forwarding UDP packets to the computer which asks for them. This is less elegant and will only work on 1 client. The rules i used on a OpenBSD computer with PF firewall are the following:
rdr on $ext_if inet proto udp from any port { 6970, 6971, 6972, 6973 } to $external_ip1 port 40300:40400 -> $internal_ip3 port 40300:*
Explanation: redirect on external interface IPv4 traffic protocol UDP from every IPv4 port 6970, 6971, 6972 and 6973 which goes to external_ipv4_1 port 40300 till and including 40400 to internal_ipv4_3 port 40300 t/m 40400.
pass in quick on $ext_if inet proto udp from any to $internal_ip3 port 40300 >< 40400 keep state
Explanation: let pass everything to external interface protocol UDP from every IPv4 which goes to intern_ipv4_3 port 40300 till and including 40400.
Simply said, all the UDP traffic which arrives at the firewall from port 6970, 6971, 6972 and 6973 which goes to port 40300 till and including 40400 will be forwarded to the computer you specify which you want to be able to view online streaming video. This works, but only with one computer at the time. How you configure this on a firewall differs, but what you have to forward and let pass is the same; the principle is the same.

