<?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/"
xmlns:series="http://unfoldingneurons.com/"
><channel><title>David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞. &#187; Shell</title> <atom:link href="http://davidwalsh.name/tutorials/shell/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Sat, 04 Feb 2012 19:28:58 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Recursively Delete .svn&#160;Directories</title><link>http://davidwalsh.name/delete-svn</link> <comments>http://davidwalsh.name/delete-svn#comments</comments> <pubDate>Thu, 17 Mar 2011 14:01:25 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5188</guid> <description><![CDATA[Version control systems are hugely important when it comes to development of all kinds.  I&#8217;m a huge fan of git but sometimes I&#8217;m required to use SVN.  Unfortunately I tend to forget to remove .svn folders when I copy and paste from a directory structure template.  This, of course, leads to me overwriting files and [...]<p><a
href="http://davidwalsh.name/delete-svn">Recursively Delete .svn&nbsp;Directories</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>Version control systems are hugely important when it comes to development of all kinds.  I&#8217;m a huge fan of git but sometimes I&#8217;m required to use SVN.  Unfortunately I tend to forget to remove .svn folders when I copy and paste from a directory structure template.  This, of course, leads to me overwriting files and results in mass confusion.  I recently <a
href="http://www.crainbandy.com/linux/recursively-remove-svn-directories-2">stumbled up</a> an awesome command line script which recursively removes .svn directories from parent directories.</p><pre class="shell">
find . -type d -name .svn -exec rm -rf {} \;
</pre><p>The script starts within the current directory, so be sure you navigate to the directory you want to start searching from first. This script would work on any search type; simply replace &#8220;.svn&#8221; with the search of your choosing but be careful:  if your search term is too general, you may end up deleting a bunch of stuff you don&#8217;t want to!</p><p><a
href="http://davidwalsh.name/delete-svn">Recursively Delete .svn&nbsp;Directories</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/delete-svn/feed</wfw:commentRss> <slash:comments>19</slash:comments> </item> <item><title>Fixing Python&#8217;s &#8220;Python Eggs&#8221;&#160;Error</title><link>http://davidwalsh.name/python-eggs</link> <comments>http://davidwalsh.name/python-eggs#comments</comments> <pubDate>Thu, 25 Feb 2010 14:29:00 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4879</guid> <description><![CDATA[Let me first state this for the record: I am not a server guy. The closest I&#8217;ve ever gotten to compiling my own versions of code is &#8220;sudo port install &#8230;&#8221; So when I decided to teach myself Python (creating simply database interaction, record listings, etc) and kept getting &#8220;500 Internal Server Error&#8221; messages, I [...]<p><a
href="http://davidwalsh.name/python-eggs">Fixing Python&#8217;s &#8220;Python Eggs&#8221;&nbsp;Error</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>Let me first state this for the record:  I am not a server guy.  The closest I&#8217;ve ever gotten to compiling my own versions of code is &#8220;sudo port install &#8230;&#8221;  So when I decided to teach myself Python (creating simply database interaction, record listings, etc) and kept getting &#8220;500 Internal Server Error&#8221; messages, I thought I was doomed.  I opened up the Apache error log and saw this:</p><pre class="shell">
[error] [client ::1] Traceback (most recent call last):
[error] [client ::1]   File &quot;/Users/davidwalsh83/Projects/server/something.py&quot;, line 6, in &lt;module&gt;
[error] [client ::1]     import MySQLdb, cgi, cgitb, httplib, urllib2
[error] [client ::1]   File &quot;build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py&quot;, line 19, in &lt;module&gt;
[error] [client ::1]   File &quot;build/bdist.macosx-10.6-universal/egg/_mysql.py&quot;, line 7, in &lt;module&gt;
[error] [client ::1]   File &quot;build/bdist.macosx-10.6-universal/egg/_mysql.py&quot;, line 4, in __bootstrap__
[error] [client ::1]   File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py&quot;, line 835, in resource_filename
[error] [client ::1]     self, resource_name
[error] [client ::1]   File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py&quot;, line 1304, in get_resource_filename
[error] [client ::1]     self._extract_resource(manager, self._eager_to_zip(name))
[error] [client ::1]   File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py&quot;, line 1326, in _extract_resource
[error] [client ::1]     self.egg_name, self._parts(zip_path)
[error] [client ::1]   File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py&quot;, line 915, in get_cache_path
[error] [client ::1]     self.extraction_error()
[error] [client ::1]   File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py&quot;, line 881, in extraction_error
[error] [client ::1]     raise err
[error] [client ::1] pkg_resources.ExtractionError: Can't extract file(s) to egg cache
[error] [client ::1] 
[error] [client ::1] The following error occurred while trying to extract file(s) to the Python egg
[error] [client ::1] cache:
[error] [client ::1] 
[error] [client ::1]   [Errno 20] Not a directory: '/Library/WebServer/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp'
[error] [client ::1] 
[error] [client ::1] The Python egg cache directory is currently set to:
[error] [client ::1] 
[error] [client ::1]   /Library/WebServer/.python-eggs
[error] [client ::1] 
[error] [client ::1] Perhaps your account does not have write access to this directory?  You can
[error] [client ::1] change the cache directory by setting the PYTHON_EGG_CACHE environment
[error] [client ::1] variable to point to an accessible directory.
[error] [client ::1] 
[error] [client ::1] Premature end of script headers: something.py
</pre><p>My first thought was &#8220;Wow, that&#8217;s quite a long way of telling me to &#8216;just quit.&#8217;&#8221;  Not wanting to concede defeat, I did some quick Google searching to find that the following snippet of Python code would allow me program another day:</p><pre class="shell">
import os
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
</pre><p>I&#8217;d like to pretend I know what that means but I really don&#8217;t know.  In any event, if you start receiving those errors, this snippet could be your ticket to taking a bite out of Python.</p><p><a
href="http://davidwalsh.name/python-eggs">Fixing Python&#8217;s &#8220;Python Eggs&#8221;&nbsp;Error</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/python-eggs/feed</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>MooTools Forge / GitHub Plugin Structure Shell&#160;Script</title><link>http://davidwalsh.name/mootools-forge-script</link> <comments>http://davidwalsh.name/mootools-forge-script#comments</comments> <pubDate>Tue, 15 Dec 2009 14:11:47 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4410</guid> <description><![CDATA[One thing I love about the MooTools Forge is that it requires a strict structure for its plugins i.e. requiring a README.md file, Source directory, etc. I&#8217;ve created a shell script that I can run that creates the directory structure and files required to add my plugin to GitHub and then the Forge. The Shell [...]<p><a
href="http://davidwalsh.name/mootools-forge-script">MooTools Forge / GitHub Plugin Structure Shell&nbsp;Script</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>One thing I love about the MooTools Forge is that it requires a strict structure for its plugins i.e. requiring a README.md file, Source directory, etc.  I&#8217;ve created a shell script that I can run that creates the directory structure and files required to add my plugin to GitHub and then the Forge.</p><h2>The Shell Script &amp; Usage</h2><p>The first step is creating the repository at GitHub.  Once created at GitHub, I run the script, giving it the name of the plugin and repository (they must be the same):</p><pre class="shell">
./newPlugin.sh ScrollSpy
</pre><p>The script itself looks like:</p><pre class="shell">
#!/bin/sh
mkdir $1
cd $1
git init
touch README.md
mkdir Source
touch Source/$1.js
touch Source/$1-yui-compressed.js
mkdir Docs
touch Docs/$1.md
touch package.yml
echo &quot;name:  $1
author:  davidwalsh
current:  
category:  
tags:  []
docs:  
demo:  &quot; &gt;&gt; package.yml;
cd $1
git add *
git commit -m &quot;First Commit&quot;
git remote add origin g&#105;&#116;&#64;&#103;i&#116;&#104;&#117;&#98;&#46;&#99;o&#109;:darkwing/$1.git
</pre><p>Tada!  Done!  Now I just need to populate each file with the necessary content. MooTools FTW!</p><p><a
href="http://davidwalsh.name/mootools-forge-script">MooTools Forge / GitHub Plugin Structure Shell&nbsp;Script</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-forge-script/feed</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Run PHP Files From the Command&#160;Line</title><link>http://davidwalsh.name/php-command-line</link> <comments>http://davidwalsh.name/php-command-line#comments</comments> <pubDate>Fri, 02 Oct 2009 13:24:20 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3753</guid> <description><![CDATA[I&#8217;ve been brushing up on my shell scripting lately. I just got a MacBook and never felt compelled to spend too much time with Cygwin. I&#8217;m learning quite a bit now but there are still some tasks that I&#8217;d need to accomplish sooner rather than later. I know how to accomplish the task using PHP [...]<p><a
href="http://davidwalsh.name/php-command-line">Run PHP Files From the Command&nbsp;Line</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been brushing up on my shell scripting lately.  I just got a MacBook and never felt compelled to spend too much time with Cygwin.  I&#8217;m learning quite a bit now but there are still some tasks that I&#8217;d need to accomplish sooner rather than later.  I know how to accomplish the task using PHP so I&#8217;ve got that to my advantage.  What&#8217;s awesome is that I can quickly and easily run my PHP files from the command line.</p><h2>The Shell&nbsp;Script</h2><pre class="shell">
php doTask.php
</pre><p>I&#8217;m not sure whether I consider using PHP instead of a straight shell script as being resourceful or using PHP as a crutch.  What are your thoughts?</p><p><a
href="http://davidwalsh.name/php-command-line">Run PHP Files From the Command&nbsp;Line</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/php-command-line/feed</wfw:commentRss> <slash:comments>22</slash:comments> </item> <item><title>Automate YouTube Video and MP3 Rips with Bash Shell&#160;Scripting</title><link>http://davidwalsh.name/youtube-mp3</link> <comments>http://davidwalsh.name/youtube-mp3#comments</comments> <pubDate>Thu, 01 Oct 2009 12:21:04 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3698</guid> <description><![CDATA[I love listening to music while I code. Listening to music keeps me from getting too frustrated about code that isn&#8217;t working (yes, it happens) or frustrations brought on by hosting providers, clients, etc. What I&#8217;ll do is listen to Pandora, hear a song I like, look up the song on YouTube, and save the [...]<p><a
href="http://davidwalsh.name/youtube-mp3">Automate YouTube Video and MP3 Rips with Bash Shell&nbsp;Scripting</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>I love listening to music while I code.  Listening to music keeps me from getting too frustrated about code that isn&#8217;t working (yes, it happens) or frustrations brought on by hosting providers, clients, etc.  What I&#8217;ll do is listen to Pandora, hear a song I like, look up the song on YouTube, and save the YouTube link in a text file for later listening.  Having to go to YouTube every time sucks so I set out to take YouTube videos linked in a text file and download them to my computer in MP3 format.</p><h2>The Text&nbsp;File</h2><pre class="text">

