Script that converts your avi files into 3gp files
Ever wanted to connect with your mobile phone to motion and download the latest movies? This script makes it possible. It converts every finished movie made by motion into a 3gp video file. Basically any compatible device will be able to view the created files. Phones, PDAs etc.
The script makes use of the onffmpegclose option in motion.conf and converts movies using ffmpeg
from os import system,path,unlink
from sys import argv
outpath="/home/sites/motion/web/3gp" # destination of the converted files
outbps=6 # kbits per second
outfps=6 # frames per second
def to3gp(infile, outfile, bps, fps):
ffmpeg="ffmpeg -i %s -r %d -s qcif -b %d -an -map 0.0 -f 3gp %s </dev/null"
system(ffmpeg % (infile, fps, bps, outfile))
to3gp(infile, outfile, outbps, outfps);
Download script: convert_to_3gp.py
What do you need to install before?
ffmpeg is needed by the script
apache o compatible browser is needed to connect via wap or browser to the specified directory
How do you install the program?
Copy the file to a folder, edit options in the script (file location, quality) and add the command line to 'onffmpegclose' option in motion.conf (something like onffmpegclose /usr/local/bin/convert_to_3gp.py)
To download the file directly with your cell phone, you should add the following code in your apache httpd.conf to allow directory listing.
allow from all
In my case, i also had to add a mime type for 3gp movies in my mime.types configuration of apache. Without it, my movies wouldn't be recognised by my phone.
I think that's all. Have fun!
Thanks go to Gabriel
for writing that little script, and Mike Lees
for making the code even shorter.
This script is stable. No future versions expected. Feel free to edit and improve.
Nokia 6230, 6600
- 03 Apr 2005
As of Motion 3.2.3 the motion.conf syntax is:
As of Motion 3.2.4_snap4 the %f paramater must be added to above command:
on_movie_end /usr/local/bin/convert_to_3gp.py %f
- 05 Nov 2005
I am using motion Version 3.2.7 on Fedora Core 7. When I add the above line to the config file it will only execute the script if i stop the motion service. The same is true if I have motion running in non-deamon mode, I have to -c and stop motion, only then will the script run.
Any Ideas as to why this happens?.
-- JohnPowell - 06 Apr 2008