Tech Blog

Using Mac Homebrew to install ffmpeg

Posted At : January 31, 2012 11:40 PM 0 Comments

Super quick one - came across this issue again today and had to search for the solution, so as note to self:

To install ffmpeg via homebrew you need to specify which compiler to use on 10.7 at least:

brew install ffmpeg --use-clang

Cheers, Mark

Generating PDFs and ePubs from an AsciiDoc ... on a Mac

Posted At : August 11, 2011 9:41 AM 2 Comments


I've been updaging our existing documentation which was written in AsciiDoc and also creating new documentation recently.

Our normal process is to update the source text file, commit to our SVN and the run the documentation build script from the deployment server to create the HTML and PDF versions of the document.

This works fine from our server but to speed things up while I was writing the documents and make sure I had the formatting correct I thought I'd install AsciiDoc on my laptop and 'build' the document locally before committing to SVN, building and checking.

Installing AsciiDoc is simple enough using MacPorts:

$ sudo port install asciidoc

Creating a html version of your AsciiDoc is simple at this point:

$ asciidoc /home/ajdyka/sample.txt

That will output a file called sample.html in the same directory as the source file. No worries ...

To create a PDF or an ePub, it's recommended that you use the a2x command instead of asciidoc though.

According to the AsciiDoc website "a2x is A toolchain manager for AsciiDoc (converts Asciidoc text files to other file formats)"

So I gave this a try:

$ a2x -fpdf -dbook -L sample.txt
$ a2x -fepub -dbook -L sample.txt

It generated the following error though!

a2x: ERROR: xmllint --nonet --noout --valid sample.xml returned non-zero exit status 4

It took a bit of Googling (sp?) but I found the core of my solution in this post:Fixing the ePub problem with Docbook-XSL/A2X/Asciidoc

The only 'tricky' part was finding my catalogue.xml, which ended up being in /opt/local/share/xsl/docbook-xsl ... and I modified the contents to be:

<?xml version="1.0" encoding="utf-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<!-- XML Catalog file for DocBook XSL Stylesheets v1.76.1 -->
<rewriteURI uriStartString="/usr/local/docbook-xsl-1.76.1/epub" rewritePrefix="./"/>
<rewriteSystem systemIdStartString="/usr/local/docbook-xsl-1.76.1/epub" rewritePrefix="./"/>
</catalog>
* the new path is where I extracted the docbook-xsl-1.76.1 archive

Once I had done that, everything generated fine :)

The next thing I need to work on is getting the default XSLT template cleaned up :)

HTH

A.J.

Convert FLV to MP4 with ffmpeg Howto

Posted At : December 29, 2010 5:13 AM 5 Comments

I recently needed to convert a lot of FLV files which were H264 encoded to MP4 so that they would play nice on my Mac Mini.

Initial attempts using ffmpeg were making it re-encode the entire video which would take ages and result in a larger file or worse quality.

A bit of googling and reading the man pages later I discovered

-vcodec copy -acodec copy

This tells ffmpeg to copy the video and audio without re-encoding.

So insted of this

ffmpeg -i input.flv output.mp4

The Solution

ffmpeg -i input.flv -vcodec copy -acodec copy output.mp4

Further complications

This worked a treat for all except one file - which gave the following error.

[NULL @ 0x9b6b9f0]error, non monotone timestamps 37464141 >= 37463126
av_interleaved_write_frame(): Error while opening file

By using the "-an" and "-vn" flags to skip the video and audio encoding in turn I narrowed it down to a problem in the audio codec timestream.

To try to get ffmpeg to fix the problem I got it to reencode the audio but copy the video codec with the following:

ffmpeg -i input.flv -vcodec copy -acodec mp2 -ar 44100 -ab 128k output.mp4

Worked a treat. I love ffmpeg :-)

Update

As usually happens, by the time I finished writing the post I spotted another enhancement - using the libfaac codec (I had been trying to use it as aac which was failing).

Final code to fix it using aac with audio quality quite high 200 (range is 0-255)

ffmpeg -i input.flv -vcodec copy -acodec libfaac -aq 200 output.mp4

Learnosity are looking for Junior to Mid level Web Application Developers x2

Posted At : October 20, 2010 4:36 AM

Learnosity develop cutting edge tools for teachers and educators. Our flagship product Learnosity Voice uses the telephone to enable language students and teachers to interact on a one to one level. Our service:
  • Makes it practical for students to practice Oral and Aural skills
  • Is efficient and effective for teachers, as they can listen to each student individually at a time to suit them
  • Can be used for homework assignments or “High Stakes Assessments”

