-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathffmpeg.py
54 lines (47 loc) · 1.75 KB
/
ffmpeg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Makes movies of cgem vars
#Plot CGEM
#plot_schism_cgem.py
##--Set path to scripts----
#SCRIPT_PATH = "/rsstu/users/l/lllowe/tops/visit-scripts"
SCRIPT_PATH = "/expanse/lustre/scratch/llowe/temp_project/CGEM/visit"
import subprocess
#
import os
#So it can find setup_visit.py
import sys
sys.path.append(SCRIPT_PATH)
from cgem_vars import *
from setpaths import *
#Put the full path, followed by '/'
#Main path to images
#This is in setpaths
#IMAGES = "/rsstu/users/l/lllowe/tops/images_1day/"
#Check that output directory exists
if not os.path.exists(IMAGES):
sys.exit("The directory " + IMAGES + " does not exist. Exiting.")
#nframes = '1440'
#nframes = '13700'
#nframes = '730'
#nframes = '8759'
#nframes = '300'
nframes = '4079'
start = '0'
which_plots = ['_surface','_near_bottom']
#Images are in separate directories for each varible
for var in cgem_vars:
for iplot in which_plots:
#-r is frame rate, how many images per second. Increase to make the movie run faster.
command = 'ffmpeg -y -r 30 -s 1200x1000 -start_number ' + start
filename = IMAGES + var['name'] + "/" + var['name'] + iplot + '_%06d.png'
moviename = IMAGES + var['name'] + iplot + '.mp4'
command = command + ' -i ' + filename
command = command + ' -vframes ' + nframes + ' -c:v libx264 -crf 17 -pix_fmt yuv420p '
command = command + moviename
print(command)
exitcode = subprocess.call(command,shell=True)
if exitcode != 0:
print('Error, exit code:',exitcode)
print('Command:')
print(command)
sys.exit()
#ffmpeg -y -r 15 -f image2 -s 1200x800 -start_number $start -i $dirname/$filename%04d.$suffix -vframes $nframes -vcodec libx264 -crf 25 -pix_fmt yuv420p ./$filename.mp4