Skip to content

Commit

Permalink
Add an ffmpeg script to normalize video
Browse files Browse the repository at this point in the history
  • Loading branch information
cnunciato committed Oct 7, 2024
1 parent a331e36 commit dee2ff1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/normalize-video.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# This script takes an input video path (relative is fine) and converts it to H.264 MP4 format with AAC audio,
# downscaling to 1200-pixel max-width where necessary. Converted files are written to ${filename}-${video_codec}.${extension}.
# Originals are left not modified. Requires ffmpeg: https://ffmpeg.org/download.html

filename=$(basename $1)
path=$(dirname $1)
video_codec="h264"
audio_codec="aac"
max_width="1200"
extension="mp4"

ffmpeg -i "${1}" -vcodec "$video_codec" -acodec "$audio_codec" -crf 18 -vf "scale=${max_width}:-1" "${path}/$(echo ${filename%.*})-${video_codec}.${extension}"

0 comments on commit dee2ff1

Please sign in to comment.