Learnosity are creating the next generation of language and assessment technology for use in schools and education worldwide. The current product portfolio includes:

  • High availability web based systems
  • Cross platform software (Windows, Mac and Linux)
  • iPhone/Android native applications
  • Telephony/VOIP and SMS applications

We need someone who can:

  • Use Javascript or Actionscript to create great user interfaces
  • Develop highly scalable web applications using ColdFusion, PHP or similar
  • Cut code with the best in the world

You will also need to be:

  • keen to continue learning new technologies
  • able to have a conversation with non technical people
  • enthusiastic and ready to push the boundaries

You'll need:

  • 1-3 years of programming experience
  • Experience in at least one Client side language (Actionscript or Javascript/jQuery)
  • Experience in at least one Server side language (eg PHP, Java, ColdFusion, etc)
  • Understanding of Object Oriented design
  • Understanding of XHTML and CSS

It would be good if you have:

  • A degree in Computer Science, Engineering or similar.
  • been working with open source tools
  • Experience with Adobe AIR or Flex
  • been playing around with iPhone/Android applications
  • experience with some of Linux/VOIP/SIP/Asterisk/Jabber/XMPP

This is a full time role and you will be working in a casual workplace with flexible hours in the Sydney CBD. Salary commensurate with experience.

If this sounds like the job for you, email a covering letter explaining why you'll be great and your resume to mark@learnosity.com - no agencies please.

HOWTO find files that are not world readable

Posted At : May 18, 2009 11:47 AM

I ran across some permissions errors on content that some users uploaded to a website. The files uploaded were not world readable so were coming up as forbidden:

This simple find command shows the offending files:

/usr/bin/find . -type f ! -perm -004

A quickie but a goodie.

Cheers, Mark

Installing Railo on Tomcat via Apache on Leopard - Step by Step

Posted At : March 27, 2009 3:45 AM 8 Comments

After a bit of fiddling and head scratching I managed to install Railo on Tomcat via Apache on my laptop running on OS X 10.5.6.

Tomcat

Firstly, download Tomcat 6

extract content:

tar xvzf apache-tomcat-6.0.18.tar.gz

Move Tomcat to a more secure place:

sudo mv apache-tomcat-6.0.18 /usr/local/tomcat

Railo

Download Railo custom version

extract and move into Tomcat lib directory:

