User:Manetta/scripts/python-csv-to-ffmpeg-subclips: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "<source lang="python"> import os import csv with open('bambi-chunks-annotations.csv', 'rb') as f: reader = csv.reader(f) i=0 for row in reader: start = row[1...")
 
No edit summary
 
Line 3: Line 3:
import csv
import csv


with open('bambi-chunks-annotations.csv', 'rb') as f:
with open('spreadsheet.csv', 'rb') as f:
     reader = csv.reader(f)
     reader = csv.reader(f)
     i=0
     i=0
Line 17: Line 17:


</source>
</source>
with clip description in csv:
1,00:01:18.00,00:02:40.50,introduction of the wood,
2,00:02:42.00,00:02:55.00,owl flies and lands on tree,
3,00:02:58.00,00:03:04.50,owl settles and trembles,
4,00:03:05.00,00:03:10.00,owl yawns,
5,00:03:12.00,00:03:21.00,squirle wakes up and yawns,
6,00:03:21.50,00:03:25.00,owl snors,
7,00:03:32.00,00:03:40.00,"kid squirle sleeps and covers Himself with his mothers' tale",
8,00:03:43.00,00:03:46.00,bird feeds her youngs,
9,00:03:45.00,00:03:55.00,"two kid birds fight for berries, The third flies in and eats the berries",
10,00:04:00.00,00:04:10.00,"mouse takes waterdrop and washes His face with it",
11,00:04:11.00,00:04:17.00,"Thumper walks out of his rabbit hole and yawns ",
12,00:04:18.00,00:04:22.00,Thumper scrubs his back to a tree,
13,00:04:24.00,00:04:27.00,bird flies and lands on tree,
14,00:04:28.00,00:04:46.00,bird calls and activates the animals ,
15,00:04:46.00,00:04:50.00,"*the sound of Thumper stamping on The ground* and Thumper calls the Owl to wake up",

Latest revision as of 09:26, 24 March 2015

import os
import csv

with open('spreadsheet.csv', 'rb') as f:
    reader = csv.reader(f)
    i=0
    for row in reader:
    	start = row[1]
    	end = row[2]
        print "this clip starts at "+start+" and ends at "+end
        c = "ffmpeg -i input.mpeg -ss "+start+" -to "+end+" -y subclips/output{0:03d}.mpeg".format(i)
        print c
        os.system(c)
        print i
        i=i+1

with clip description in csv:

1,00:01:18.00,00:02:40.50,introduction of the wood,
2,00:02:42.00,00:02:55.00,owl flies and lands on tree,
3,00:02:58.00,00:03:04.50,owl settles and trembles,
4,00:03:05.00,00:03:10.00,owl yawns,
5,00:03:12.00,00:03:21.00,squirle wakes up and yawns,
6,00:03:21.50,00:03:25.00,owl snors,
7,00:03:32.00,00:03:40.00,"kid squirle sleeps and covers Himself with his mothers' tale",
8,00:03:43.00,00:03:46.00,bird feeds her youngs,
9,00:03:45.00,00:03:55.00,"two kid birds fight for berries, The third flies in and eats the berries",
10,00:04:00.00,00:04:10.00,"mouse takes waterdrop and washes His face with it",
11,00:04:11.00,00:04:17.00,"Thumper walks out of his rabbit hole and yawns ",
12,00:04:18.00,00:04:22.00,Thumper scrubs his back to a tree,
13,00:04:24.00,00:04:27.00,bird flies and lands on tree,
14,00:04:28.00,00:04:46.00,bird calls and activates the animals ,
15,00:04:46.00,00:04:50.00,"*the sound of Thumper stamping on The ground* and Thumper calls the Owl to wake up",