Skip to content

Instantly share code, notes, and snippets.

@mmodrow
Created April 24, 2024 04:43
Show Gist options
  • Save mmodrow/a97e1bbb64f219db698f30ec5aee268d to your computer and use it in GitHub Desktop.
Save mmodrow/a97e1bbb64f219db698f30ec5aee268d to your computer and use it in GitHub Desktop.
Removes the last 5 seconds from all mp4 files in the directory using ffmpeg and stores them in an adjacent directory.
$videos = Get-ChildItem *.mp4
foreach ($video in $videos) {
$duration = [float](ffprobe -i $video.fullName -show_entries format=duration -v quiet -of csv="p=0")
ffmpeg -i $video.fullName -ss 0 -to ($duration - 5) (Join-Path "..\trimmed" ($video.name))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment