Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added + removed a couple of files

  • Loading branch information...
commit 32189fead2bf2b924c5bd00a567c162344ad3bf4 1 parent 1f8384f
freder authored
View
2  .gitignore
@@ -1,4 +1,4 @@
-*.bat
+c4d_render.bat
*.pyc
*.jsx
*/
View
2  ffmpeg_crop-vob.bat
@@ -0,0 +1,2 @@
+REM -vf cropdetect
+ffmpeg -i VTS_01_1.VOB -vf crop=720:462:0:57 -target dvd -acodec copy cropped.vob
View
1  ffmpeg_demux-vob.bat
@@ -0,0 +1 @@
+ffmpeg -i VTS_01_1.VOB -an -sn -vcodec copy -f rawvideo output.mpeg
View
2  ffmpeg_extract-audio.bat
@@ -0,0 +1,2 @@
+REM ffmpeg -i bond.vob -f mp3 -ar 44100 -ab 128000 -ac 2 audio.mp3
+ffmpeg -i %1 -f wav -ac 1 -ar 16000 audio.wav
View
1  ffmpeg_vob2mpeg.bat
@@ -0,0 +1 @@
+ffmpeg -i VTS_01_1.VOB -vcodec copy -acodec copy output.mpg
View
87 movie_core.py
@@ -1,87 +0,0 @@
-# -*- coding: utf-8 -*-
-import cv
-import sys
-import os
-import os.path
-import math
-import xml.etree.ElementTree as et
-import time
-
-
-OUTPUT_DIR_NAME = "core"
-
-
-def main():
- os.chdir(sys.argv[1])
-
- try:
- os.mkdir(OUTPUT_DIR_NAME)
- except:
- pass
-
- tree = et.parse("project.xml")
-
- movie = tree.getroot()
- file_path = movie.attrib["path"]
-
- cap = cv.CreateFileCapture(file_path)
- cv.QueryFrame(cap)
-
- # skip frames in the beginning, if neccessary
- start_frame = int( movie.attrib["start_frame"] )
- for i in range(start_frame):
- cv.QueryFrame(cap)
-
- f = open("scenes.txt", "r")
- lines = [line for line in f if line]
- f.close()
-
- w = None
- h = None
- radius = None
- umfang = None
-
- t = time.time()
-
- for nr, line in enumerate(lines):
- print (nr+1), "/", len(lines)
-
- width = int( line.split("\t")[2] )
-
- output_img = None
-
- for frame_counter in range(width):
- img = cv.QueryFrame(cap)
- if not img:
- break
-
- if nr == 0:
- w = img.width
- h = img.height
- radius = int( (0.9 * h) / 2 )
- umfang = int( 2 * math.pi * radius )
-
- if frame_counter == 0:
- output_img = cv.CreateImage((umfang, width), cv.IPL_DEPTH_8U, 3)
- cv.SaveImage(os.path.join(OUTPUT_DIR_NAME, "core_%04d_a.png" % nr), img)
- elif frame_counter == width-1:
- cv.SaveImage(os.path.join(OUTPUT_DIR_NAME, "core_%04d_b.png" % nr), img)
-
- for i in range(umfang):
- alpha = math.radians( i * (360.0 / umfang) )
- x = (w / 2) + math.sin(alpha) * radius
- y = (h / 2) + math.cos(alpha) * radius
- px = cv.Get2D(img, int(y), int(x))
- cv.Set2D(output_img, frame_counter, i, px)
-
- cv.SaveImage(os.path.join(OUTPUT_DIR_NAME, "core_%04d.png" % nr), output_img)
-
- print "%.2f min" % ((time.time()-t) / 60)
- raw_input("- done -")
- return
-
-
-# #########################
-if __name__ == "__main__":
- main()
-# #########################
View
33 plot_chapters.py
@@ -1,33 +0,0 @@
-# -*- coding: utf-8 -*-
-import sys
-import os
-import xml.etree.ElementTree as et
-import matplotlib.pyplot as plt
-import math
-import numpy
-
-
-os.chdir(sys.argv[1])
-
-# ===== SHOTS ==================================================================================================
-f = open("chapters.txt", "r")
-values = [int(value) for value in f if value]
-f.close()
-
-fig = plt.figure()
-ax = fig.add_subplot(111)
-
-#last_endframe = 0
-tree = et.parse("project.xml")
-movie = tree.getroot()
-last_endframe = int( movie.attrib["start_frame"] )
-
-for i, item in enumerate(values):
- y = 1
- if (i % 2 == 0):
- y = 2
- ax.hlines(y, last_endframe, item, lw=30)
- last_endframe = item
-
-ax.axis("off")
-plt.show()
View
57 stills.py
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-import cv
-import math
-import os
-import sys
-import xml.etree.ElementTree as et
-import time
-
-
-EVERY_NTH_FRAME = 50
-
-
-def main():
- os.chdir(sys.argv[1])
- try:
- os.mkdir("stills")
- except OSError:
- pass
-
- tree = et.parse("project.xml")
-
- movie = tree.getroot()
- file_path = movie.attrib["path"]
-
- cap = cv.CreateFileCapture(file_path)
- cv.QueryFrame(cap)
-
- # skip frames in the beginning, if neccessary
- start_frame = int( movie.attrib["start_frame"] )
- for i in range(start_frame):
- cv.QueryFrame(cap)
-
- frame_counter = 0
-
- t = time.time()
-
- while 1:
- img = cv.QueryFrame(cap)
- if not img:
- break
-
- cv.SaveImage("stills\\still_%07d.jpg" % (frame_counter), img)
- frame_counter += 1
-
- for i in range(EVERY_NTH_FRAME-1):
- cv.GrabFrame(cap)
- frame_counter += 1
-
- print "%.2f min" % ((time.time()-t) / 60)
- raw_input("- done -")
- return
-
-
-# #########################
-if __name__ == "__main__":
- main()
-# #########################
View
49 stills_slitscan.py
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-import cv
-import sys
-import os
-import os.path
-
-
-OUTPUT_DIR_NAME = "stills_slitscan"
-
-
-def main():
- os.chdir(sys.argv[1])
-
- try:
- os.mkdir(OUTPUT_DIR_NAME)
- except:
- pass
-
- os.chdir("stills")
- files = [file for file in os.listdir(os.getcwd()) if not os.path.isdir(file)]
-
- width = None
- height = None
- output_img = None
-
- for i, file in enumerate( files ):
- img = cv.LoadImageM(file)
-
- if i % 100:
- print i, "/", len(files)
-
- if i == 0:
- width = img.width
- height = img.height
- output_img = cv.CreateImage((width, len(files)), cv.IPL_DEPTH_8U, 3)
-
- row = cv.GetRow(img, int( (i/len(files))*height ))
- for x in range(width):
- color = cv.Get1D(row, x)
- cv.Set2D(output_img, i, x, color)
-
- cv.SaveImage("..\\" + OUTPUT_DIR_NAME + "\\still_slitscan.png", output_img)
- return
-
-
-# #########################
-if __name__ == "__main__":
- main()
-# #########################
View
126 subtitle_quotes.py
@@ -1,126 +0,0 @@
-# -*- coding: utf-8 -*-
-import sys
-import os
-from pysrt import SubRipFile, SubRipItem, SubRipTime
-from lxml import etree
-import re
-import string
-import xml.etree.ElementTree as et
-
-
-from lib import timecode_to_seconds, seconds_to_timecode
-
-
-QUOTE_MIN_LEN = 5
-QUOTE_MAX_LEN = 300
-
-
-def main():
- os.chdir(sys.argv[1])
-
- raw_input("are the subtitle timings correct?".upper())
-
- # ##### extract quotes from IMDB html-file ###################################################
- f = open(r"quotes.htm", "r")
- parser = etree.HTMLParser()
- tree = etree.parse(f, parser)
- f.close()
- root = tree.getroot()
-
- quotes = []
- for div in root.xpath("//div"):
- try:
- c = div.attrib["class"]
- if c == "sodatext":
- s = etree.tostring(div)
- s = re.sub("\<div.*\>\n", "", s)
- s = re.sub("\</div.*\>", "", s)
-
- #s = re.sub("\<b\>.*\</b\>:\n", "- ", s) # names
- s = re.sub("\<b\>\<a.*\"\>", "", s)
- s = re.sub("\</a\>\</b\>:\n", ": ", s)
-
- # share this quote
- s = re.sub("\<p.*\>.*\</p\>", "", s)
- s = re.sub("\<span.*\>.*\</span\>", "", s)
-
- s = re.sub("\[.*\]", "", s) # stage directions
- s = re.sub("\<br/\>", "", s)
- s = re.sub(" ", " ", s)
- lines = [line.strip() for line in s.split("\n")]
- lines = [line for line in lines if len(line) > 0]
- if len(lines) == 1:
- lines[0] = lines[0][1:].strip()
- quote = "\n".join(lines)
- # #######
- '''if len(quote) >= QUOTE_MIN_LEN and len(quote) <= QUOTE_MAX_LEN:
- quotes.append(quote)'''
- quotes.append(quote)
- # #######
- except:
- continue
-
- quotes = list( set(quotes) )
- quotes_clean = [re.sub("[%s]+" % re.escape(string.punctuation), "", x) for x in quotes]
- quotes_clean = [x.lower().strip() for x in quotes_clean]
- """for quote in quotes_clean:
- print quote, "\n" """
-
- # ##### read subtitles from srt-file ###################################################
- subs = SubRipFile.open('subtitles.srt')
- """for sub in subs:
- #print sub.from_string()
- print sub.index
- #print sub.shift()
- print sub.start
- print sub.end
- print sub.text
- print "\n" """
- #print dir(subs)
-
- timecode_quote = {}
- for item in subs:
- item.text = re.sub("[%s]+" % re.escape(string.punctuation), "", item.text)
- item.text = item.text.lower().strip()
- text = item.text.split("\n")[0] # first line only
-
- for i, quote in enumerate(quotes_clean):
- if len(text.split(" ")) >= 3 and text in quote: # we'll get a lot of false hits with only one word :/
- if quotes[i] not in timecode_quote.values():
- timecode_quote[str(item.start)] = quotes[i]
-
- # ##### ###################################################
- tree = et.parse("project.xml")
- movie = tree.getroot()
- fps = float( movie.attrib["fps"] )
- frames = float( movie.attrib["frames"] )
- seconds = frames / fps
- #print seconds
- """start_frame = float( movie.attrib["start_frame"] )
- start_sec = startframe / fps"""
-
- # sort by timecode
- timecodes = timecode_quote.keys()
- timecodes.sort()
-
- f = open("quotes.txt", "w")
- for tc in timecodes:
- #print tc
- print "%.1f" % (100 * timecode_to_seconds(tc) / seconds) + "%", tc
- print timecode_quote[tc]
- print ""
- f.write("%f#%s\n" % (timecode_to_seconds(tc) / seconds, timecode_quote[tc].replace("\n", "#")))
- f.close()
-
- print "<<", len(timecodes), "QUOTES >>"
-
-
- #raw_input("- done -")
- return
-
-
-
-# #########################
-if __name__ == "__main__":
- main()
-# #########################
View
49 subtitle_sync.py
@@ -1,49 +0,0 @@
-import math
-import pysrt
-
-
-from lib import timecode_to_seconds, seconds_to_timecode
-
-
-#def corrected_seconds(s, speed, offset):
-# return (s / speed) + offset
-
-
-PROJECT = "Annie Hall"
-
-
-def main():
- tc_1 = timecode_to_seconds("00:00:53,840")
- tc_1_real = timecode_to_seconds("00:00:49,000")
-
- tc_2 = timecode_to_seconds("01:27:22,640")
- tc_2_real = timecode_to_seconds("01:27:18,000")
-
- speed = (tc_1 - tc_2) / (tc_1_real - tc_2_real)
- #print speed
- offset = tc_1_real - (tc_1 / speed)
- #print offset
- #print (tc_1 / speed) + offset, tc_1_real
-
- #print "00:00:59,225"
- #print seconds_to_timecode(timecode_to_seconds("00:00:59,225"))
-
- #print corrected_seconds(tc_1, speed, offset), seconds_to_timecode(corrected_seconds(tc_1, speed, offset))
- file_orig = pysrt.SubRipFile.open("projects\\" + PROJECT + "\\subtitles.srt~")
-
- for sub in file_orig:
- sub.start = timecode_to_seconds(str(sub.start))
- sub.start = (sub.start / speed) + offset
- sub.start = seconds_to_timecode(sub.start)
-
- sub.end = timecode_to_seconds(str(sub.end))
- sub.end = (sub.end / speed) + offset
- sub.end = seconds_to_timecode(sub.end)
-
- file_orig.save("projects\\" + PROJECT + "\\subtitles.srt", "utf-8") # , "utf-8", "\n"
-
-
-# #########################
-if __name__ == "__main__":
- main()
-# #########################
Please sign in to comment.
Something went wrong with that request. Please try again.