Skip to content

Instantly share code, notes, and snippets.

@guessi
Created November 5, 2024 10:10
Show Gist options
  • Save guessi/c879ad3dd8141c136b2cc914bbaf7262 to your computer and use it in GitHub Desktop.
Save guessi/c879ad3dd8141c136b2cc914bbaf7262 to your computer and use it in GitHub Desktop.
resize video with ffmpeg
#!/usr/bin/env bash
INPUT="${1}"
OUTPUT="${2}"
SIZE="1920:1080" # horizontal
# SIZE="1080:1920" # vertical
BITRATE_V="4800k"
# https://trac.ffmpeg.org/wiki/Encode/H.265
ffmpeg -i ${INPUT} \
-c:v libx265 -vtag hvc1 -x265-params pass=1 \
-b:v "${BITRATE_V}" -vf "scale=${SIZE}" \
-an \
-map_metadata 0 \
-preset slower \
-f null /dev/null
ffmpeg -i ${INPUT} \
-c:v libx265 -vtag hvc1 -x265-params pass=2 \
-b:v "${BITRATE_V}" -vf "scale=${SIZE}" \
-c:a copy \
-map_metadata 0 \
-preset slower \
${OUTPUT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment