Skip to content

Instantly share code, notes, and snippets.

@soldair
Created April 23, 2010 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soldair/376761 to your computer and use it in GitHub Desktop.
Save soldair/376761 to your computer and use it in GitHub Desktop.
#!/bin/sh
#rotate android 3gp video and transcode to mp4
# mit / gpl and all that
# copyright 2010 ryan day, ryanday.org
#
#NOTE: OGG CONVERSION IS FAILING FOR SOME REASON
#
#PURPOSE:
# to rotate and transcode a 3gp/h.263 video, amr audio to mp4/h.264 , mp3 audio
# to take the mp4 and make a compatable
# the resulting mp4 is html5 video compatable (webkit)
# the resulting ogg is a firefox/opera compatible ogg video
#
# you can use these file in any web page and they will be playable from modern browsers
#
# <video controls>
# <source src=/video/example.ogg type=video/ogg>
# <source src=/video/example.mp4 type=video/mp4>
# your browser doesnt support the video tag =(
# </video>
#
# g1 android video is 352x288 10fps
#
# 3gp to mpg with mp3 audio
# why mpeg? i had issues with mencoder where the framerate would be improperly detected even though its specified and the rotated video would play too fast
ffmpeg -i $1 -acodec libmp3lame -ar 44100 tmp-kjhdjkhajkhAFklahfkhdsljkjlk.mpg
#mpeg to mpeg 4 rotated
mencoder -vf rotate=1 -o $2 -oac copy -ovc lavc -ofps 10 tmp-kjhdjkhajkhAFklahfkhdsljkjlk.mpg
#strip ext
#ogg=`echo "$2" | sed 's/\(.*\)\..*/\1/'`
#make ogg also
#some people prefer the ogv extenstion for ogg/theora video but i find that apache will by default serve .ogg files with appropriate headers
#without requiring extra addtype declarations
#ffmpeg -i $2 -acodec vorbis -ar 44100 $ogg.ogg
# remove tmp mpeg
rm tmp-kjhdjkhajkhAFklahfkhdsljkjlk.mpg
#also helpful - get video info from ffmpeg
#ffmpeg -i filename.flv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment