Permalink
Browse files

Developing a command-line tool to automatically extract images from a…

… video file (mp4) and comparing them to keep significant ones (work in progress)
  • Loading branch information...
1 parent 51247eb commit 589123e70b52d9f8bf45bfd7539ddfced1fe812e @metadirective metadirective committed Apr 28, 2014
Showing with 51 additions and 2 deletions.
  1. +49 −0 videoFileAnalyser.py
  2. +2 −2 win-installer/installeur.iss
View
@@ -0,0 +1,49 @@
+###############################################################################
+#
+# videoFileAnalyser (c) Univesity of Strasbourg
+# Developper: F. Schnell
+#
+# A command-line tool to automatically extract images from a video file (mp4),
+# comparing them to keep significant ones
+#
+###############################################################################
+
+
+import subprocess, os
+import ImageChops, Image
+import math
+
+print "> videoFileAnalyser started..."
+
+def rmsdiff(im1, im2):
+ """Calculate the root-mean-square difference between two images
+ source : http://code.activestate.com/recipes/577630-comparing-two-images/"""
+ diff = ImageChops.difference(im1, im2)
+ h = diff.histogram()
+ sq = (value*(idx**2) for idx, value in enumerate(h))
+ sum_of_squares = sum(sq)
+ rms = math.sqrt(sum_of_squares/float(im1.size[0] * im1.size[1]))
+ return rms
+
+if 1:
+ print "> extracting images from video..."
+ p= subprocess.Popen(["ffmpeg","-i","enregistrement-video.mp4","-r","0.1","-f","image2","tests/%05d.jpg"])
+ p.communicate() #waiting for ffmpeg to finish before continuing script
+
+if 0: # Test
+ print "> comparing pictures..."
+ im1=Image.open("tests/1.jpg")
+ im2=Image.open("tests/7.jpg")
+ print rmsdiff(im1,im2)
+
+if 1:
+ print "to do :"
+ print "begin with first picture and make a copy D1.jpg"
+ print "go through pic, if rms difference > threshold create n.jpg"
+ print "remove others pics when finished"
+
+ for fileName in (os.listdir("tests")):
+ if fileName != "00001.jpg":
+ print fileName
+ #currentRms =
+
@@ -6,8 +6,8 @@
[Setup]
AppName=audiovideocast
AppId=audiovideocast
-AppVerName=audiovideocast 2.3
-AppVersion=2.3
+AppVerName=audiovideocast 2.4
+AppVersion=2.4
AppPublisher=(C) University of Strasbourg 2006-2014
AppPublisherURL=http://www.unistra.fr
AppSupportURL=http://www.unistra.fr

0 comments on commit 589123e

Please sign in to comment.