Last active
September 1, 2022 10:27
-
-
Save megasaturnv/1ff1f56a5a9a21b67354769f633ed2af to your computer and use it in GitHub Desktop.
Simple script to extract a clip from an video with ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ./ffmpeg_clip.sh <filename> <start mm:ss> <end mm:ss> | |
# Example: ./ffmpeg_clip.sh file.mp4 01:15 01:45 | |
# Output file is <filename>_clip.mp4 | |
FILE=$1 | |
START_TIME=$2 | |
END_TIME=$3 | |
echo "start $(date -Iseconds)" | |
#Don't rotate 180 | |
ffmpeg -hide_banner -loglevel error -i "$1" -ss "$START_TIME" -to "$END_TIME" -metadata:s:v rotate=0 -codec:v libx264 -codec:a aac "$1_clip.mp4" | |
# ffmpeg -hide_banner -loglevel error -i "$1" -ss "$START_TIME" -to "$END_TIME" -metadata:s:v rotate=0 -codec:v copy -codec:a aac "$1_clip.mp4" | |
# ffmpeg -hide_banner -loglevel error -i "$1" -ss "$START_TIME" -to "$END_TIME" -metadata:s:v rotate=0 -codec:v copy -codec:a copy "$1_clip.mp4" | |
#Rotate 180 | |
#ffmpeg -hide_banner -loglevel error -i "$1" -ss "$START_TIME" -to "$END_TIME" -vf "transpose=2,transpose=2,format=yuv420p" -metadata:s:v rotate=0 -codec:v libx264 -codec:a aac "$1_clip.mp4" | |
#Rotate 180 Alternate method | |
#ffmpeg -hide_banner -loglevel error -i "$1" -ss "$START_TIME" -to "$END_TIME" -vf "rotate=PI:bilinear=0,format=yuv420p" -metadata:s:v rotate=0 -codec:v libx264 -codec:a aac "$1_clip2.mp4" | |
echo "end $(date -Iseconds)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment