Posts Tagged ‘JCXD’

Downloading your favourity flash video from Youtube with a simple command (youtube-dl)

Wednesday, April 13th, 2011

downloading-flash-videos-from-youtube-on-linux-and-bsd-youtube-downloader-logo
Watching videos in youtube today and already for about 2 years is the de-facto hype.
There is almost none a day passed without almost each one of us has watched a dozen videos in Youtube.

Watching videos in youtube has become even more addictive for many than the early days of Internet Relay Chats (IRC)

As youtube is very accessible for people and it’s a comparativily easy way people share more and more with the day.
There is no question that the business idea of youtube is great and youtube generates millions of dollars for Google day by day, however I have a serious objection here! All is good the only pitfall is that you don’t own the youtube videos you watch!

Youtube’s story is not that different from the story of the cloud computing threat to internet users Freedom

The good thing here is that we’re not still completely dependant on youtube and there is still way to retrieve your favourite youtube video and store it for later watching or distribution.

Probably the most famous browser plugin that allows files retrieval from youtube, as most people know is DownloadHelper .

However using download helper is browser dependant, you need to use the browser to save the plugin and I don’t find it to be the best way to download a youtube video.

Since the old days I have started using Linux, I’ve been quite addicted to as many things on my linux as possible from the command line (terminal / console) (CLI) .

In that manner of thoughts it was a real delight for me to find out that a group of free software developer guys has come up with a command line tool that allows downloads of youtube videos straight from terminal, the great software is called youtube-dl and at the moment of this post writting it’s to be found on the URL address:

http://rg3.github.com/youtube-dl/

Youtube-dl is written in python so, it requires the Python interpreter, version 2.5 in order to properly run on Unix, Mac OS X or even on Windows!

The fact that it’s written in python has made the little shiny tool quite a multi-platform one.
To start using immediately the tool on a Debian or Ubuntu Linux you will have to install python (even though in most cases you must have it already installed):

1. To make sure you have python interpreter installed issue the cmd:

debian:~# apt-get install python
Building dependency tree
Reading state information... Done
python is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

As you can see from above apt-get’s output I do have it installed so nothing gets installed.

2. As a next step I used links to download the youtube-dl python script, like so:

debian:~# links https://github.com/rg3/youtube-dl/raw/2011.03.29/youtube-dl >> youtube-dl
Use the links interface to save youtube-dl and use gzip to ungzip it
debian:~# gzip -d youtube-dl.gz
debian:~# chmod +x youtube-dl

Now to make it system wide accessible I have copied the youtube-dl to /usr/local/bin , whether I selected /usr/local/bin as a location as this location is predetermined to contain mostly files which does not belong to a regular deb package.

3. Move youtube-dl to /usr/local/bin

debian:~# mv youtube-dl /usr/local/bin

4. Test the newly installed youtube-dl command line youtube retrieval tool:

