Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bash script to trim last few seconds of video files (.mp4) downloaded with you-get using ffmpeg
for f in *.mp4; do
duration=$(ffmpeg -i "$f" 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,//)
length=$(echo "$duration" | awk '{ split($1, A, ":"); print 3600*A[1] + 60*A[2] + A[3] }' )
trim_end=$(echo "$length" - 18 - "$trim_start" | bc)
ffmpeg -ss "$trim_start" -i "$f" -c copy -map 0 -t "$trim_end" "${f%.mp4}-trimmed.mp4"

This comment has been minimized.

Copy link
Owner Author

AdySan commented Dec 27, 2016

@sharonhe Check this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.