Created
January 15, 2021 12:13
-
-
Save knekke/19e35f53fb5ae7ab88c3b12dabeb8027 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
frames = 50 | |
for frame in range(frames): | |
print(frame) | |
if frame == 0: | |
cmd = ['ffmpeg', '-y', '-i', 'test_source.mp4', | |
'-filter_complex', | |
'''[0]select='eq(n,0)'[A],[0]select='eq(n,1)'[B],[A][B]blend=all_mode=difference[out]''', | |
'-map', '[out]', '-vsync', '0', 'out.jpg'] | |
subprocess.run(cmd) | |
else: | |
cmd = ['ffmpeg', '-y', '-i', 'test_source.mp4', | |
'-i', 'out.jpg', | |
'-filter_complex', | |
f'''[0]select='eq(n,{frame})'[A],[A][1]blend=all_mode=difference[out]''', | |
'-map', '[out]', '-vsync', '0', 'out.jpg'] | |
subprocess.run(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment