forked from OpenJobDescription/openjd-specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpeg.yaml
226 lines (226 loc) · 7.33 KB
/
ffmpeg.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# ----
# Demonstrates
# ----
#
# This demonstrates a Job that will take an input image sequence and output an
# initial h264 movie via FFmpeg conversion, then take that h264 movie and
# generate a hq and proxy Prores, along with a webm suitable for web review.
#
# Encoding settings from the Academy Software Foundation's Encoding Guidelines
# Project: https://academysoftwarefoundation.github.io/EncodingGuidelines/
#
# You can see a summary of what this template will do by running:
#
# openjd summary ffmpeg.yaml
#
# To Run with default parameters use:
#
# openjd run ffmpeg.yaml -p InputFile=./image_sequence.%04d.exr \
# -p OutputDir=. -p StartFrame=1 -p EndFrame=100 -p FPS=24 --step webm \
# --run-dependencies
#
# If you want to just run the h264 encode, use this command:
#
# openjd run ffmpeg.yaml -p InputFile=./image_sequence.%04d.exr \
# -p OutputDir=. -p StartFrame=1 -p EndFrame=100 -p FPS=24 --step h264
#
# ----
# Requirements (tested with ffmpeg 6.1.1)
# ----
# - bash shell
# - FFmpeg with vpx library
#
# -----
# Contributors to this template:
# Sean Wallitsch (https://github.com/shidarin)
#
specificationVersion: 'jobtemplate-2023-09'
name: Job Bundle - FFmpeg Review Media
parameterDefinitions:
- name: InputFile
type: PATH
objectType: FILE
dataFlow: IN
description: The input image sequence, with %04d style padding.
userInterface:
control: CHOOSE_INPUT_FILE
label: Input File
groupLabel: Files
fileFilters:
- label: Image Sequence Files
patterns: ["*.exr", "*.png", "*.dpx"]
- label: Any Files
patterns: ["*"]
# In a GUI, this would only "kinda" work right now, because what we
# really need to provide to FFmpeg for an image sequence is something with
# frame padding. If this were using an OpenJD GUI, a GUI would tell
# openjd-cli the literal value of the file we selected, frame number and
# all. If you need to use a straight OpenJD GUI here which directly passes
# the result of this to the OpenJD template, you should be using a script
# to change this value and add the frame padding.
- name: OutputDir
type: PATH
objectType: DIRECTORY
dataFlow: OUT
description: The output directory to put all generated movies in
userInterface:
control: CHOOSE_DIRECTORY
label: Output Directory
groupLabel: Files
- name: FPS
type: INT
userInterface:
control: DROPDOWN_LIST
label: FPS
groupLabel: FrameInfo
description: What FPS (Frames Per Second) the movie should be encoded at.
default: 24
allowedValues: [1, 12, 24, 30, 48, 60, 90, 96, 120, 144, 165, 240]
- name: StartFrame
type: INT
userInterface:
control: SPIN_BOX
label: Start Frame
groupLabel: FrameInfo
description: What frame to start the encode on
default: 1
- name: EndFrame
type: INT
userInterface:
control: SPIN_BOX
label: End Frame
groupLabel: FrameInfo
description: What frame to end the encode on
# It'd be great to have EndFrame be completely optional- where if a value is
# not given, a default value results in the argument not being given to
# FFmpeg at all. You wouuld need to set up an embedded script do handle
# that, and it might not even be desirable as the first missing frame
# would result in the end of the encode.
steps:
- name: h264
# This step encodes a high quality h264 mp4 for downstream
script:
actions:
onRun:
command: "ffmpeg"
args:
# Every argument and its value, must be a separate list item. If
# you combine the argument and the value, FFmpeg (and most other
# CLI tools) will treat them as one combined arg and have no idea
# how to handle this. This is a side result of how openjd is
# formatting those args, as each item on this list will be
# enclosed in single quotes after being its values being
# formatted.
- "-r" # Framerate
- "{{Param.FPS}}"
- "-start_number"
- "{{Param.StartFrame}}"
- "-i"
- "{{Param.InputFile}}"
- "-pix_fmt"
- "yuv444p10le" # YUV 4:4:4 10-bit to use as input to other encodes
- "-crf"
- "18" # Lower numbers better, 0 is uncompressed
- "-vf"
- "scale=in_color_matrix=bt709:out_color_matrix=bt709"
- "-frames:v" # End Frame options need to happen after the input
- "{{Param.EndFrame}}"
- "-c:v"
- "libx264"
- "-preset"
- "slower" # 'slow' runs slightly faster.
- "-color_range"
- "tv"
- "-colorspace"
- "bt709"
- "-color_primaries"
- "bt709"
- "-color_trc"
- "iec61966-2-1"
- "-movflags"
- "faststart" # Reorgs mp4 for better streaming performance
- "{{Param.OutputDir}}/h264_hq_output.mp4"
- name: webm
# For web review
dependencies:
- dependsOn: 'h264'
script:
actions:
onRun:
command: "ffmpeg"
args:
- "-r" # Framerate
- "{{Param.FPS}}"
- "-i"
- "{{Param.OutputDir}}/h264_hq_output.mp4"
- "-c:v"
- "libvpx-vp9"
- "-pix_fmt"
- "yuv420p10le" # YUV 4:2:0 10-bit
- "-crf"
- "22"
- "-speed"
- "2"
- "-row-mt"
- "1"
- "-quality"
- "good"
- "-b:v"
- "0"
- "-sws_flags"
- "spline+accurate_rnd+full_chroma_int"
- "-vf"
- "scale=in_range=full:in_color_matrix=bt709:out_range=tv:out_color_matrix=bt709"
- "-color_range"
- "tv"
- "-colorspace"
- "bt709"
- "-color_primaries"
- "bt709"
- "-color_trc"
- "iec61966-2-1"
- "-y"
- "{{Param.OutputDir}}/webm_output.webm"
- name: prores
# For editorial
dependencies:
- dependsOn: "h264"
parameterSpace:
# Setting a taskParameter will result in multiple tasks being broken out
taskParameterDefinitions:
- name: Quality
type: STRING
range: ["0", "3"]
script:
actions:
onRun:
command: "ffmpeg"
args:
- "-r" # Framerate
- "{{Param.FPS}}"
- "-i"
- "{{Param.OutputDir}}/h264_hq_output.mp4"
- "-pix_fmt"
- "yuv422p10le" # YUV 4:2:2 10-bit
- "-vf"
- "scale=in_color_matrix=bt709:out_color_matrix=bt709"
- "-c:v"
- "prores_ks" # For Apple Silicon, use prores_videotoolbox
- "-profile:v"
- "{{Task.Param.Quality}}"
- "-vendor"
- "apl0"
- "-qscale:v"
- "11" # between values of 9-13 give a good result, w/ 0 being best
- "-color_range"
- "tv"
- "-colorspace"
- "bt709"
- "-color_primaries"
- "bt709"
- "-color_trc"
- "iec61966-2-1"
- "-y"
- "{{Param.OutputDir}}/prores_{{Task.Param.Quality}}_output.mov"