<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hack Admin &#187; convert</title>
	<atom:link href="http://www.hackadmin.com/tag/convert/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackadmin.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 21:31:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Strip MP3s from YouTube with ffmpeg.</title>
		<link>http://www.hackadmin.com/2009/07/09/strip-mp3s-from-youtube-with-ffmpeg/</link>
		<comments>http://www.hackadmin.com/2009/07/09/strip-mp3s-from-youtube-with-ffmpeg/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 01:47:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=134</guid>
		<description><![CDATA[Here&#8217;s a nifty little script that will take a YouTube URL as an argument, pull down the associated flv and convert it into mp3 format.  It&#8217;s basically all shell but I wrapped it with php.
First:
Take the YouTube URL as an argument
$url = $argv[1];
Next:
Use a little shell magic to grab the video arguments for later [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a nifty little script that will take a YouTube URL as an argument, pull down the associated flv and convert it into mp3 format.  It&#8217;s basically all shell but I wrapped it with php.</p>
<p>First:</p>
<p>Take the YouTube URL as an argument</p>
<p><code>$url = $argv[1];</code></p>
<p><span id="more-134"></span>Next:</p>
<p>Use a little shell magic to grab the video arguments for later use:</p>
<p><code>$vid_args = `lynx -source "$url" | grep video_id | grep fullscreen | awk -F'video_id=' '{print $2}' | awk -F'&amp;title'</code></p>
<p>Next:</p>
<p>use basically the same command to grab the title of the video:</p>
<p><code>$title = 'lynx -source "$url" | grep video_id | grep fullscreen | awk -F'video_id=' '{print $2}' | awk -F'&amp;title=' '{print $2}' ';</code></p>
<p>Then:</p>
<p>Do a little formatting of the title to make it useable:</p>
<p><code>$title = preg_replace("| |", "_", $title);<br />
$title = trim($title);<br />
$title = preg_replace("/^[^a-z0-9]?(.*?)[^a-z0-9]?$/i", "$1", $title);<br />
$title = preg_replace("|'|", "", $title);<br />
$title = preg_replace("|\)|", "", $title);<br />
$title = preg_replace("|\(|", "", $title);<br />
$title = preg_replace("|\/|", "_", $title);</code></p>
<p>Then:</p>
<p>Grab the flv with the video arguments you captured from the line above:</p>
<p><code>'wget -O /tmp/$title.flv "http://www.youtube.com/get_video?video_id=$vid_args"';</code></p>
<p>Next:</p>
<p>Use ffmpeg to break it down to mp3 format:</p>
<p><code>'ffmpeg -i /tmp/$title.flv -ar 44100 -ab 160k -ac 2 /tmp/$title.mp3';</code></p>
<p>Finally:</p>
<p>Dump the flv and enjoy:</p>
<p><code>'rm -f /tmp/$title.flv';</code></p>
<p>These files are of course only for educational purposes when you are finished so make sure you delete them <img src='http://www.hackadmin.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.hackadmin.com/downloads/tubeconverter.php.txt">Download The Whole Script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2009/07/09/strip-mp3s-from-youtube-with-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
