summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/check_diskspace20
-rw-r--r--tools/image2video49
-rw-r--r--tools/image_logo24
-rw-r--r--tools/image_text48
-rw-r--r--tools/intro-outro125
-rw-r--r--tools/require14
-rw-r--r--tools/takk_til13
-rw-r--r--tools/video_aspect_ratio28
-rw-r--r--tools/video_fps14
-rw-r--r--tools/video_resolution14
-rw-r--r--tools/video_standard32
11 files changed, 368 insertions, 13 deletions
diff --git a/tools/check_diskspace b/tools/check_diskspace
new file mode 100644
index 0000000..7b7031c
--- /dev/null
+++ b/tools/check_diskspace
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Check for free space needed to work with video-file
+
+DISK=`df \`pwd\` | tail -1 | awk '{print $4}'`
+FILE=`du $1 | awk '{print $1}'`
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <file>"
+ exit 1
+fi
+
+if [ $DISK -le $FILE ]; then
+ echo "Error: Not enough disk space to continue! Aborting."
+ exit 1
+fi
diff --git a/tools/image2video b/tools/image2video
new file mode 100644
index 0000000..23ca123
--- /dev/null
+++ b/tools/image2video
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Converts images* into video
+
+EXT=`echo "$1"|awk -F . '{print $NF}'`
+NAME=`basename $1 .$EXT`
+WIDESCREEN=`./video_aspect_ratio $1`
+FRAMES=`./video_fps $1`
+ENDNAME=$2
+NTSC=`./video_standard $1`
+
+# smilutils
+./require image2raw
+
+if [ -z "$2" ]; then
+ echo "Usage: $0 <video-file> <end-name>"
+ exit 1
+fi
+
+if [ ! -f $1 ]; then
+ echo "File $1 does not exists"
+ exit 1
+fi
+
+if [ $EXT == "dv" ] ; then
+ if [ "$WIDESCREEN" == "4:3" ] ; then
+ if [ "$NTSC" == "NTSC" ] ; then
+ image2raw -n -r $FRAMES -a $NAME-*.png > $NAME-$ENDNAME.dv;
+ else
+ image2raw -r $FRAMES -a $NAME-*.png > $NAME-$ENDNAME.dv;
+ fi
+ elif [ "$WIDESCREEN" == "16:9" ] ; then
+ if [ "$NTSC" == "NTSC" ] ; then
+ image2raw -n -w -r $FRAMES -a $NAME-*.png > $NAME-$ENDNAME.dv;
+ else
+ image2raw -w -r $FRAMES -a $NAME-*.png > $NAME-$ENDNAME.dv;
+ fi
+ else
+ echo "Unkown aspect ratio"
+ exit 1
+ fi
+else
+ echo "Video format not supported"
+ exit 1
+fi
diff --git a/tools/image_logo b/tools/image_logo
new file mode 100644
index 0000000..4681e4b
--- /dev/null
+++ b/tools/image_logo
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Make a logo-image
+
+EXT=`echo "$1"|awk -F . '{print $NF}'`
+NAME=`basename $1 .$EXT`
+
+SIZE=`./video_resolution $1`
+COUNTER=$2
+BGCOLOR=$3
+LOGO=$4
+
+if [ -z "$4" ]; then
+ echo "Usage: $0 <video-file> <counter> <bg-color> <logo-file>"
+ exit 1
+fi
+
+convert -size $SIZE xc:$BGCOLOR -append $BGCOLOR.png
+composite -gravity center $LOGO $BGCOLOR.png $NAME-$COUNTER.png
+rm $BGCOLOR.png
diff --git a/tools/image_text b/tools/image_text
new file mode 100644
index 0000000..fa286bd
--- /dev/null
+++ b/tools/image_text
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Make a text-image (intro-outro)
+#
+# todo: sjekk hvor lang teksten er.. skaper problemer hvis blir for
+# lang. Bli kvitt counter.
+
+EXT=`echo "$1"|awk -F . '{print $NF}'`
+NAME=`basename $1 .$EXT`
+
+FONT="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf"
+SIZE=`./video_resolution $1`
+COUNTER=$2
+BGCOLOR=$3
+
+if [ -z "$4" ]; then
+ echo "Usage: $0 <video-file> <counter> <bg-color> <text1> [<text2>]"
+ exit 1
+fi
+
+if [ ! -f $FONT ]; then
+ echo "Font $FONT does not exists"
+ exit 1
+fi
+
+if [ $BGCOLOR == "white" ]; then
+ FGCOLOR="black"
+elif [ $BGCOLOR == "black" ]; then
+ FGCOLOR="white"
+else
+ echo "Only black or white is allowed"
+ exit 1
+fi
+
+if [ $# -gt 4 ]; then
+ convert -font $FONT -size $SIZE xc:$BGCOLOR \
+ -fill $FGCOLOR -gravity center -pointsize 50 -draw "text 0,0 '${4}'" \
+ -fill $FGCOLOR -gravity center -pointsize 30 -draw "text 0,60 '${5}'" \
+ -append $NAME-$COUNTER.png
+else
+ convert -font $FONT -size $SIZE xc:$BGCOLOR \
+ -fill $FGCOLOR -gravity center -pointsize 60 -draw "text 0,0 '${4}'" \
+ -append $NAME-$COUNTER.png
+fi
diff --git a/tools/intro-outro b/tools/intro-outro
new file mode 100644
index 0000000..99682e4
--- /dev/null
+++ b/tools/intro-outro
@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Creates a intro and outro video-file from a csv-file
+#
+# libtext-csv-perl
+# see test.csv
+
+use strict;
+use warnings;
+use Text::CSV;
+
+my $file = 'test.csv';
+my $csv = Text::CSV->new();
+my @takk;
+my @url;
+my $counter = "000";
+
+open (CSV, "<:encoding(utf8)", "$file") or die "$file: $!";
+
+while (<CSV>) {
+ if ($csv->parse($_)) {
+ my @columns = $csv->fields();
+
+ if ($. == 1) {
+ my $index;
+ foreach (@columns) {
+ if ($_ eq "Takk") {
+ push(@takk, $index);
+ }
+ elsif ($_ eq "URL") {
+ push(@url, $index);
+ }
+ $index++;
+ }
+ }
+
+ next if ($. == 1);
+
+ my $filename = $columns[0];
+ my $logo = $columns[1];
+ my $name = $columns[2];
+ my $title = $columns[3];
+ my $what = $columns[4];
+ my $date = $columns[5];
+ my $location = $columns[6];
+ my $license = $columns[7];
+ my $takk = $columns[8];
+
+ print "#$.. Filename: $filename\n";
+
+ print "\tIntro:\n";
+ print "\t\tSlide 1: Logo: $logo\n";
+ print "\t\tSlide 2: Name: $name\n";
+ print "\t\tSlide 2: Title: $title\n";
+ print "\t\tSlide 2: What: $what\n";
+ print "\t\tSlide 2: Date: $date\n";
+ print "\t\tSlide 2: Location: $location\n";
+ print "\t\tSlide 3: License: $license\n";
+
+ system("bash ./image_logo $filename.dv $counter white $logo"); $counter++;
+ system("bash ./image_logo $filename.dv $counter white $logo"); $counter++;
+ system("bash ./image_logo $filename.dv $counter white $logo"); $counter++;
+
+ system("bash ./image_text $filename.dv $counter white '$what' '$date - $location'"); $counter++;
+ system("bash ./image_text $filename.dv $counter white '$what' '$date - $location'"); $counter++;
+ system("bash ./image_text $filename.dv $counter white '$what' '$date - $location'"); $counter++;
+
+ system("bash ./image_text $filename.dv $counter white '$title' '$name'"); $counter++;
+ system("bash ./image_text $filename.dv $counter white '$title' '$name'"); $counter++;
+ system("bash ./image_text $filename.dv $counter white '$title' '$name'"); $counter++;
+
+ system("cp $license.png $filename-$counter.png"); $counter++;
+ system("cp $license.png $filename-$counter.png"); $counter++;
+ system("cp $license.png $filename-$counter.png"); $counter++;
+
+ # .dv buh fix!
+ system("./image2video $filename.dv intro");
+ system("rm $filename-*.png");
+ $counter="000";
+
+ print "\tOutro:\n";
+
+ system("bash ./image_text $filename.dv $counter black 'TAKK TIL'"); $counter++;
+ system("bash ./image_text $filename.dv $counter black 'TAKK TIL'"); $counter++;
+ system("bash ./image_text $filename.dv $counter black 'TAKK TIL'"); $counter++;
+
+ print "\t\tName: $name\n";
+ print "\t\tLocation: $location\n";
+
+ system("bash ./image_text $filename.dv $counter black '$name' Foredragsholder"); $counter++;
+ system("bash ./image_text $filename.dv $counter black '$location' Lokaler"); $counter++;
+
+ foreach (@takk) {
+ my $test = $columns[$_];
+ my @takk = split(/:/, $test);
+ my $hva = $takk[0];
+ my $hvem = $takk[1];
+ # if takk1 ""
+ print "\t\t$hvem - $hva\n";
+ system("bash ./image_text $filename.dv $counter black '$hvem' '$hva'"); $counter++;
+ }
+
+ foreach (@url) {
+ my $lenke = $columns[$_];
+ print "\t\tURL: $lenke\n";
+ system("bash ./image_text $filename.dv $counter black ' '"); $counter++;
+ system("bash ./image_text $filename.dv $counter black '$lenke'"); $counter++;
+ system("bash ./image_text $filename.dv $counter black '$lenke'"); $counter++;
+ }
+
+ # .dv buh fix!
+ system("./image2video $filename.dv outro");
+ system("rm $filename-*.png");
+
+ } else {
+ my $err = $csv->error_input;
+ print "Failed to parse line #$..: $err";
+ }
+}
+
+close CSV;
diff --git a/tools/require b/tools/require
new file mode 100644
index 0000000..ac0a26e
--- /dev/null
+++ b/tools/require
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Check if a program is installed
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <program>"
+ exit 1
+fi
+
+type -P $1 &>/dev/null || { echo "Error: This script require $1, but it's not installed. Aborting." >&2; exit 1; }
diff --git a/tools/takk_til b/tools/takk_til
deleted file mode 100644
index 900e222..0000000
--- a/tools/takk_til
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-FONT="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf"
-
-if [ $# -gt 2 ]; then
- convert -font $FONT -size 1440x1080 xc:black \
- -fill white -gravity center -pointsize 60 -draw "text 0,0 '${1}'" \
- -fill white -gravity center -pointsize 40 -draw "text 0,60 '${2}'" \
- -append ${3}.png
-else
- convert -font $FONT -size 1440x1080 xc:black \
- -fill white -gravity center -pointsize 60 -draw "text 0,0 '${1}'" \
- -append ${2}.png
-fi
diff --git a/tools/video_aspect_ratio b/tools/video_aspect_ratio
new file mode 100644
index 0000000..ac81980
--- /dev/null
+++ b/tools/video_aspect_ratio
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Show the pixel aspect ratio (PAR) for a video-file
+
+EXT=`echo "$1"|awk -F . '{print $NF}'`
+PAR=`ffmpeg -i $1 2>&1 | grep Video | cut -d "," -f 5 | cut -d " " -f 3`
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <video-file>"
+ exit 1
+fi
+
+if [ $EXT == "dv" ] ; then
+ if [ "$PAR" == "59:54" ] ; then
+ echo "4:3"
+ elif [ "$PAR" == "118:81" ] ; then
+ echo "16:9"
+ else
+ echo "Unkown pixel aspect ratio"
+ fi
+else
+ echo "Video format not supported"
+ exit 1
+fi
diff --git a/tools/video_fps b/tools/video_fps
new file mode 100644
index 0000000..635762e
--- /dev/null
+++ b/tools/video_fps
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Show video frame per second
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <video-file>"
+ exit 1
+fi
+
+ffmpeg -i $1 2>&1 | grep Video | cut -d "," -f 6 | cut -d " " -f 2
diff --git a/tools/video_resolution b/tools/video_resolution
new file mode 100644
index 0000000..c7a3ff6
--- /dev/null
+++ b/tools/video_resolution
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Show video resolution (x:y)
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <video-file>"
+ exit 1
+fi
+
+ffmpeg -i $1 2>&1 | grep Video | cut -d "," -f 3 | cut -d " " -f 2
diff --git a/tools/video_standard b/tools/video_standard
new file mode 100644
index 0000000..064641c
--- /dev/null
+++ b/tools/video_standard
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Date: 2009-12-04
+# Author: Ole Kristian Lien
+# License: GNU General Public License
+#
+# Show video standard
+
+EXT=`echo "$1"|awk -F . '{print $NF}'`
+FPS=`./video_fps $1`
+RES=`./video_resolution $1`
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <video-file>"
+ exit 1
+fi
+
+if [ "$FPS" == "25" ] ; then
+ if [ "$RES" == "720x576" ] ; then
+ echo "PAL"
+ else
+ echo "PAL(?)"
+ fi
+elif [ "$FPS" == "30" ] ; then # 29.97 ?
+ if [ "$RES" == "720x480" ] ; then
+ echo "NTCS"
+ else
+ echo "NTCS(?)"
+ fi
+else
+ echo "Unkown video standard"
+fi