<?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>Johannes Luderschmidt&#039;s Blog &#187; bash</title>
	<atom:link href="http://johannesluderschmidt.de/lang/en-us/category/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://johannesluderschmidt.de</link>
	<description>This is a blog about topics like multi-touch, Flash programming and natural user interfaces.</description>
	<lastBuildDate>Tue, 10 Jan 2012 15:54:58 +0000</lastBuildDate>
	<language>en-us</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<item>
		<title>Create Thumbnail Images from Flash Video FLVs Folder with Bash Script</title>
		<link>http://johannesluderschmidt.de/lang/en-us/create-thumbnail-images-from-flash-video-flvs-folder-with-bash-script/525</link>
		<comments>http://johannesluderschmidt.de/lang/en-us/create-thumbnail-images-from-flash-video-flvs-folder-with-bash-script/525#comments</comments>
		<pubDate>Sat, 28 Mar 2009 10:42:06 +0000</pubDate>
		<dc:creator>johannes</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash video]]></category>
		<category><![CDATA[flv]]></category>

		<guid isPermaLink="false">http://johannesluderschmidt.de/?p=525</guid>
		<description><![CDATA[I&#8217;ve had the problem that I wanted to show a list of Flash videos in a Flex application and I want to show a sample picture of each video. As I have got only the videos stored in a folder and have no jpegs of them, I want to generate those sample jpegs, one for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had the problem that I wanted to show a list of Flash videos in a Flex application and I want to show a sample picture of each video. As I have got only the videos stored in a folder and have no jpegs of them, I want to generate those sample jpegs, one for each video in the folder. Thus, I found quite a lot of blog entries that show you how you can create an image from a Flash video with the Open Source tool <a href="http://www.ffmpeg.org/">ffmpeg</a>.</p>
<p>As I want to do this not for a single file but for a whole folder, I have written a bash script, that renders out a frame of each FLV video into a jpeg and saves them into a folder called <em>thumbnails</em> of the folder in which it is lying.<br />
<span id="more-525"></span><br />
So here is the bash script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
 <span style="color: #000000; font-weight: bold;">for</span> FILENAME <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.flv
 <span style="color: #000000; font-weight: bold;">do</span>
   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FILENAME</span>&quot;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Create thumbnail of <span style="color: #007800;">$FILENAME</span>&quot;</span>
     <span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FILENAME</span>&quot;</span> <span style="color: #660033;">-ss</span> 00:00:<span style="color: #000000;">01.00</span> <span style="color: #660033;">-vcodec</span> mjpeg <span style="color: #660033;">-vframes</span> <span style="color: #000000;">1</span> \ 
         <span style="color: #660033;">-f</span> image2 .<span style="color: #000000; font-weight: bold;">/</span>thumbnails<span style="color: #000000; font-weight: bold;">/</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$FILENAME</span>&quot;</span>.jpg
     <span style="color: #666666; font-style: italic;">#cp $FILENAME ~/test1/</span>
   <span style="color: #000000; font-weight: bold;">else</span>
       <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;File <span style="color: #007800;">$FILENAME</span> not existing.&quot;</span>
   <span style="color: #000000; font-weight: bold;">fi</span>
 <span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p><a href='http://johannesluderschmidt.de/wp-content/uploads/2009/03/createFlvThumbnailsInCurrentFolder.zip'>Download bash script as a file.</a></p>
<p>If your under Mac OS X (or any other Unix system that supports bash scripts) you will have to save and extract this file in the folder where your FLV files are in and then cd to it in the Terminal and make it executable:<br />
<code><br />
chmod u+x createFlvThumbnailsInCurrentFolder.sh<br />
</code><br />
and then execute it in that folder:<br />
<code><br />
./createFlvThumbnailsInCurrentFolder.sh<br />
</code></p>
<p>If there is nothing happening you maybe have to create the folder thumbnails on your own:<br />
<code><br />
mkdir thumbnails<br />
</code></p>
<p>The script should be able to cope with blanks in filenames. However, there are some letters in filenames (like &#8216;/&#8217;) that it cannot cope with. But you will see, which images are missing in the thumbnails folder and can then appropriately rename those files.</p>
<p>Please be so kind to post improvements of the script in the comments.</p>
<p>Cheers!</p>
<p>(Script is under <a href="http://creativecommons.org/licenses/by/2.5/">Creative Commons Attribution 2.5 License</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://johannesluderschmidt.de/lang/en-us/create-thumbnail-images-from-flash-video-flvs-folder-with-bash-script/525/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

