jbilcke-hf HF staff commited on
Commit
d7766f0
·
verified ·
1 Parent(s): a309b59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +105 -1
app.py CHANGED
@@ -96,12 +96,116 @@ def export_to_video_file(video_frames, output_video_path=None, fps=hardcoded_fps
96
  # those are way too slow for a AiTube which needs things to be as fast as possible
97
  # -----------------------------------------------------------------------------------
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  def interpolate_video_frames(input_file_path, output_file_path, output_fps=hardcoded_fps, desired_duration=hardcoded_duration_sec, original_duration=hardcoded_duration_sec):
100
  scale_factor = desired_duration / original_duration
101
  # old value:
102
  # interpolation_filter = f'minterpolate=fps={output_fps},setpts={scale_factor}*PTS'
103
  # new value:
104
- interpolation_filter = f'minterpolate=mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps={output_fps},setpts={scale_factor}*PTS'
105
 
106
  cmd = [
107
  'ffmpeg',
 
96
  # those are way too slow for a AiTube which needs things to be as fast as possible
97
  # -----------------------------------------------------------------------------------
98
 
99
+ # Convert the video to specified frame rate using motion interpolation.
100
+ #
101
+ # This filter accepts the following options:
102
+ #
103
+ # fps
104
+ #
105
+ # Specify the output frame rate. This can be rational e.g. 60000/1001. Frames are dropped if fps is lower than source fps. Default 60.
106
+ # mi_mode
107
+ #
108
+ # Motion interpolation mode. Following values are accepted:
109
+ #
110
+ # ‘dup’
111
+ #
112
+ # Duplicate previous or next frame for interpolating new ones.
113
+ # ‘blend’
114
+ #
115
+ # Blend source frames. Interpolated frame is mean of previous and next frames.
116
+ # ‘mci’
117
+ #
118
+ # Motion compensated interpolation. Following options are effective when this mode is selected:
119
+ #
120
+ # ‘mc_mode’
121
+ #
122
+ # Motion compensation mode. Following values are accepted:
123
+ #
124
+ # ‘obmc’
125
+ #
126
+ # Overlapped block motion compensation.
127
+ # ‘aobmc’
128
+ #
129
+ # Adaptive overlapped block motion compensation. Window weighting coefficients are controlled adaptively according to the reliabilities of the neighboring motion vectors to reduce oversmoothing.
130
+ #
131
+ # Default mode is ‘obmc’.
132
+ # ‘me_mode’
133
+ #
134
+ # Motion estimation mode. Following values are accepted:
135
+ #
136
+ # ‘bidir’
137
+ #
138
+ # Bidirectional motion estimation. Motion vectors are estimated for each source frame in both forward and backward directions.
139
+ # ‘bilat’
140
+ #
141
+ # Bilateral motion estimation. Motion vectors are estimated directly for interpolated frame.
142
+ #
143
+ # Default mode is ‘bilat’.
144
+ # ‘me’
145
+ #
146
+ # The algorithm to be used for motion estimation. Following values are accepted:
147
+ #
148
+ # ‘esa’
149
+ #
150
+ # Exhaustive search algorithm.
151
+ # ‘tss’
152
+ #
153
+ # Three step search algorithm.
154
+ # ‘tdls’
155
+ #
156
+ # Two dimensional logarithmic search algorithm.
157
+ # ‘ntss’
158
+ #
159
+ # New three step search algorithm.
160
+ # ‘fss’
161
+ #
162
+ # Four step search algorithm.
163
+ # ‘ds’
164
+ #
165
+ # Diamond search algorithm.
166
+ # ‘hexbs’
167
+ #
168
+ # Hexagon-based search algorithm.
169
+ # ‘epzs’
170
+ #
171
+ # Enhanced predictive zonal search algorithm.
172
+ # ‘umh’
173
+ #
174
+ # Uneven multi-hexagon search algorithm.
175
+ #
176
+ # Default algorithm is ‘epzs’.
177
+ # ‘mb_size’
178
+ #
179
+ # Macroblock size. Default 16.
180
+ # ‘search_param’
181
+ #
182
+ # Motion estimation search parameter. Default 32.
183
+ # ‘vsbmc’
184
+ #
185
+ # Enable variable-size block motion compensation. Motion estimation is applied with smaller block sizes at object boundaries in order to make the them less blur. Default is 0 (disabled).
186
+ #
187
+ # scd
188
+ #
189
+ # Scene change detection method. Scene change leads motion vectors to be in random direction. Scene change detection replace interpolated frames by duplicate ones. May not be needed for other modes. Following values are accepted:
190
+ #
191
+ # ‘none’
192
+ #
193
+ # Disable scene change detection.
194
+ # ‘fdiff’
195
+ #
196
+ # Frame difference. Corresponding pixel values are compared and if it satisfies scd_threshold scene change is detected.
197
+ #
198
+ # Default method is ‘fdiff’.
199
+ # scd_threshold
200
+ #
201
+ # Scene change detection threshold. Default is 5.0.
202
+
203
  def interpolate_video_frames(input_file_path, output_file_path, output_fps=hardcoded_fps, desired_duration=hardcoded_duration_sec, original_duration=hardcoded_duration_sec):
204
  scale_factor = desired_duration / original_duration
205
  # old value:
206
  # interpolation_filter = f'minterpolate=fps={output_fps},setpts={scale_factor}*PTS'
207
  # new value:
208
+ interpolation_filter = f'minterpolate=mi_mode=mci:mc_mode=obmc:vsbmc=1:mb_size=8:fps={output_fps},setpts={scale_factor}*PTS'
209
 
210
  cmd = [
211
  'ffmpeg',