http://www.youtube.com/watch?v=iYtDqHupwrg


<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/xZ23pVTPfSw&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xZ23pVTPfSw&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object>


<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/Rvw1ctGWfSs&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Rvw1ctGWfSs&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object>


<object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/IXPOHCsgWFw&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/IXPOHCsgWFw&#038;fs=1" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object>


<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/QF73Ypncwss&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/QF73Ypncwss&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object>


<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/8nBmIetx_t8&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8nBmIetx_t8&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object>


<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/sw_x8XtngGM&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/sw_x8XtngGM&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object>

</pre><p>One link per line.</p><h2>The Bash&nbsp;Script</h2><pre class="shell">
#!/bin/sh
IFS=$'\n'
for line in `&lt; songs.txt`; do
	newfile=`youtube-dl.py -o %\(title\)s.%\(ext\)s $line | grep '^\[download\]' | cut -d ' ' -f 3-`
	ffmpeg -b 192k -i $newfile ${newfile/flv/mp3}
	rm $newfile
done
</pre><p>My script reads the file by line, downloads the YouTube video at the link provided by the text document, uses ffmpeg to rip the song into an MP3, and deleted the video.  Note that you&#8217;ll need YouTube-DL and FFMPEG to run this script;  this script is essentially a shortcut to achieve what was outlined in my post titled <a
href="http://davidwalsh.name/youtube-ffmpeg-mp3-conversion">YouTube, FFMPEG, and MP3 Conversion</a>.</p><p><a
href="http://davidwalsh.name/youtube-mp3">Automate YouTube Video and MP3 Rips with Bash Shell&nbsp;Scripting</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/youtube-mp3/feed</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>Creating Git&#160;Aliases</title><link>http://davidwalsh.name/git-aliases</link> <comments>http://davidwalsh.name/git-aliases#comments</comments> <pubDate>Fri, 25 Sep 2009 13:18:04 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3702</guid> <description><![CDATA[I create shortcuts for everything. I create variables which act as text shortcuts, shortcuts in TextMate to generate CSS/JS/HTML, and bash scripts so I don&#8217;t have to type in the same commands over and over again. So why should version control software be any different? I commit and push religiously so I create Git aliases [...]<p><a
href="http://davidwalsh.name/git-aliases">Creating Git&nbsp;Aliases</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>I create shortcuts for everything.  I create variables which act as text shortcuts, shortcuts in TextMate to generate CSS/JS/HTML, and bash scripts so I don&#8217;t have to type in the same commands over and over again.  So why should version control software be any different?  I commit and push religiously so I create Git aliases to save myself a few keystrokes.</p><h2>Sample&nbsp;Aliases</h2><pre class="git">
#make "com" alias for "commit"
git config alias.com commit

