There was an error in this gadget

+1

Sunday, January 14, 2007

Downloading and Converting YouTube Videos for Mobile Phones

4 comments

Viewing, Downloading, Converting YouTube Video Files


Youtube is one the popular social networking website , but unlike Google Videos which include link for downloading videos Youtube provides no such link here in this article we try to look at ways of downloading videos on to hard disk , Playing them and converting them to a format suitable for them to be played on Mobile Phones . All these would be done underLinux.

Tools needed : -
For converting video from FLV format to 3GP (To be used to be played on mobile phones) following tools are needed : -
1. MPlayer (with all associated libraries installed)
2. FFmpeg source code
3. Active Internet Connection

Downloading Videos from YouTube

There are number of ways of downloading videos form youtube


1. Youtube-dl script : -
There is a handy python script called youtube-dl that can download videos from the youtube website and works as a Linux console application . The script can be found here : -
http://www.arrakis.es/~rggi3/youtube-dl/youtube-dl

First you need to note/copy the address of the youtube clip you want to save then supply the address to youtube-dl program which downloads the clip.

use : youtube-dl -o filename.flv "Entire path to youtube clip(ex:- http://www.youtube.com/watch?v=foobar ) where foobar would be actual code of the clip"

If the file needs a user-name and password as it is classified under mature section then following command can be used for downloading the video clip.

use : youtube-dl -u username -p password "Entire path to youtube clip(ex:- http://www.youtube.com/watch?v=foobar ) where foobar would be actual code of the clip" -o filename.flv


2. Using FireFox extension : -

First one hast to install GreaseMonkey on FireFox which enables custom java scripts to run under FireFox browser. Greasemonkey can be found here in this location : -
https://addons.mozilla.org/firefox/748/
On clicking the install button the GreaseMonkey install itself on the firefox browser , and the GreaseMonkey can be used after restarting the Mozilla FireFox browser .
A Dialog showing installation of the Script

After restarting the Mozilla FireFox browser type the following address in the address-bar , "http://www.joshkinberg.com/blog/files/youtube_to_me.user.js" , on typing the address the script install automatically. Now whenever anyYouTube video is loaded in the browser a link with red background is provided at top of web browser allowing for downloading of the file . After downloading the file rename the file as filename.flv where filename is name of file that you want to have.

A Windows showing a red bar at top providing link
for downloading of Youtube Videos


3.Use Third Party websites allowing download of youtube videos

There are website which allows saving of youtube videos to computer ,first go to the page of the clip you want to download , copy the address of the clip then go to keepvid.com paste the link , click on the link and download the file. Rename the downloaded file to file's name.flv
Here are some of the Websites : -

http://javimoya.com/blog/youtube_en.php
http://keepvid.com
http://www.youtubex.com/
http://www.viloader.net/


PLAYING FLV FILES

FLV file can be played on the Linux operating system using the MPlayer video player or VLC Video player .
Both can be found here : -

MPlayer : - http://www.mplayerhq.hu/
VLC Player : - http://www.videolan.org/vlc/


use : mplayer filename.flv at the console for playing the flv file .

If you dont know about MPlayer or VLC Player better look at this post : - http://linuxondesktop.blogspot.com/2007/01/playing-audiovideo-files-under-linux.html

ENCODING FLV FILE TO 3GP

3gp is a common media format used on mobile phones allowing playback of video . 3gp video is encoded in H.263 or H.264 and audio is encoded in AMR-NB or AAC format . So FLV file has to be converted to these video encoding

mencoder is a good tool for converting one media file format to another , it can convert any media supported by MPlayer from one format to other . It can be downloaded with MPlayer and can be used for encoding the video and audio encoding from FLV to AVI. So that video could be played on mobile phones.

Here are the steps for converting FLV file to 3gp FILE : -

1. First we will extract video from the FLV file and save it as a AVI file which would be combined with audio stream using FFmpeg program .

mencoder Filename.flv -nosound -ovc lavc -lavcopts vcodec=mpeg4 -vop expand=176:144,scale=176:-2 -o temp.avi -ofps 15


Here in the above command Filename.flv is the name of the video file you want to convert to mobile phone format and temp.avi would be the file in which the converted video would be written. 176:144 Is the size of mobile screen of the phone to which we want to resize the video clip. -ofps 15 specifies the frame rate per second.


Now we extract a audio stream from the FLV movie and store it in a external wav file soundump.wav


