summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks
diff options
context:
space:
mode:
authorrk2663@student.uni-lj.si <rk2663@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-03-11 21:52:58 +0000
committerrk2663@student.uni-lj.si <rk2663@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-03-11 21:52:58 +0000
commitdd9bc626dcb1af109fa12960de70a3ef53aef323 (patch)
tree820d260100d3edaa4f2e94228a68dcf40d202897 /kpov_judge/tasks
parent3a792f58f6406bedc510b4b1a100e0705dabf8b6 (diff)
Koncan video.py
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@287 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r--kpov_judge/tasks/nat_vlc/video.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/kpov_judge/tasks/nat_vlc/video.py b/kpov_judge/tasks/nat_vlc/video.py
index bdcd51a..7593d43 100644
--- a/kpov_judge/tasks/nat_vlc/video.py
+++ b/kpov_judge/tasks/nat_vlc/video.py
@@ -1 +1,37 @@
import string, random, os
+#You need to find PIL library on the internet. Just GOOGLE it!!! Other imports are standard.
+from PIL import Image, ImageDraw, ImageFont
+
+#Method for generating random string
+def randomString():
+ return ''.join(random.choice(string.lowercase) for i in range(30))
+
+
+image = Image.new("RGBA", (600,150), (255,255,255))
+draw = ImageDraw.Draw(image)
+
+#Font option is optional. If you don't want to use it figure out how to increase font size, because default is veeeeery small.
+
+font = ImageFont.truetype("georgia.ttf", 36)
+txt = randomString()
+
+draw.text((20,50), txt, (20,100,0), font)
+img_resized = image.resize((600,80), Image.ANTIALIAS)
+img_resized.save("out.png")
+
+#Creates .mp4 video from image out.png. Video is 1 second long.
+bashCommand = "avconv -r 1/5 -i out.png -b:v 1000k video.mp4"
+os.system(bashCommand)
+
+# Converts .mp4 video to .avi format. Still 1 second long. ( 2x )
+bashCommand = "avconv -i video.mp4 -c:a copy video.avi"
+os.system(bashCommand)
+
+bashCommand = "avconv -i video.mp4 -c:a copy video1.avi"
+os.system(bashCommand)
+
+# This loop will increas videos length by adding more picesec of the original video.
+last = input("Set video length in seconds: ")
+bashCommand = "avconv -i concat:video.avi\|video1.avi -c copy video.avi"
+for i in range(0, last-2):
+ os.system(bashCommand)