Guest User

snip.sh

a guest
Jun 28th, 2020
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. INFILE="$1"
  4. OUT="$4"
  5.  
  6.  
  7. if ! [[ -f $INFILE ]]; then
  8.     echo "'$INFILE' is not a File."
  9.     exit 1
  10. elif [[ -z $OUT ]]; then
  11.     echo "Need four arguments: Infile, start time, duration, and outfile."
  12.     exit 1
  13. fi
  14.  
  15. function panic() {
  16.     echo "Operation cancelling." >&2
  17.     exit 1
  18. }
  19.  
  20.  
  21. ffmpeg -hide_banner -loglevel warning -stats -avoid_negative_ts 1 \
  22.     -ss "$2" -t "$3" -i "$INFILE" -map 0:v -map 0:a "$OUT" || panic
  23.  
  24.  
  25. echo -n "Done. Size: " >&2
  26. numfmt --to=iec-i --suffix=B --format="%.1f" $(stat -c '%s' "$OUT") >&2
  27. readlink -f "$OUT"
RAW Paste Data Copied