Sonntag, 4. Oktober 2009

Encoding videos for the Aiptek V10

About two weeks ago I felt the need to try out the Aiptek V10 LED Micro Projector and it actually sucks a lot less than I thought. I am still thinking about selling it again but it was a nice thing to play with and it fulfilled its purpose.


What I found to be very problematic is encoding videos for the aiptek with my mac (same problem with linux or other unix-based systems I guess). There are a couple of pitfalls and it took me about 5 hours to figure every detail out so don't waste as much time as I did and try what I came up with!

I used mencoder and ffmpeg to create working mp4 containers. Mencoder is able to add black bars to your movies; the aiptek will not play anything other than a movie which is exactly 640x480 in size, you can not just adjust the width to 640. I use ffmpeg after adjusting the video size to get a correct audio stream. I haven't quite figured out why mencdoers ac3 doesn't play on the v10 but a quick run of ffmpeg to adjust the audio stream works quite well and doesn't take too long. All in all I came up with the following:

Software:
  • mencoder using macports ("sudo port install mplayer-devel +faac +x264 +xvid")
  • ffmpeg using macports ("sudo port install ffmpeg")
Commands used:
mencoder "$file" -sws 9 -of avi -ovc lavc -lavcopts \
  vcodec=mpeg4:vbitrate=300 -o "$file-temp" \
  -vf scale=640:-2,expand=640:480:0:0:1::,harddup -oac faac -faacopts br=64:object=2:mpeg=4 \
  -srate 44100 -channels 2 -ofps 25 -ffourcc DIVX -noodml


ffmpeg -i "$file-temp" -s 640x480 -b 800k -acodec libfaac -ab 64 -vcodec mpeg4 -vtag divx "$outfile"

 The first command resizes the video stream and changes formats, the second run "fixes" audio. Now I am not sure why this is necessary but it works for me and it is resonably fast. You can also make a small script out of it:

#!/bin/bash

file=$1
outfile=${file%.[^.]*}

mencoder "$file" -sws 9 -of avi -ovc lavc -lavcopts \
  vcodec=mpeg4:vbitrate=300 -o "$outfile-temp-aiptek.mp4" \
  -vf scale=640:-2,expand=640:480:0:0:1::,harddup -oac faac -faacopts br=64:object=2:mpeg=4 \
  -srate 44100 -channels 2 -ofps 25 -ffourcc DIVX -noodml

ffmpeg -i "$outfile-temp-aiptek.mp4" -s 640x480 -b 800k -acodec libfaac -ab 64 -vcodec mpeg4 -vtag divx "$outfile-aiptek.mp4"
rm "$outfile-temp-aiptek.mp4"


This script encodes the video given as first parameter for the aiptek not changing the original and creating a new file with -aiptek as suffix.

Hope this helps someone out there; I'd really love to hear from you if it did or if you have improved my approach!

4 Kommentare:

  1. Hi!

    I just bought an Aiptek V10 today, a steal at just 1600sek, ~150eur! I run Ubuntu, tried using your script. I had to recompile ffmpeg as the package version didn't support libfaac, I followed the guide at http://ubuntuforums.org/showthread.php?t=786095 . After that, apart from the typo (-temp-aiptel.mp4), it worked great!

    Thanks for documenting this! It would have taken me ages to figure this out! :)

    Regards,
    Peter

    AntwortenLöschen
  2. Thanks for your kind feedback, just fixed the typo :) have fun with your aiptek!

    Henrik

    AntwortenLöschen
  3. For what it's worth, I found a workable solution using ffmpegX. I am not much of a Unix command-line guru but I tried what you did above. I couldn't get past the installation commands!

    So I tried ffmpegX. I tried all the plausible codecs and found one that worked: XviD [.MP4] (ffmpeg) with MP3 audio.

    The quality is still not what it should be and I will try more settings in different applications. But the above combination will work 100% with no crashes. It took me a long time to get video + audio to work on that damned thing!

    AntwortenLöschen
  4. A few more things. I tried the commands again and had success with mencoder. The format you gave above did not work and had to modify it (I'm using 10.4.11 on PPC). The image quality is far superior to what ffmpegX gave me using XviD [.MP4]. Of course audio does not play.

    So now onto ffmpeg. Well, it doesn't work on the Aiptek, no matter what I do. To even get it to encode I had to replace -acodec libfaac with -acodec aac. I even tried -vcodec copy. No luck.

    BTW, when I use ffmpegX, yes I get sound on the Aiptek but the sync is way, way off (I didn't notice when I posted my first comment). I think I can fix that with an intermediate step. But as I said, picture quality is not good.

    AntwortenLöschen