Last active
October 9, 2019 15:42
-
-
Save etenzy/55bebfbc944b997e5085545f09252da2 to your computer and use it in GitHub Desktop.
ffmpeg tools
This file contains hidden or 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 | |
# [Parsed_cropdetect_0 @ 0x220cdc0] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:215 t:0.215000 crop=1280:720:0:0 | |
# [Parsed_cropdetect_0 @ 0x220cdc0] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:257 t:0.257000 crop=1280:720:0:0 | |
# [Parsed_cropdetect_0 @ 0x220cdc0] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:299 t:0.299000 crop=1280:720:0:0 | |
ffmpeg -ss 90 -i $1 -vframes 10 -vf cropdetect -f null - |
This file contains hidden or 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 | |
# ffplay -vf crop=1280:720:0:0 input.mp4 | |
# $1=file $2=crop | |
ffplay -vf crop=$2 $1 |
This file contains hidden or 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 | |
# ffmpeg -i input.mp4 -vf crop=1280:720:0:0 -c:a copy output.mp4 | |
# $1=file $2=crop $3=output | |
threads=$(nproc --all | awk '{ print $1-1 }') | |
if [ $threads -eq 0 ]; then | |
threads=1; | |
fi | |
case "$2" in | |
"auto") | |
position=$(ffprobe -show_streams $1 2> /dev/null | grep nb_frames | head -1 | cut -d \= -f 2 | awk '{print $1-1+1}') | |
if [ $position -ne 0 ]; then | |
position=$($position / 2); | |
fi | |
crop=$(ffmpeg -threads $threads -i $1 -vf select=$position -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | cut -d \= -f 2 | tail -1) | |
;; | |
*) | |
crop=$2 | |
;; | |
esac | |
file=$(basename "$1") | |
ext=${file##*.} | |
fileName=$(basename "$file" ".$ext")_crop | |
output=${3:-$fileName".mp4"} | |
rm -f "$output" | |
ffmpeg -threads $threads -i $1 -vf crop=$crop -c:a copy $output |
This file contains hidden or 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 | |
# ffmpeg -i input.mp4 -vf select=\'eq\(n,1337\) -vframes 1 output.jpg | |
# $1=file $2=position $3=output | |
threads=$(nproc --all | awk '{ print $1-1 }') | |
if [ $threads -eq 0 ]; then | |
threads=1; | |
fi | |
case "$2" in | |
"first") | |
position=0 | |
;; | |
"last") | |
position=$(ffprobe -show_streams $1 2> /dev/null | grep nb_frames | head -1 | cut -d \= -f 2 | awk '{print $1-1}') | |
;; | |
*) | |
position=$2 | |
;; | |
esac | |
file=$(basename "$1") | |
ext=${file##*.} | |
fileName=$(basename "$file" ".$ext")_$position | |
output=${3:-$fileName".jpg"} | |
rm -f "$output" | |
ffmpeg -threads $threads -i $1 -vf select=\'eq\(n,$position\) -vframes 1 $output |
This file contains hidden or 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 | |
threads=$(nproc --all | awk '{ print $1-1 }') | |
if [ $threads -eq 0 ]; then | |
threads=1; | |
fi | |
file=$(basename "$1") | |
ext=${file##*.} | |
fileName=$(basename "$file" ".$ext") | |
ffmpeg -threads $threads -i "$1" -c:v h264 -an ${2:-$fileName}.mp4 | |
ffmpeg -threads $threads -i "$1" -c:v libtheora -q:v 4 -an ${2:-$fileName}.ogv | |
ffmpeg -threads $threads -i "$1" -c:v libvpx-vp9 -b:v 5M -an ${2:-$fileName}.webm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment