<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Ignition Project: Tag multimedia</title>
    <link>http://www.ignition-project.com/articles/tag/multimedia</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Open Source Collaboration Solutions</description>
    <item>
      <title>My Deinterlacing and Post-Processing Scripts</title>
      <description>&lt;p&gt;At work, we put up a lot of Flash video. I use On2 Flix Pro for the Flash encoding part. But I get the content in a variety of formats. Perhaps the most common format we get is 480i MPEG-2 video interleaved. I&amp;#8217;m encoding on a Mac, and QuickTime cannot correctly feed the audio stream into Flix Pro because it&amp;#8217;s interleaved in the video stream. Also, Flix Pro&amp;#8217;s deinterlacer sucks. So, I use &lt;code&gt;mplayer&lt;/code&gt; and &lt;code&gt;mencoder&lt;/code&gt; to fudge the video around and deinterlace it. It&amp;#8217;s working very well. Oh yeah, you&amp;#8217;ll need &lt;a href="http://perian.org/"&gt;Perian&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Read it after the break.&lt;/p&gt;

&lt;p&gt;Wait, how do you get &lt;code&gt;mplayer&lt;/code&gt; and &lt;code&gt;mencoder&lt;/code&gt; on a Mac? &lt;code&gt;mplayer&lt;/code&gt; is included in MPlayer OSX. Show Package Contents, Resources, External_Binaries, mplayer, Show Package Contents, MacOS, and bam, your binary for mplayer is in there. &lt;code&gt;mencoder&lt;/code&gt;, on the other hand, is hard to find. I ended up using ffmpegX&amp;#8217;s &lt;code&gt;mencoder&lt;/code&gt;, which is &amp;#8220;MEncoder dev-CVS-060307-04:23-4.0.1&amp;#8221;, compared to my &lt;code&gt;mplayer&lt;/code&gt; which is &amp;#8220;MPlayer dev-SVN-r25648-4.0.1&amp;#8221; and way newer.&lt;/p&gt;

&lt;p&gt;First, I have to strip the MP3 audio stream and the MPEG-2 video stream, into separate files. I have my video rips folder set up with a &amp;#8220;scripts&amp;#8221; subfolder and a &amp;#8220;work&amp;#8221; subfolder. Here is my script to dump both streams:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#!/bin/bash

# Takes $1 and dumps it into two files in work/
./scripts/mplayer &amp;quot;$1&amp;quot; -dumpvideo -dumpfile work/dump.m2v
./scripts/mplayer &amp;quot;$1&amp;quot; -dumpaudio -dumpfile work/dump.mp3&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Next, I run cropdetect, which is a stupid script to save me typing:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#!/bin/bash

# Runs crop detect on the stream we dumped.
./scripts/mplayer work/dump.m2v -vf cropdetect -vo null -ao null&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Next, I run a deinterlacing and cropping filter. And postprocessing maybe, but I&amp;#8217;m not even sure if it works in &lt;code&gt;mplayer&lt;/code&gt; like it works in &lt;code&gt;mencoder&lt;/code&gt;. I&amp;#8217;m sure the latest &lt;code&gt;mencoder&lt;/code&gt; can let me combine this step with the next one. But as it stands I need to do this in two steps.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#!/bin/bash

# Takes work/dump.m2v and applies the crop in $1
# and deinterlaces, outputting to work/dump.deint.yuv

./scripts/mplayer work/dump.m2v -vf crop=$1,pp=de,yadif=0 \
    -vo yuv4mpeg:file=work/dump.deint.yuv&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Finally, I put both streams together, doing final postprocessing. I also convert it to HuffYUV because QuickTime can play it with &lt;a href="http://perian.org/"&gt;Perian&lt;/a&gt;. Again, I think the latest mencoder has the &lt;code&gt;yadif&lt;/code&gt; deinterlacer, which would let me combine the previous script and current script in one step. BTW - A/V sync gets off if you leave out &lt;code&gt;harddup&lt;/code&gt;.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#!/bin/bash

# Takes files in work and compiles them into work/output.avi
# $1 if specified is a list of additional filters to apply.

if [ &amp;quot;x$1&amp;quot; == &amp;quot;x&amp;quot; ]; then
    ./scripts/mencoder work/dump.deint.yuv -noskip -vf harddup,pp=de -ofps 30000/1001 -ovc lavc \
        -lavcopts vcodec=huffyuv:format=422p -audiofile work/dump.mp3 -oac copy -o work/output.avi
else
    ./scripts/mencoder work/dump.deint.yuv -noskip -vf harddup,pp=de,$1 -ofps 30000/1001 -ovc lavc \
        -lavcopts vcodec=huffyuv:format=422p -audiofile work/dump.mp3 -oac copy -o work/output.avi
fi&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Also, if you noticed, the previous script lets me specify additional filters on the command line if I want. Usually I have to run hqdn3d, but not always.&lt;/p&gt;

&lt;p&gt;Oh, and this will use about 1 GB per minute of content, times two because it&amp;#8217;s creating an uncompressed file twice (the final AVI and the intermediate &lt;code&gt;.deint.yuv&lt;/code&gt;). Don&amp;#8217;t run yourself out of disk space! :)&lt;/p&gt;</description>
      <pubDate>Wed, 26 Nov 2008 09:05:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:afb21c67-069b-4594-8089-e9601b2ec996</guid>
      <author>Keith Gable</author>
      <link>http://www.ignition-project.com/articles/2008/11/26/my-deinterlacing-and-post-processing-scripts</link>
      <category>Howto</category>
      <category>Linux</category>
      <category>Hacks</category>
      <category>multimedia</category>
      <category>deinterlacing</category>
      <category>mplayer</category>
    </item>
  </channel>
</rss>