mplayer -vo null -ao pcm -af resample=8000,volume=+4db:sc filename.flv


This extracts the audio from the file filename.flv and resamples the sound to 8 kHz It also applies a soft clip filter. The result is a file called audiodump.wav that contains the sound. We need to extract sound as 8Khz since FFmpeg wont encode our file if it is higher.


Now a major problem (maybe some legal issue because of proprietary media format) is that because of some reasons the FFmpeg binary that comes dosent include the files to handle the AMR file that is used by 3gp files for storing audio , hence we need to recompile the FFmpeg library to include support for the AMR file.


So first download FFmpeg source-code from Source Code can be obtained from this website : - http://ffmpeg.mplayerhq.hu/ . Extract the source-code to a suitable directory and go to that directory and chdir to doc here you would find a .texi file FFmpeg-doc open that file in text editor or convert the texi file to dvi using tex program and search for AMR you would find a section like this :-


Section of texi file ffmpeg-doc.texi

@item For AMR WB floating-point download TS26.204 V5.1.0 from
@url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip}
and extract the source to @file{libavcodec/amrwb_float/}.

@item For AMR NB floating-point download TS26.104 REL-5 V5.1.0 from
@url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip}
and extract the source to @file{libavcodec/amr_float/}.
If you try this on Alpha, you may need to change @code{Word32} to
@code{int} in @file{amr/typedef.h}.

@item For AMR NB fixed-point download TS26.073 REL-5 V5.1.0 from
@url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip}
and extract the source to @file{libavcodec/amr}.
You must also add @code{-DMMS_IO} and remove @code{-pedantic-errors}
to/from @code{CFLAGS} in @file{libavcodec/amr/makefile}, i.e.
``@code{CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO}''.



Here copy the address for AMR NB loating point download the file http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip extract it in a temporary directory . Create a directory ffmpegsourcecode-directory/libavcodec/amr_float and extract the zip file contained in it in the newly created directory ffmpegsourcecode-direcotry/libavcodec/amr_float .


Now go to the main directory where the FFmpeg source code is extracted and execute configure script with --enable-amr_nb argument. Example "./configure --enable-amr_nb "

Now make to compile the source code

and make install to install the compiled files.



Now if everything went fine in above steps . FFmpeg should be configured to encode 3gp files properly, now we combine the two pieces to create a one 3gp file using FFmpeg


ffmpeg -i temp.avi -i audiodump.wav -b 48 -ac 1 -ab 12 -map 0.0 -map 1.0 filename.flv


After this command the flv file should be ready to be transferred to a mobile device , and should work fine on any phone capable of playing the 3gp format.


