0

I needed a single ffmpeg command that will trim a video by 8 frames from beginning and 8 frames from the end of the video. Is there a way to do this. I'm on windows 10

If there is a single command to get this done it will really speed up my work, current option is to take it to premiere and trim and then export.

1 Answers1

0

If you know the frame rate (to calculate the frame duration) you should be able to use following code, assuming 8 frames = 0.333s (the 24FPS video)

#!/usr/bin/env powershell

$inputFile="input.mp4" $outputFile="output.mp4" $trimSeconds=0.333 # frames / FPS

$videoDuration=ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ${inputFile} Write-Host videoDuration=${videoDuration}

$endPosition=(($videoDuration -as [double]) - ($trimSeconds -as [double])) -as [string]

ffmpeg -ss ${trimSeconds}s -to ${endPosition} -i "${inputFile}" -c:v copy -c:a copy ${outputFile}

https://shotstack.io/learn/use-ffmpeg-to-trim-video/

How to get video duration in seconds?