Skip to content

Instantly share code, notes, and snippets.

@oliverswitzer
Created October 10, 2022 00:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliverswitzer/c5facaef1ec91eb93ddb5ba828572d96 to your computer and use it in GitHub Desktop.
Save oliverswitzer/c5facaef1ec91eb93ddb5ba828572d96 to your computer and use it in GitHub Desktop.
Simple elixir script to rotate mp4 video in bulk using ffmpeg
# Files need to be in same directory as this script
files = ["rotate_me_1", "rotate_me_2", "rotate_me_3"]
# Read more about rotating videos with ffmpeg here
# https://www.baeldung.com/linux/ffmpeg-rotate-video#:~:text=transpose%20is%20an%20FFmpeg%20filter,the%20values%20from%200%2D3.
# Run this from a new shell session to watch the progress of this script:
# `$ while true; do ps aux | grep ffmpeg; sleep 2; clear; done`
Task.async_stream(
files,
fn f ->
IO.puts("START: Running ffmpeg rotation for file #{f}.MP4")
System.cmd("ffmpeg", ["-y", "-i", "#{f}.MP4", "-vf", "transpose=2", "#{f}.mov"])
IO.puts("END: Running ffmpeg rotation for file #{f}.MP4")
end,
max_concurrency: 3,
timeout: :infinity
)
|> Enum.to_list()
IO.puts("Finished processing all videos! (files: #{files})")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment