From 58ddf33002806eb979e128be45b0e849dbb138f4 Mon Sep 17 00:00:00 2001
From: Greg Frost <gregfrost1@bigpond.com>
Date: Sat, 24 Apr 2010 14:37:25 +0930
Subject: test-pattern: add bitrate support

---
 abs/core-testing/test-pattern/PKGBUILD          |  2 +-
 abs/core-testing/test-pattern/test_pattern.bash | 24 +++++++++++++++++++-----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/abs/core-testing/test-pattern/PKGBUILD b/abs/core-testing/test-pattern/PKGBUILD
index db15a0d..cf7b2f1 100644
--- a/abs/core-testing/test-pattern/PKGBUILD
+++ b/abs/core-testing/test-pattern/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=test-pattern
 pkgver=1.0
-pkgrel=4
+pkgrel=5
 arch=('i686')
 pkgdesc="script to create test pattern videos"
 depends=(imagemagick)
diff --git a/abs/core-testing/test-pattern/test_pattern.bash b/abs/core-testing/test-pattern/test_pattern.bash
index a68249a..76db158 100755
--- a/abs/core-testing/test-pattern/test_pattern.bash
+++ b/abs/core-testing/test-pattern/test_pattern.bash
@@ -9,8 +9,9 @@ TEMPDIR=
 unset remove_tempdir
 interlaced=
 aspect_ratio=
+bitrate=
 
-while getopts ":w:h:t:r:ia:" opt; do
+while getopts ":w:h:t:r:ia:b:" opt; do
   case $opt in
     w)
       w=$OPTARG
@@ -30,8 +31,11 @@ while getopts ":w:h:t:r:ia:" opt; do
     a)
       aspect_ratio=$OPTARG
       ;;
+    b)
+      bitrate=$OPTARG
+      ;;
     \?)
-      echo -n"\
+      echo -n "\
 Error: Invalid option -$OPTARG
 
 Usage:
@@ -42,11 +46,16 @@ Usage:
         The height in pixels.
     -t tempdir
 	Temporary directory for intermediate files. If no directory is specified, one is created and deleted at the end of processing.
-    -r framerate
+    -r fieldrate
     -i
 	Generate an interlaced test pattern
     -a n:m
 	Aspect ratio of generated video.
+    -b bitrate
+	Bitrate used for encoding.
+
+Example:
+test_pattern.bash -w 1440 -h 1080 -t temp -r 50 -i -a 16:9 -b 12000k
 "
       exit 1
   esac
@@ -297,12 +306,17 @@ for ((i=0; i < $frames; i++)) ; do
   fi
 done
 
+bitrate_flags=
+if [ -n "$bitrate" ] ; then
+  bitrate_flags="-b $bitrate"
+fi
+
 if [ -n "$interlaced" ] ; then
   ffmpeg -r ${rate} -i ${TEMPDIR}/interlaced%03d.png -r ${rate} \
-    -vcodec mpeg2video -flags +ilme+ildct -y test.mpg
+    -vcodec mpeg2video -flags +ilme+ildct ${bitrate_flags} -y test.mpg
 else
   ffmpeg -r ${rate} -i ${TEMPDIR}/test%03d.png -r ${rate} \
-    -vcodec mpeg2video -aspect $aspect_ratio -y test.mpg
+    -vcodec mpeg2video -aspect $aspect_ratio ${bitrate_flags} -y test.mpg
 fi
 
 if [ -n "$remove_tempdir" ] ; then
-- 
cgit v0.12