How to download YouTube flash videos in Linux and convert them to a format for viewing in windows
You will need have all the necessary 3rd party rpms installed from livna. You should be able to play .flv files with movie player (totem-xine) xine, mplayer etc.
First download the youtube-dl script found at http://www.arrakis.es/~rggi3/youtube-dl/ by opening a terminal and typing the following:
i have also attached it for download:
[jonathon@localhost ~]$
Code:
wget http://www.arrakis.es/~rggi3/youtube-dl/youtube-dl
--11:50:26-- http://www.arrakis.es/~rggi3/youtube-dl/youtube-dl
=> `youtube-dl'
Resolving www.arrakis.es... 212.59.199.45
Connecting to www.arrakis.es|212.59.199.45|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15,750 (15K) [text/plain]
100%[====================================>] 15,750 17.70K/s
11:50:28 (17.68 KB/s) - `youtube-dl' saved [15750/15750]
[jonathon@localhost ~]$ Password:
[root@localhost jonathon]# [root@localhost jonathon]# a86bfb24c5f9b7aff0c4ec2975c1a03c youtube-dl
[root@localhost jonathon]#
Code:
chmod 744 youtube-dl
[root@localhost jonathon]#
Code:
mv /home/jonathon/youtube-dl /usr/bin
............close terminal
To download a flash-video from YouTube open a terminal and type the following:
[jonathon@localhost ~]$
Code:
youtube-dl -t http://www.youtube.com/watch?v=Yl8qfu-ojTQ
Retrieving video webpage... done.
Extracting video title... done.
Extracting URL "t" parameter... done.
Requesting video file... done.
Video data found at http://nyc-v135.nyc.youtube.com/get_...key=yt1&sver=2
Retrieving video data: 100.0% ( 11.74M of 11.74M) at 58.29k/s ETA 00:00 done.
Video data saved to making_a_trumpet-Yl8qfu-ojTQ.flv
Checkout the 'More Usage Tips" at http://www.arrakis.es/~rggi3/youtube-dl/
or open a terminal and type the following:
[jonathon@localhost ~]$ Usage: youtube-dl [options] video_url
Options:
-h, --help print this help text and exit
-v, --version print program version and exit
-u USERNAME, --username=USERNAME
account username
-p PASSWORD, --password=PASSWORD
account password
-o FILE, --output=FILE
output video file name
-q, --quiet activates quiet mode
-s, --simulate do not download video
-t, --title use title in file name
-l, --literal use literal title in file name
-n, --netrc use .netrc authentication data
-g, --get-url print final video URL only
-2, --title-too used with -g, print title too
-f FORMAT, --format=FORMAT
append &fmt=FORMAT to the URL
-b, --best-quality alias for -f 18
To convert flash videos to MPEG-4 for viewing in windows media player and other types of devices open a terminal and type the following:
[jonathon@localhost ~]$
Code:
gedit /home/jonathon/flv2avi.sh
paste the following script from http://www.linux.com/articles/56642:
Code:
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 {-divx|-xvid} list_of_flv_files"
exit 1
fi
# video encoding bit rate
V_BITRATE=1000
while [ "$1" ]; do
case "$1" in
-divx)
MENC_OPTS="-ovc lavc -lavcopts \
vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoaspect"
;;
-xvid)
MENC_OPTS="-ovc xvid -xvidencopts bitrate=$V_BITRATE:autoaspect"
;;
*)
if file "$1" | grep -q "Macromedia Flash Video"; then
mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame \
-lameopts fast:preset=standard -o \
"`basename $1 .flv`.avi"
else
echo "$1 is not Flash Video. Skipping"
fi
;;
esac
shift
done
............save and close
[jonathon@localhost ~]$ Password:
[root@localhost jonathon]# [root@localhost jonathon]#
Code:
chmod 755 flv2avi.sh
[root@localhost jonathon]#
Code:
mv /home/jonathon/flv2avi.sh /usr/bin
..........close terminal
If you would like to convert your flash videos to an open source MPEG-4 codec (libavcodec) you can use the -xvid option. The -xvid option refers to software that is used to encode MPEG-4 ASP video. Your new video file will have an .avi extension. The -divx option refers to proprietary based closed source software that is used to create an MPEG-4 codec.The file will also have an .avi extension. By the way if this is not correct please correct me..))
Code:
flv2avi.sh -xvid /home/jonathon/myvideo1.flv
or
Code:
flv2avi.sh -divx /home/jonathon/myvideo1.flv
Another way to convert the flash video to avi that works very well is with this command:
Code:
ffmpeg -i /home/user/myvideo.flv -ar 48000 -ac 2 /home/user/myvideo.avi
example:
[jonathon@localhost ~]$
Code:
ffmpeg -i /home/jonathon/making_a_trumpet.flv -ar 48000 -ac 2 /home/jonathon/making_a_trumpet.avi
FFmpeg version SVN-r10703, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --prefix=/usr --incdir=/usr/include/ffmpeg --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --arch=i386 --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables --enable-liba52 --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libogg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-libx264 --enable-pp --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-opts --disable-strip
libavutil version: 49.5.0
libavcodec version: 51.45.0
libavformat version: 51.14.0
built on Oct 18 2007 03:11:06, gcc: 4.1.2 20070925 (Red Hat 4.1.2-31)
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
Input #0, flv, from '/home/jonathon/making_a_trumpet.flv':
Duration: 00:05:00.0, start: 0.000000, bitrate: 56 kb/s
Stream #0.0: Video: flv, yuv420p, 320x240, 25.00 fps(r)
Stream #0.1: Audio: mp3, 22050 Hz, mono, 56 kb/s
Output #0, avi, to '/home/jonathon/making_a_trumpet.avi':
Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 25.00 fps(c)
Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 7502 fps=264 q=11.4 Lsize= 10369kB time=300.0 bitrate= 283.2kbits/s
video:7544kB audio:2344kB global headers:0kB muxing overhead 4.876258%
[jonathon@localhost ~]$
The tag at the end "myvideo.avi" eg making_a_trumpet.avi allows you to choose the name of the output file.
johnny