#!/bin/sh

test $# -ne 1 && echo "usage: gstreamer-ogg-vs-avi.sh 30" && exit

length=$1
AVIGST="gst-launch-0.10 v4l2src ! \
	video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! \
       	queue ! tee name=videoout ! queue ! videorate ! jpegenc ! \
       	muxout. alsasrc ! audio/x-raw-int,rate=22000,channels=1,width=16 ! \
       	queue ! muxout. avimux name=muxout ! \
	filesink location=video.avi videoout. ! queue ! ffmpegcolorspace ! \
       	ximagesink"

OGGGST="gst-launch-0.10 v4l2src ! \
	video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! \
       	queue ! tee name=videoout ! queue ! videorate ! theoraenc keyframe-force=1 ! \
       	queue ! \
	muxout. alsasrc ! audio/x-raw-int,rate=22000,channels=1,width=16 ! \
	queue ! audioconvert ! vorbisenc ! queue ! \
       	muxout. oggmux name=muxout max-delay=10000000 ! filesink location=video.ogg videoout. ! \
	queue ! ffmpegcolorspace ! ximagesink"

WEBMGST="gst-launch-0.10 v4l2src ! \
	video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! \
       	queue ! tee name=videoout ! queue ! videorate ! vp8enc ! \
       	queue ! \
	muxout. alsasrc ! audio/x-raw-int,rate=22000,channels=1,width=16 ! \
	queue ! audioconvert ! vorbisenc ! queue ! \
       	muxout. webmmux name=muxout ! filesink location=video.webm videoout. ! \
	queue ! ffmpegcolorspace ! ximagesink"


$OGGGST &
sleep $length
kill $!

$AVIGST &
sleep $length
kill $!

$WEBMGST &
sleep $length
kill $!

du -h video.avi
du -h video.ogg
du -h video.webm