debian:~# ./youtube-dl https://www.youtube.com/watch?v=g7tvI6JCXD0
[youtube] Setting language
[youtube] g7tvI6JCXD0: Downloading video webpage
[youtube] g7tvI6JCXD0: Downloading video info webpage
[youtube] g7tvI6JCXD0: Extracting video information
[download] Destination: g7tvI6JCXD0.flv
[download] 53.3% of 22.62M at 33.23k/s ETA 05:25
[download] 100.0% of 22.62M at 31.91k/s ETA 00:00 [u

As you might have noticed from the above youtube-dl command output the newly retrieved youtube file will be saved under a name g7tvI6JCXD0.flv

The line I passed to youtube-dl is directly taken from my browser and pasted to console, the file downloading from youtube took me about 10 minutes but this is mostly because of some kind of youtube server speed restrictions …

In general at least I have this video for later, watching, so after a while I can watch it once again without loosing a lot of time trying to remember what was the video headline name

5. To use youtube-dl in a bit advanced way you can for instance invoke the command with options like:

debian:~# ./youtube-dl -l -w -c https://www.youtube.com/watch?v=g7tvI6JCXD0
[youtube] Setting language
[youtube] g7tvI6JCXD0: Downloading video webpage
[youtube] g7tvI6JCXD0: Downloading video info webpage
[youtube] g7tvI6JCXD0: Extracting video information
[download] Destination: BSD is Dying, Jason Dixon, NYCBSDCon 2007-g7tvI6JCXD0.flv
[download] 4.4% of 22.62M at 1.43M/s ETA 00:15

As you can see now youtube-dl was even able to detect the downloaded video file name and store it on the computer with a correct name 😉

I would recommend you also to check out the youtube-dl help page, to do use command: youtube-dl –help
 

How to extract Audio Sound and Music from Flash Videos (.flv) files and convert it to (.mp3) on Linux and BSD

Friday, April 15th, 2011

In my quest to know Linux better and use it capabilities to fulfill a multimedia tasks I came across the question:

How can I extract audio sound and music from Flash Videos .flv file format?

After a bit of investigation online I’ve found out in order to achieve this task the quickest way is via the handy ffmpeg conversion tool .

It’s rather easy actually, all necessery to do the conversion is to have the ffmpeg installed.
FFMpeg is part of Debian and Ubuntu repositories, so if you haven’t installed it yet, go straigh and install it with:

debian:~# apt-get install ffmpeg
...

Many modern day Linux distributions already have the ffmpeg pre-installed by default, ffmpeg even have a Windows version so this little tutorial should be directly applied on a Windows host with installed ffmpeg.

Convertion of a .flv file to .mp3 file for example is a real piece of cake to so do issue the command:

debian:~# ffmpeg -i input_file.flv -ab 128 -ar 44100 output_file.mp3

The few mmpeg options meaning is as follows:

-i (specifies input file)
-ab (Set the audio bitrate in bit/s 64k by default)
-ar (Set the audio sampling frequency (default = 44100 Hz).)

For more options checkout the ffmpeg help.

I found ffmpeg to be a bit slower than I expected. A 17 minutes .flv video file is converted to .mp3 for 38 seconds time.

Here is the textual output I got on my Debian Linux while extracting the flash video’s sound and converting it to mp3:

debian:~# time ffmpeg -i g7tvI6JCXD0.flv -ab 128 -ar 44100 output.mp3
FFmpeg version SVN-r25838, Copyright (c) 2000-2010 the FFmpeg developers
built on Jan 21 2011 08:21:58 with gcc 4.4.5
configuration: –enable-libdc1394 –prefix=/usr –extra-cflags=’-Wall -g ‘ –cc=’ccache cc’ –enable-shared –enable-libmp3lame –enable-gpl –enable-libvorbis –enable-pthreads –enable-libfaac –enable-libxvid –enable-postproc –enable-x11grab –enable-libgsm –enable-libtheora –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libx264 –enable-libspeex –enable-nonfree –disable-stripping –enable-avfilter –enable-libdirac –disable-decoder=libdirac –enable-libschroedinger –disable-encoder=libschroedinger –enable-version3 –enable-libopenjpeg –enable-libvpx –enable-librtmp –extra-libs=-lgcrypt –disable-altivec –disable-armv5te –disable-armv6 –disable-vis
libavutil 50.33. 0 / 50.39. 0
libavcore 0.14. 0 / 0.14. 0
libavcodec 52.97. 2 / 52.97. 2
libavformat 52.87. 1 / 52.87. 1
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.65. 0 / 1.65. 0
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0
[flv @ 0x1336760] Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 29.92 (359/12)
Input #0, flv, from ‘g7tvI6JCXD0.flv’:
Metadata:
duration : 1060
starttime : 0
totalduration : 1060
width : 480
height : 360
videodatarate : 76
audiodatarate : 94
totaldatarate : 179
framerate : 30
bytelength : 23723246
canseekontime : true
sourcedata : B5F9E82C6HH1302704673918653
purl :
pmsg :
Duration: 00:17:40.35, start: 0.000000, bitrate: 174 kb/s
Stream #0.0: Video: h264, yuv420p, 480×360 [PAR 1:1 DAR 4:3], 77 kb/s, 29.92 tbr, 1k tbn, 2k tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16, 96 kb/s
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, mp3, to ‘output.mp3’:
Metadata:
duration : 1060
starttime : 0
totalduration : 1060
width : 480
height : 360
videodatarate : 76
audiodatarate : 94
totaldatarate : 179
framerate : 30
bytelength : 23723246
canseekontime : true
sourcedata : B5F9E82C6HH1302704673918653
purl :
pmsg :
TSSE : Lavf52.87.1
Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16, 0 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Press [q] to stop encoding
size= 16576kB time=1060.81 bitrate= 128.0kbits/s
video:0kB audio:16575kB global headers:0kB muxing overhead 0.002404%

real 0m38.489s
user 0m37.126s
sys 0m0.764s

When talking about conversions, another very useful application of ffmpeg is in case if you want to:

Extract Audio from online streams

Let’s say you have a favourite radio, you often listen and there are a podcast you want to capture for later listening, or just catch a few nice songs, using ffmpeg it’s a piece of cake by using the command like:

debian:~# ffmpeg -i http:///xxx.xxx.xxx.xxx/some -ab 128 -ar 44100 captured-radio-sound.mp3

The possible ways of use of ffmpeg is truly versatily, you can use it for instance if you have to convert some kind of audio or video format to another one I have given a very simple example of converting a .flv file to .avi and vice versa in my previous post