Created
June 16, 2015 02:37
-
-
Save ph1ee/5c736bb98698b19f23ff to your computer and use it in GitHub Desktop.
Record various H264 video clips with different settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
die() { | |
cat << EOF | |
usage: $(basename $0) secs [timezone] | |
30m = 1800s 1h = 3600s 4h = 14400s 7h = 25200s | |
90m = 5400s 2h = 7200s 5h = 18800s 8h = 28800s | |
120m = 7200s 3h = 10800s 6h = 21600s 9h = 32400s | |
10h = 36000s | |
EOF | |
exit 1 | |
} | |
random() { | |
r=$(($(dd if=/dev/urandom bs=4 count=1 2>/dev/null | cksum | cut -d' ' -f1) % 32768)) | |
r=${r#-} # convert to absolute value | |
echo $(($r % $1)) | |
} | |
pick_sign() { | |
case "$1" in | |
0) echo -;; | |
1) echo +;; | |
*) die;; | |
esac | |
} | |
pick_hour() { | |
case "$1" in | |
0) echo 00;; | |
1) echo 01;; | |
2) echo 02;; | |
3) echo 03;; | |
4) echo 04;; | |
5) echo 05;; | |
6) echo 06;; | |
7) echo 07;; | |
8) echo 08;; | |
9) echo 09;; | |
10) echo 10;; | |
11) echo 11;; | |
12) echo 12;; | |
13) echo 13;; | |
14) echo 14;; | |
*) die;; | |
esac | |
} | |
pick_min() { | |
case "$1" in | |
0) echo 00;; | |
1) echo 15;; | |
2) echo 30;; | |
3) echo 45;; | |
*) die;; | |
esac | |
} | |
test -n "$1" || die | |
test -n "$2" && (while kill -0 $$ | |
do | |
tz=GMT$(pick_sign $(random 2))$(pick_hour $(random 15))$(pick_min $(random 4)) | |
sleep 360 | |
echo change timezone to $tz | |
echo $tz > /etc/TZ | |
done) 2>/dev/null & | |
while read idx sz bps h264fps fps | |
do | |
${DO} ./timelimit -q -s INT -t $1 ffmpeg \ | |
-v verbose -nostdin -y \ | |
-f video4linux2 -input_format h264 \ | |
-video_size $sz \ | |
-framerate $h264fps \ | |
-bitrate $bps \ | |
-i /dev/video0 \ | |
-f alsa -i capture \ | |
-acodec pcm_s16le \ | |
-vcodec copy \ | |
-af 'pan=mono\|c0=FL' \ | |
-map 0 -map 1 \ | |
-r $fps -f segment \ | |
-segment_time 720 \ | |
-reset_timestamps 1 \ | |
-segment_format avi \ | |
${idx}_%3d_%F_%T.avi | |
done << EOF | |
720p 1280x720 1500000 24 30 | |
480p 854x480 500000 24 30 | |
360p 640x360 400000 24 30 | |
240p 426x240 300000 24 30 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment