Creating stream-able video
I spent much to much time trying to figure out the right combination of video/audio encodings that would would from an RTSP streaming server (went with a RealServer demo, for now) to a variety of clients (QuickTime Player, VLC, various phones, etceteras.)
First, VLC is a champ. Every time I tried a new streaming server, VLC could play the stream with video and audio. QuickTime Player was not so kind. Even the phone we were streaming to — the Nokia N95 (tech specs) — could play streams that QuickTime Player could not.
I tried a variety of tools, from the venerable ffmpeg to QuickTime Player’s export functionality to create stream-able videos (mainly for QuickTime, since it was being very picky). The tools I used were the following:
- ffmpeg from FFMPEG project
- faac from AudioCoding
- mp4creator from MPEG4IP
Here is a simple bash loop I made to iterate over .mov’s in the current directory and create MPEG4 video, MPEG4 audio (AAC LC), in an MPEG4 container that was hinted. You should set FRAMERATE and SIZE (as “WxH”) as environment variables. Note that the first line has -ac 1 which sets the audio to mono. Also, edit the -qscale to your liking (or remove it).
-
for i in `ls *mov –color=never`; do
-
ffmpeg -i $i -ac 1 -vn "$i.wav"
-
faac –mpeg-vers 4 –tns -o "$i.aac" "$i.wav"
-
ffmpeg -re -i "$i" -pass 1 -passlogfile "${i}pass" -vcodec mpeg4 -r $FRAMERATE -s $SIZE -qscale 8 -an "$i.m4v"
-
rm -f "$i.m4v"
-
ffmpeg -re -i "$i" -pass 2 -passlogfile "${i}pass" -vcodec mpeg4 -r $FRAMERATE -s $SIZE -qscale 8 -an "$i.m4v"
-
mp4creator -c "$i.m4v" -optimize -rate=$FRAMERATE "$i.mp4"
-
mp4creator -hint=1 "$i.mp4"
-
mp4creator -c "$i.aac" -interleave -optimize "$i.mp4"
-
mp4creator -hint=3 "$i.mp4"
-
mp4creator -list "$i.mp4"
-
done