James Crook, web geek ++

Video conversion: ogv to mp4

31 Aug 2011

HandBrake software screenshot

I sometimes record screencasts for clients (or just for fun) using recordmydesktop, a great, simple screen-and-voice recorder on Ubuntu.

It captures the screen and audio for a selected area and outputs it to an .ogv file. This file views fine on my own computer, but Windows users and others often have trouble with it, and it's also quite a large file size by default.

So I often convert my screencasts to .mp4 format and then put them on screencast.com. Screencast.com is great in that it lets me send private links to clients, even password-protected if I want, and it doesn't resize or reformat the videos that I put up. Screencast.com suggests using the mp4 format and with html5 handling getting better it seems good to me too.

Mencoder

I've always been a fan of mencoder for converting video. I used to convert the recordmydesktop .ogv files to .avi files using this script:

nice mencoder inputfile.ogv -ovc xvid -vf harddup -xvidencopts bitrate=800 -oac mp3lame -lameopts abr:br=92 -channels 1 -o outputfile.avi

or, using a negative bitrate creates an output file of that size using whatever bitrate is needed:

nice mencoder inputfile.ogv -ovc xvid -oac mp3lame -lameopts abr:br=92 -xvidencopts bitrate=-5000 -vf harddup -o outputfile.avi

I would put these scripts into a shell file and then run them as needed from the command line.

However, recently mencoder has had problems for me. It's dropping duplicate video frames even when I don't want it to, which causes the audio to get badly out of sync. It also doesn't seem to handle mp4 output formats well.

So I've been looking around for an alternative.

Handbrake

Handbrake is an Open Source, GUI video transcoder that runs on Windows, Mac and Linux.

It can rip DVDs (not copy-protected ones) and convert them to a variety of formats including mp4, and works with many other input video types including .ogv - so recordmydesktop screencasts are (theoretically) easy to handle.

To get it on Ubuntu you'll need to add the PPA.

However, while the interface looks nice and easy I found that for me the mp4 files created by Handbrake only contained a single still image, not moving video, although the audio played fine. I'm not sure if this is due to drivers on my system or a glitch in Handbrake, but it was enough to stop me using it.

Ffmpeg

Ffmpeg is another command-line tool.

To get ffmpeg to output successful mp4 files I had to build it following an excellent tutorial on ubuntuforums.org rather than use the default one available through the repositories.

Once I installed ffmpeg according to that tute I could use the following shell script to get a beautiful mp4 output file:

#!/bin/bash
# ogv to mp4

# 1-pass CRF encoding using ffmpeg
# Adjust -crf to change the quality. Lower numbers mean higher quality and a larger output file size. A sane range is 18 to 28.

ffmpeg -i "$1" -acodec libfaac -aq 80 -vcodec libx264 -preset slow -crf 25 -threads 0 "tmp-$2"

# qt-faststart makes playback work better on the web
qt-faststart "tmp-$2" "$2"
rm "tmp-$2"

If you copy and paste that into 'ogv2mp4.sh' you can run it with ./bin/ogv2mp4.sh inputfile.ogv outputfile.mp4

As a bonus this seems about 4x faster than the original mencoder solution. Nice.

Categories: 

Comments

31 Oct 2011

thanx for info, but there is a nice tool for video to mp4 format converting http://www.macvide.com/Macvide_iPod_Converter/, i usually use and enjoy it!)

29 Nov 2013

Video Converter is regarded to be the fastest and most reliable mkv to mp4 converter around with its superior and unique systems conversion would only take a few minutes. <a href="http://magnoconag.com/">asus laptops india price</a>

16 Dec 2011

That's perfect! Resolved all my issues with ogv from Desktop Recorder.

15 Apr 2012

Great help that ffmpeg script! I was having massive dropped frames when mixing *.ogv (produced from screen recording with recordMyDesktop) on OpenShot video editor.
Now I convert the *.ogv to *.mp4 and the mixing goes on flawlessly.
Thanks once again!

15 Mar 2013

The above ffmpeg script is a little hard and complicated to me. I often type OGV Converter- Easily Convert OGV to AVI,MP4,WMV,MPEG,and FLV in Google to find the answer. If you want to get a quick solution, hope this can be helpful:
http://www.bigasoft.com/articles/ogv-converter-convert-ogv-to-avi-mp4-wm...

17 Aug 2013

<script> alert(owned)</script>

06 Oct 2013

Super cool and interesting post! You really got my brain goin on that one! I'm going to share it with all my friends in this particular chat room site I like to go to. The site is cool if you're wondering. It's super duper fun and cool just like your magnificient post. http://adult4sexchat.com

18 Apr 2014

I think ffmpeg to most people is just like Greek to them. Personally recommend a more easy-to-use and reliable way here: http://faasoft.com/articles/ogv-converter.html

Add new comment