Linux, politics, and other interesting things
deb http://www.coker.com.au lenny selinux-mm
Firstly I installed the version of ffmpeg that comes from the Debian-Multimedia repository . Then I spent about an hour getting it to build with some patches to not require text relocations. The change involves putting --disable-mmx in the CONFIG_OPT setting for i386 and patching rgb2rgb.c to not compile MMX code. I’ve put the packages in the above APT repository.
My first attempt was to produce AVI files similar to the ones that my Viewty makes when it saves a video. ffmpeg -i file.avi displays the file details, which includes mpeg4 video and mp3 audio. By default ffmpeg creates AVI files that use mp2 audio and my phone doesn’t like them. I tried using “-acodec libmp3lame” which gave a file that (according to ffmpeg) had the same encoding as files produced by my phone, but my phone didn’t accept them. I eventually gave up and used mpeg4 which worked without any problem. I never had a reason to desire AVI files, it just seemed likely that the easiest format would be the one that the phone uses to encode the videos it creates – obviously a bad assumption.
Just use MPEG4 for a Viewty phone!
One of the videos I tried causes various parts of the phone to crash. It would crash the preview screen (which shows icons of the videos), and crash the player after playing for a couple of seconds. Crashing the player caused a soft-boot of the phone (it restarted and asked for my PIN code). I expect that anyone who was suitably motivated could create a hostile mpeg4 file that can exploit a Viewty.
The next problem I had was that most videos had a blank icon for the preview. It seems that the Viewty uses the first frame as the icon which doesn’t work well for videos that fade in, as such videos comprise a large portion of my collection that is a problem. The solution to this problem is to take 100ms of video from later on in the flv file and prepend it to the start. The ffmpeg FAQ has some information on how to do this , it involves converting the data to a format that can be concatenated and then converting it back. It’s rather ugly, it would be good if someone added a feature to ffmpeg to support multiple -i options.
I used the below Makefile to convert all the flvs in my collection to mp4 format in a subdirectory named “mp4“. I used a Makefile for this so that I can just run “make” whenever I add more flvs to my collection, and “make -j2” to use both cores of my Opteron CPU. It takes 0.1 seconds of data from 20 seconds in the video and appends the entire video to that. It creates two pipes for the temporary data which tends to be about 30* larger than the source flv file.
MP4S:=$(shell for n in *.flv ; do echo $$n | sed -e s/^/mp4\\// -e s/flv$$/mp4/ ; done)
mkfifo $@.aud $@.vid
sh -c "(ffmpeg -ss 20 -t 0.1 -i $< -vn -f u16le -acodec pcm_s16le -ac 2 -ar 22050 – ; ffmpeg -i $< -vn -f u16le -acodec pcm_s16le -ac 2 -ar 22050 – ) > $@.aud &"
sh -c "(ffmpeg -ss 20 -t 0.1 -i $< -an -f yuv4mpegpipe – ; ffmpeg -i $< -an -f yuv4mpegpipe – ) > $@.vid &"
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 22050 -i $@.aud -f yuv4mpegpipe -i $@.vid -y $@
rm $@.aud $@.vid