Skip to content

Instantly share code, notes, and snippets.

@knekke
Created January 15, 2021 12:13
Show Gist options
  • Save knekke/19e35f53fb5ae7ab88c3b12dabeb8027 to your computer and use it in GitHub Desktop.
Save knekke/19e35f53fb5ae7ab88c3b12dabeb8027 to your computer and use it in GitHub Desktop.
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