#make "co" alias for checkout
git config alias.co checkout

#make "br" alias for branch
git config alias.br branch

# When you want to see just the differences of one function in one file in two different commits
git config alias.funcdiff '!sh -c "git show \"\$1:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp1 &#038;&#038;
        git show \"\$2:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp2 &#038;&#038;
        git diff --no-index .tmp1 .tmp2"' -

</pre><p>These are just some sample Git aliases.  You can view more detailed (and by detailed I mean brain-numbing) examples of git aliases at the <a
href="http://git.or.cz/gitwiki/Aliases">Git Wiki</a>.</p><p><a
href="http://davidwalsh.name/git-aliases">Creating Git&nbsp;Aliases</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/git-aliases/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>PNGCRUSH a Directory of&#160;Images</title><link>http://davidwalsh.name/pngcrush-directory</link> <comments>http://davidwalsh.name/pngcrush-directory#comments</comments> <pubDate>Thu, 24 Sep 2009 12:24:15 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3713</guid> <description><![CDATA[One easy way of reducing website load time is by optimizing your images. PNG graphics are often more bloated than they need to be so using PNGCRUSH should be a no-brainer. PNGCRUSH&#8217;s basic usage provides only single-file-crushage but I&#8217;ve created a script that crushes PNGs in directories recursively. The Bash&#160;Script #!/bin/sh for png in `find [...]<p><a
href="http://davidwalsh.name/pngcrush-directory">PNGCRUSH a Directory of&nbsp;Images</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>One easy way of reducing website load time is by optimizing your images.  PNG graphics are often more bloated than they need to be so using PNGCRUSH should be a no-brainer.  PNGCRUSH&#8217;s basic usage provides only single-file-crushage but I&#8217;ve created a script that crushes PNGs in directories recursively.</p><h2>The Bash&nbsp;Script</h2><pre class="shell">
#!/bin/sh
for png in `find $1 -name "*.png"`;
do
	echo "crushing $png"	
	pngcrush -brute "$png" temp.png
	mv -f temp.png $png
