MPlayer Alternative online playback audio and video files tips (original)

Source: Internet
Author: User
Tags curl stdin
Guide:
   title: MPlayer Alternative online playback audio and video files tips (original)
This article describes the MPlayer online playback method, not refers to the installation of MPlayer Plug-ins in the browser this method, but in the command line, the use of MPlayer can be played from stdin in the principle of implementation. The principle is to download files to stdout using downloadable software that supports stdout (such as wget and curl), and then to read and play the data from stdin using MPlayer. Because all data is only temporary in the stdin/out, so you can do not save on the local hard drive, online playback of audio and video files. This method can be used in a variety of distributions. For more information on stdin/out, please check online, I am not very clear.
Here are some examples of more common online playback, using wget and mplayer as examples.
1. Play rmvb files online
This is the simplest because the RMVB file does not involve a subtitle problem. Please make sure you have installed the Realcodecs first. Suppose I want to see some rmvb movie in a movie FTP, then the command line format is:
Wget-ftp://username:password@ftpserver/directory/movie.rmvb-o-| Mplayer-cache 8192-
To explain, the wget parameter "-o" means Save As, followed by "-" means output to stdout; is the pipe character,-cache 8192 sets the mplayer buffer size to 8192K, and the last "-" tells MPlayer to read the data from stdin. Generally speaking, the bandwidth required for fluent playback is about 60kb/s. If the speed is fast, MPlayer will automatically control wget spin down to keep the buffer at around 49%.
2. Play AVI file online
This kind of document usually has a separate subtitle file. Subtitle files need to be downloaded to the local hard drive, and it is not possible to put the subtitle files in stdin. Subtitles generally have two formats, SRT and sub. For SRT captions, assuming the location is TMP/MOVIE.SRT, the total command line format is
wget Ftp://username:password@ftpserver/directory/movie.avi-o-| Mplayer-cache 8192-sub tmp/movie.srt-font/usr/share/fonts/simsun.ttf-subcp cp936-
To explain, MPlayer's "-sub" specifies the subtitle file, "-font" specifies the font of the subtitle file, where the Simsun.ttf corresponds to the simplified, traditional subtitles for traditional Chinese text. "-SUBCP" designated subtitle file encoding, simplified is cp936, traditional is big5.
For sub format captions, you need to download the movie.sub and Movie.idx files, and the total command line format is
wget Ftp://username:password@ftpserver/directory/movie.avi-o-| Mplayer-cache 8192-vobsub Movie-
Note that here "-vobsub" specifies a subtitle in sub format, followed by only the prefix name of the caption file, and not the suffix name. "-font" and "-subcp" parameters are not needed because sub captions are special bitmap formats that have nothing to do with fonts and encodings.
Generally speaking, the bandwidth required for fluent playback is about 130kb/s. For questions about loading captions, you can see my other article
http://www.linuxsir.org/bbs/showthread.php?t=249835
3, online listening to songs
There are several ways to listen to songs online, such as listening to all the songs in a directory on an FTP server:
wget Ftp://username:password@ftpserver/directory/*.mp3-o-| Mplayer-cache 1000-
If the name of a song has Chinese in it, then the song will not be able to broadcast. This has to do with how wget gets the list.
There are many music sites, also provide online listening to songs (such as Music.trueice.net), click Play, will generate a list file (assuming the existence of tmp/playlist.m3u), so that wget can read the list file and download, in the form of:
Wget-i Tmp/playlist.m3u-o-| Mplayer-cache 1000-
If such a site needs to be logged in to play, that is, the need for cookies (such as music.xjtust.com), that does not matter, the command format is as follows:
Wget-i tmp/playlist.m3u--load-cookies Mozilla/firefox/default/cookies.txt-o | Mplayer-cache 1000-
Here, "--load-cookies" is followed by the Firefox store cookies file.
Also some websites, must use the Winamp to play, xmms all not good, that also has no problem, the command format is as follows:
Wget-i tmp/playlist.m3u--load-cookies mozilla/firefox/default/cookies.txt--user-agent= "WinampMPEG/5.0"-O | Mplayer-cache 1000-
This sends the Winamp player identity to the server.
Generally speaking, the bandwidth of fluent playback is 20kb/s or so.
***********************************************
April 27, 2006 new content:
Wget also has a parameter in connection with the FTP server is also useful, is "--no-passive-ftp." As the name suggests, without this parameter is passive mode, plus is the port mode. If the wget speed changes to 0 during playback, try adding or removing this parameter.
When you play the MP3 file list, there is a possibility that wget is downloading one of the files, but MPlayer does not play it. This is because MPlayer defaults to the file's extension to determine its audio decoding type, and may not be able to find relevant information in stdin because of a file name encoding problem. This way mplayer may not know how to decode and refuse to play. You can add such a parameter "-demuxer 17" after mplayer to force it to be processed in audio format.
The basic commands for playing with Curl are:
Curl Url-o-| Mplayer-cache-
Note that the curl save parameter is lowercase o, but curl whether it supports cookies and whether it can be set user-agent has not been tried.
This post is edited by MWMB2 in 06-04-27 21:40.

This article turns from
http://www.linuxsir.org/bbs/showthread.php?t=254467

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.