Article Written by Ambuj Varshney <> for Linux On Desktop (http://linuxondesktop.blogspot.com)
(C) 2006 , Ambuj Varshney

Tuesday, January 09, 2007

Playing Audio/Video Files under Linux

0 comments
PLAYING AUDIO/VIDEO FILES ON LINUX

A large number of Linux Distributions these days including Fedora,Ubuntu,Kubuntu etc which have become quiet popular and are increasingly being accepted by the Desktop Users lack proper support for playing the popular Audio/Video Formats right out of the box mainly because of certain patent and royalty issue . The issue of no cross platform file compatibility has been robbing common users of ability to display files and this has been one of the major reason for slow adaption of Linux on the Desktop Front. The case isn't that the Linux dosent support these formats but is not intentionally added to the Linux distribution because of legal reasons. However with a bit of tweaking/installing applications it is possible to run these files in the Linux Operating system . Here in this article we look at playing various Audio/Video format on the Linux Operating System. The system on which these have been tried is a Fedora Core 6 based distribution however all these should be equally applicable to other Linux distributions.



Real Player


Playing Real Media(.rm) Files :-

Real Player has been available on the Unix/Linux platform since a number of years . The Current version of the realplayer available on linux is the RealPlayer 10 though not as feature rich or rich in user interface as one available on the windows platform but still very usable and does the job of playing audio/video files quiet well and can be obtained at the following address . http://www.real.com/linux?pcode=rn&am

Besides having ability to play the RealMedia(Audio and Video) (.rm,.ra,.rv,.rmvb) File , it can be used for playing mp3 files , (.3gpp) files popularly used in cellphone cameras , and the open source Audio format Ogg Vorbis(.ogg).

The Linux Version of Popular Real Player



Playing mp3 files : -

Mp3 is one of the most widely used audio format around the world right now so it would be silly if Linux could not play mp3 .

A number of players exist for playing mp3 files :-


mpg123

This is command line based audio player that forms the backbone of number of graphically available Audio players , it is one of the most efficient player on the Linux platform and can play mp3 files on as low hardware specs as a 120Mhz Pentium Processor based computer . A similar command line application is mpg321 that can be used for playing mp3 files.


mpg123 or mpg321 file name - To play mp3 file

Ctrl + C - This skips to next track

Typing Ctrl + C Twice - quits the application

mpg123 -z *.mp3 : - Command would play all the mp3 files in the directory with a shuffled play-list.


mpg123 -w filename.wav filename.mp3 :- This command would convert the mp3 file to wav file , whic can then be used for burning on to cd to make audio cd.

However if your audio files/file is located in some location in sub-folders and u don't know exact location then following command can be used

mpg123 $ (find -name "Filename")


Website : - http://www.mpg123.de/
Website : - http://mpg321.sourceforge.net/
XMMS

This is the WinAmp alternative for the Linux platform and has been in existence for quiet some time now , it is based on mpg123 library for playing mp3 files . The application has look similar to winamp application and can be beautified with a number of skins , also XMMS supports a large number of plugins that add extra functionality to the player. Besides having ability to play mp3 files it can be used for plying WMA files also by installing external plugin.(http://mcmcc.bat.ru/xmms-wma/)
Website : - http://www.xmms.org/


XINE

Xine is also one of the popular video playback engine , Xine is based upon xine-lib and uses external libraries to play popular audio/video files. Xine with external plugin can play popular Windows Media files, AVI,MPG,etc and can be used for playing VideoCD/DVD .It can be used for playing DVD movies with the use of external library livdvdcss ,though because of legal issues its use may be illegal in some places . Xine provides powerful API that can be used by other external application for playing Video files and Video processing . A Number of frontends exist for Xine including totem(Gnome) , Kaffeine (KDE) , xine-ui etc. Xine can play almost all popular file-formats by install extra w32codecs which are dll files used by xine for decoding popular media formats .
Here is the list of supported video codecs from the Xine website

Kaffeine a popular video frontend to Xine on KDE

Video codecs supported
supported:
o mpeg 1/2
o mpeg 4 (aka OpenDivX)
o ms mpeg 4
o divx 3/4/5
o windows media video 7 & 8
o motion jpeg
o Cinepak
o DV
o ms video 1 (msvc)
o ms rle
o Sorenson SVQ1/SVQ3 (often used in Quicktime trailers)
o creative yuv (cyuv)
o roq video
o QT RLE, SMC, RPZA
o theora
via external binary/win32 codecs (not included in xine):
o Indeo 3.1-5.0
o Window Media Video 8,9
o On2 VP3.1
o I263
o Real Media 2.0, 3.0, 4.0
currently unsupported/untested Formats:
o 3ivx
o h263 (aka Real Video 1.0)

File formats (System layer / media types)
supported:

* direct DVD playback (of unlocked/unencrypted DVDs, see below)
* Video CD
* Audio CD
* mpeg program streams (.mpg, .mpeg)
* mpeg transport streams (.ts)
* ogg (.ogg, .ogm)
* avi (.avi)
* asf (.asf, .wmv, .wma)
* quicktime (.mov, .mp4)
* mpeg-video (.mpv, .m2v)
* mpeg-audio (.mp2, .mp3)
* Sega Saturn FILM (.cpk)
* Id Software RoQ (.roq)
* wav (.wav)
* Autodesk FLIC (.fli)
* real (.rm, .ra, .ram)
* raw dv (.dv)
* network graphics format (.png, .mng)
* Creative Voice (.voc)
* Sun/NeXT SND/AU (.snd, .au)
* Wing Commander III (.mve)
* Westwood Studios files (.vqa, .aud)
* Electronic Arts WVE (.wve)
* AIFF (.aif, .aiff)
* YUV4MPEG2 (.y4m)
* SMJPEG (.mjpg)
* raw AC3 (.ac3)
* Dialogic VOX (.vox)
* TechnoTrend PVA (.pva)
* Playstation STR (.str)
* Nullsoft Video (.nsv)
* 4X Technologies (.4xm)
Audio codecs supported:
o mpeg audio (layer 1,2,3)
o a/52 (aka ac3, dolby digital)
o aac (used in .mp4 files)
o dts (via external decoder)
o vorbis
o pcm
o adpcm (MS/IMA/DVI/Dialogic)
o mu-law and A-law
o roq dpcm
o Real Media dnet audio
o Real Media 28.8 audio
o DivX audio (WMA)
o GSM 6.10
o FLAC
o NSF (NES sound format)
o Speex
via external binary/win32 codecs (not included in xine):
o MS GSM
o Intel Music Coder
o Voxware Metasound
o ACELP.net
o Real Media Sipro/Cook/dnet
o QDesign Music 1/2 (QDM1/QDM2)
currently unsupported/untested Formats:
o some formats frequently found in quicktime streams (Qualcomm Pure Voice...)

Xine with LCD Interface

Website : - http://xinehq.de/
MPlayer

MPlayer stands for Movie Player for Linux and is another popular video player for Linux platform . Besides being open source as most of the application under Linux are , it is available not only on Linux , But also on Windows,OS X etc. MPlayer is a command line based application for playing video files and a number of frontends exist for mplayer making it easier for newbies to play Media Files. The List of supported file formats is quiet similar to Xine as MPlayer also uses some of the library used by xine for decoding videos including w32codec pack.
MPlayer website states that it can play damaged Video CD's, bad AVI files with damaged index properly though i was not able to confirm it. So this may be another plus for some with collection of old VCD's.
Another useful application included with Mplayer is mencoder which can convert one Mplayer playable format to another.

Some of the supported file formats are : - MPEG, VOB, AVI, OGG/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA, Matroska files, supported by many native, XAnim, RealPlayer, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, RealMedia, Sorenson, Theora, and MPEG-4 (DivX) movies too.
Above list of supported file formats taken from mplayer's website.

One of the common frontend for MPlayer is Gmplayer which is skinnable .


Gmplayer the graphical frontend to MPlayer

Website : - http://www.mplayerhq.hu/
Video Lan Player : VLC Player

VLC Player is another of popular video player available under Linux . It is released under GNU General Public license and is available for different platform including Windows,Linux,BeOS,Mac OS X etc. VLC player is based upon free open source libraries like libdvdcss,FFMpeg for decoding various video formats. Since both Xine and Mplayer are based upon FFmpeg file hence the list of supported codecs without installing extra files is almost same for all three players. One Important feature of VLC Player is it's ability to play files over NetWork Protocols. The Frontend of VLC player is created using wxWidgets toolkit and it's appearance can be changed by using different skins. One Popular feature of VLC Player is it's ability to play files that are incomplete/broken or partially downloaded , making it useful for previewing file while downloading on file-sharing networks. Besides this another interesting feature of vlc player is it's ability to play files contained inside iso image. This might prove useful if you have copy of a cd on your hard-disk and you want to play file without burning on the cd. Besides this another thing for which you can use VLC player is to play FLV files on Linux/Windows which are Flash Video files popularly used on video-sharing website like YouTube .

Website : - http://www.videolan.org/vlc/

iTunes alternative to linux : - Banshee and Rhythmbox

Banshee :- is a music player for Linux platform written on Mono,C# and uses Helix and GStreamer as a backend to play Ogg,MP3 and other formats . Besides having a user friendly interface it can be used for Syncing iPODs, importing music from cd . Besides having all these features it's feature can be extended via adding external plugins since it has a nice plug-in architecture . Banshee is released under MIT License .

Rhythmbox : - Rhythmbox is gnome application based upon GStreamer architecture and has a similar interface to itunes. With SoundJuicer plugin it can import audio cd's , it has ability to sync iPODs . It has support for Internet Radio . Besides all the features being a gnome application it integrates with gnome quiet nicely . Some of the popular plugins are :-

Gaim-RhythmBox : - Shows song information for currently playing song in the Gaim instant messenger .

BlueRemote : - Allows controlling of rhythmbox from a blue tooth enabled phones .

FoxyTune : - Allows controlling of rhythmbox application from Mozilla FireFox browser without leaving the browser .

Rhythmbox running on FC 6

Website : - http://www.gnome.org/projects/rhythmbox/
Website : - http://www.banshee-project.org/
Article written by Ambuj Varshney<> for linuxondesktop.blogspot.com
(C) 2007 Ambuj Varshney