tar zxvf railo-3.0.2.001-jars.tar.gz
sudo mv railo-3.0.2.001-jars/* /usr/local/tomcat/lib

Make Tomcat and Railo work together by modifying the web config file:

sudo nano /usr/local/tomcat/conf/web.xml

add the following inside the <web-app> element:

<servlet>
<servlet-name>CFMLServlet</servlet-name>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Configuraton directory</description>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>

add the following inside <welcome-file-list> element:

<welcome-file>index.cfm</welcome-file>
<welcome-file>index.cfml</welcome-file>

Apache

Leopard OS comes with Apache 2, so you don't have to worry about installing it. However, you need to download The Apache Tomcat Connector source code.

Next you need to compile the source so that the resulting binary file is compatible with your Intel Mac architecture. I got this from Eric Rank's blog

cd into tomcat source:

cd tomcat-connectors-1.2.27-src/native

Edit the apache-2.0/Makefile.apxs.in file.

Replace

mod_jk.la:
$(APXS) -c -o $@ -Wc,"${APXSCFLAGS} ${JK_INCL}" "${JAVA_INCL}" "${APXSLDFLAGS}" mod_jk.c ${APACHE_OBJECTS}

with:

mod_jk.la:
$(APXS) -c -o $@ -Wc,"${APXSCFLAGS} -arch x86_64 ${JK_INCL}" "${JAVA_INCL}" "${APXSLDFLAGS} -arch x86_64 " mod_jk.c ${APACHE_OBJECTS}

configure the build files:

./configure --with-apxs=/usr/sbin/apxs

now go into apache-2.0 directory and build:

cd apache-2.0
make -f Makefile.apxs

Finally install

sudo make install

Now specify the connection between Apache and Tomcat. To do this you need to create workers.properties file. I created mine in /etc/apache2.

sudo nano /etc/apache2/workers.properties

Paste the following:

worker.list=default

worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

Now we need to modify the Apache httpd.conf file:

sudo nano /etc/apache2/httpd.conf

Enable The Apache Tomcat Connector:

LoadModule jk_module libexec/apache2/mod_jk.so

Underneath that tell Apache where your workers.properties file is located and add some logging info (could be useful):

# Mod_jk settings
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
DirectoryIndex index.html index.htm index.cfm index.cfml

Back to Tomcat

To test our Railo installation, let's create a test site by adding a new virtual host in both Tomcat and Apache. We do this by modifying Tomcat server.xml file (/usr/local/tomcat/conf/server.xml )
<Host name="railo.local" appBase="webapps">
<Context path="" docBase="/Library/Webserver/Documents"/>
</Host>

Apache

Now we need to create a virtual host entry in Apache as well:
<VirtualHost *:80>
JkMount /*.cfm default
ServerName railo.local
DirectoryIndex index.cfm
</VirtualHost>

JkMount /*.cfm default
Tells mod_jk to use the connector specified in your workers.properties file when it encounters a .cfm extension.

Important

Notice that in my Apache VirtualHost entry there is no DocumentRoot. I originally had it in there and it was breaking my Apache-Tomcat connection. It was driving me mad. It's probably because document root is already specified in /usr/local/tomcat/conf/server.xml.

One last thing, to start your Tomcat server type in this command:

/usr/local/tomcat/bin/startup.sh

shut down

/usr/local/tomcat/bin/shutdown.sh

My assumption is that the above steps would be very similar on other operating systems as long as you use the correct file paths.

Good luck :-)

Marko

Loading MySQL timezone info on Linux and Macs

Posted At : September 8, 2008 3:30 AM

MySQL has some really useful functions that make timezone support a bit easier as described in a previous blog post..

However, you need to do a tiny bit of setup work before you can use the functions. You need to load the timezone info from your system into the mysql db.

Thankfully, the MySQL Developers have included a very handy script that will do just that from a zoneinfo files which are used on Linux and on Mac's.

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

Obviously change the mysql params or add a -p if you have a password or are connecting to a remote server.

Check out the MySQL developer site for full details on MySQL timezone support

Cheers, Mark

Convert Mac Line endings to Linux

Posted At : June 22, 2008 10:13 PM

I was cleaning up some source code yesterday and wanted to print it all out, however the Mac line endings (we use Mac's and Ubuntu mostly) were messing up the printout on my Ubuntu machine.

A quick google later and I found the solution, a program called 'tr', posting here for next time:

tr "\r" "\n" < filewithmaclineendings.txt > filewithunixlineendings.txt

Obviously you could convert from Unix to Mac by reversing it.

tr "\n" "\r" < filewithunixlineendings.txt > filewithmaclineendings.txt

Cheers, Mark

DVD to iPod conversion - Linux, Mac & Windows

Posted At : May 16, 2008 3:21 PM 4 Comments

I've been looking for a while for a way to convert DVD's and other movies that I have into iPod format and have been failing miserably. That is until today, when I came across the unusually named HandBrake.

It does exactly what is says on the tin and makes it very easy to copy dvd's. Initially I used it from my Mac and it worked flawlessly.

I also tried the Linux version on Ubuntu Hardy (8.04) which has no GUI but it is pretty simple when you get the hang of it.

Here's a typical command line:

HandBrakeCLI --preset="iPod Low-Rez" -i /media/cdrom -o myvideo.mp4 -t 2

This reads from /dev/cdrom and uses the handy "iPod Low-Rez" preset which fixes it all up nicely for the iPod.

And here's one that takes the second title:

HandBrakeCLI --preset="iPod Low-Rez" -i /media/cdrom -o myvideo.mp4 -t 2

The wiki has more information on command line usage.

Happy iPodding.

Cheers, Mark

Gmail, Docs, Calendar and Analytics standalone with Prism

Posted At : March 24, 2008 8:32 PM

I came across Mozilla Prism the other day and while I'm still deciding if it's going to be a permanent addition to my machine so far so good.

Screenshot of Prism Gmail Prism is a cut down version of Mozilla which is designed to run single sites from icon - what's the use of that you may ask? Well it allows you to have an icon on your desktop for Gmail or Google Calendar or docs or analytics and get to it nice and quickly.

It also free's up some much needed screen real-estate as all the other toolbars relevant for a web-developers browser can get in the way and are not used when you are using you email and calendar.

Additionally - as web developer I tend to restart firefox more often than some - and having my email seperated from that is nice.

Give it a try and see if you like it. On Ubuntu Hardy you can do the following to install it:

#install calendar
sudo apt-get install prism-google-calendar
#install google docs
sudo apt-get install prism-google-docs
#install gmail
sudo apt-get install prism-google-mail
#install analytics
sudo apt-get install prism-google-analytics

On other platforms (windows,mac or other linux versions) you can go to the Prism site and download it.

For the different applications check out the Bundles section or the User contributed bundles section.

Obviously this shares a lot of similarities with the adobe AIR platform albeit not as full featured. It will be interesting to see what further development plans there are for the prism platform.

Cheers, Mark