done;
</pre><p>Do whatever you can to compress your images so that your website will load as quickly as possible.  PNGCRUSHing your images does not cause a loss of quality &#8212; only a loss of excess file size!  PNGCRUSHing my images saved over 120KB of bloated imagery for the recent redesign.</p><p><a
href="http://davidwalsh.name/pngcrush-directory">PNGCRUSH a Directory of&nbsp;Images</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/pngcrush-directory/feed</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>YouTube, FFMPEG, and MP3&#160;Conversion</title><link>http://davidwalsh.name/youtube-ffmpeg-mp3-conversion</link> <comments>http://davidwalsh.name/youtube-ffmpeg-mp3-conversion#comments</comments> <pubDate>Tue, 07 Jul 2009 13:08:15 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3102</guid> <description><![CDATA[Yesterday I published a quick post about a basic MPEG -&#62; FLV video conversion method using FFMPEG. Today I want to share another great usage of FFMPEG: stripping a video&#8217;s audio and creating an MP3. As an added bonus, I&#8217;ll be ripping the audio from a great YouTube video using youtube-dl, a python script with [...]<p><a
href="http://davidwalsh.name/youtube-ffmpeg-mp3-conversion">YouTube, FFMPEG, and MP3&nbsp;Conversion</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<img
src="http://davidwalsh.name/dw-content/rod.jpg" alt="Rod Stewart and Ron Wood" class="image" /><p>Yesterday I published a quick post about a basic <a
href="http://davidwalsh.name/convert-video-ffmpeg">MPEG -&gt; FLV video conversion method using FFMPEG</a>.  Today I want to share another great usage of FFMPEG:  stripping a video&#8217;s audio and creating an MP3.  As an added bonus, I&#8217;ll be ripping the audio from a <a
href="http://www.youtube.com/watch?v=tlWpnLdPwvk">great YouTube video</a> using <a
href="http://bitbucket.org/rg3/youtube-dl/wiki/Home">youtube-dl</a>, a python script with loads of options for downloading YouTube videos.</p><h2>The youtube-dl Shell&nbsp;Script</h2><pre class="shell">
#command
davidwalsh83$ youtube-dl.py http://www.youtube.com/watch?v=tlWpnLdPwvk

#output
[youtube] Setting language
[youtube] tlWpnLdPwvk: Downloading video webpage
[youtube] tlWpnLdPwvk: Extracting video information
[youtube] tlWpnLdPwvk: URL: http://www.youtube.com/get_video?video_id=tlWpnLdPwvk&#038;t=vjVQa1PpcFMZ4TkTSYXamGxmLZq-ot2l8Jx-HiNAf0I=&#038;el=detailpage&#038;ps=
[download] Destination: tlWpnLdPwvk.flv
[download] 100.0% of 18.78M at   53.98k/s ETA 00:00
</pre><p>The initial install of youtube-dl was tough but only because I&#8217;m not well-versed with the permissions side of Unix.  I eventually figured it out but if you have trouble installing youtube-dl or simply want to use its advanced options, check out <a
href="http://bitbucket.org/rg3/youtube-dl/wiki/Home">youtube-dl&#8217;s documentation</a>.  youtube-dl also provides an option to read a text file with a list of videos and will do a batch download. <em>Note: youtube-dl allows you to set an output file name but it didn&#8217;t appear to be working.</em> If you&#8217;d like a more simple method, Mark Sanborn wrote a great post on <a
href="http://www.marksanborn.net/howto/using-wget-to-download-youtube-videos/">ripping YouTube videos using wget</a>.</p><h2>The FFMPEG Shell&nbsp;Script</h2><pre class="shell">
davidwalsh83$ ffmpeg -i tlWpnLdPwvk.flv RodStewartMaggieMay.mp3
</pre><p>As I did with youtube-dl, I chose the most basic usage of FFMPEG. <a
href="http://www.ffmpeg.org/ffmpeg-doc.html">FFMPEG&#8217;s documentation</a> provides you a list of all of the possible conversion options if you need them.</p><h2>The&nbsp;Result</h2>[audio:RodStewartMaggieMay.mp3]<p>Use the video player above to listen to the result.  The video I chose is a live version of Maggie May by Rod Stewart recorded at Royal Albert Hall in the Knightsbridge area of the City of Westminster, London, England.  The video is from Rod&#8217;s <a
href="http://www.amazon.com/One-Night-Only-Stewart-Albert/dp/B00064VR0W/ref=sr_1_1?ie=UTF8&amp;s=music&amp;qid=1246897303&amp;sr=8-1">One Night Only DVD</a> which I HIGHLY recommend.  This is the best version of Maggie May that exists (my opinion but, as you know, when is my opinion not correct?)  Enjoy!</p><p><a
href="http://davidwalsh.name/youtube-ffmpeg-mp3-conversion">YouTube, FFMPEG, and MP3&nbsp;Conversion</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/youtube-ffmpeg-mp3-conversion/feed</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Convert Video Formats Using&#160;FFMPEG</title><link>http://davidwalsh.name/convert-video-ffmpeg</link> <comments>http://davidwalsh.name/convert-video-ffmpeg#comments</comments> <pubDate>Mon, 06 Jul 2009 11:13:54 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3023</guid> <description><![CDATA[Getting a video into the format you like can be important when providing media to your users on the web. Unfortunately your customer or video source may not give you media in the desired format. No problem: use the FFMPEG library to quickly and easily convert your media from and to any format you&#8217;d like. [...]<p><a
href="http://davidwalsh.name/convert-video-ffmpeg">Convert Video Formats Using&nbsp;FFMPEG</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<img
src="http://davidwalsh.name/dw-content/ffmpeg.jpg" alt="FFMPEG" class="image" /><p>Getting a video into the format you like can be important when providing media to your users on the web.  Unfortunately your customer or video source may not give you media in the desired format.  No problem:  use the <a
href="http://ffmpeg.org/index.html">FFMPEG</a> library to quickly and easily convert your media from and to any format you&#8217;d like.</p><h2>Installing&nbsp;FFMPEG</h2><pre class="shell">
sudo port install ffmpegx
</pre><p>The above installs FFMPEG with MacPorts.  The install process took quite a while because FFMPEG required that I upgrade quite a few packages.  Be patient&#8230;it&#8217;s worth it.</p><h2>Basic Conversion Shell&nbsp;Script</h2><pre class="shell">
ffmpeg -i myVideo.mpeg myVideo.flv
</pre><p>This is a very basic conversion directive.  Since Flash video has become the standard for embedding video, I&#8217;ve chosen to convert to the FLV format.  If you want to control more of the conversion details, <a
href="http://ffmpeg.org/documentation.html">grab the documentation</a> and experiment.  I&#8217;ve installed FFMPEG on a few websites and used PHP to direct FFMPEG to dynamically generate videos.</p><p>If you need to take control of your media, try FFMPEG.  FFMPEG also has a <a
href="http://www.macupdate.com/info.php/id/31364/ivideo-converter">GUI version</a> if you prefer to avoid command line.</p><p><a
href="http://davidwalsh.name/convert-video-ffmpeg">Convert Video Formats Using&nbsp;FFMPEG</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/convert-video-ffmpeg/feed</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>Reduce PNG Graphic Size Using&#160;PNGCRUSH</title><link>http://davidwalsh.name/pngcrush</link> <comments>http://davidwalsh.name/pngcrush#comments</comments> <pubDate>Thu, 02 Jul 2009 12:39:45 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Optimization]]></category> <category><![CDATA[Shell]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=2986</guid> <description><![CDATA[Now that I&#8217;m knee-deep in MacBook I love working with command line applications. There&#8217;s a certain beauty in the simplicity of using the console instead of a nice GUI. One task I use the console for often is reducing the size of PNG files using the powerhouse that is PNGCRUSH. The Shell&#160;Script # directive pngcrush [...]<p><a
href="http://davidwalsh.name/pngcrush">Reduce PNG Graphic Size Using&nbsp;PNGCRUSH</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></description> <content:encoded><![CDATA[<p>Now that I&#8217;m knee-deep in MacBook I love working with command line applications.  There&#8217;s a certain beauty in the simplicity of using the console instead of a nice GUI.  One task I use the console for often is reducing the size of PNG files using the powerhouse that is PNGCRUSH.</p><h2>The Shell&nbsp;Script</h2><pre class="shell">
# directive
pngcrush -reduce -brute source.png destination.png

#result
Best pngcrush method = 113 (fm 0 zl 9 zs 0) for destination.png
     (33.38% IDAT reduction)
     (33.43% filesize reduction)

   CPU time used = 835.707 seconds (decoding 151.450,
          encoding 679.145, other 5.112 seconds)
</pre><p>The above directive is a basic usage of PNGCRUSH.  PNGCRUSH offers a wealth of options that allow you to optimize your PNGs.  If you use many PNGs on your website, optimizing them using PNGCRUSH is a must.  Using the above directive, PNGCRUSH took a 11.7MB down to 7.8MB. <strong>NO QUALITY LOSS</strong>.  Sure it took over 10 minutes, but think of the bandwidth your site will save.</p><p><a
href="http://davidwalsh.name/pngcrush">Reduce PNG Graphic Size Using&nbsp;PNGCRUSH</a> is a post from: <a
href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p> ]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/pngcrush/feed</wfw:commentRss> <slash:comments>24</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 1/74 queries in 0.030 seconds using disk: basic
Object Caching 1467/1603 objects using disk: basic

Served from: davidwalsh.name @ 2012-02-08 13:34:59 -->
