Skip to content

Instantly share code, notes, and snippets.

@Vicfred
Last active April 12, 2024 06:12
Show Gist options
  • Save Vicfred/2d8a0d466c021175f1fd27001e2b0ef4 to your computer and use it in GitHub Desktop.
Save Vicfred/2d8a0d466c021175f1fd27001e2b0ef4 to your computer and use it in GitHub Desktop.
ffmpeg common

metadata

ffprobe input.mp4

(no export)

INPUT_VIDEO=input.mp4

default crf is 28 (lower = better quality), default preset is medium, preserve metadata, re-encode audio

HALF THE SIZE OF DEFAULT ANDROID ENCODING

ffmpeg -i $INPUT_VIDEO -c:v libx265 -map_metadata 0 -movflags use_metadata_tags -c:a aac -b:a 128k output.mp4

crf 26 (lower = better quality), slow preset, preserve metadata, re-encode audio

ffmpeg -i $INPUT_VIDEO -c:v libx265 -map_metadata 0 -movflags use_metadata_tags -crf 26 -preset slow -c:a aac -b:a 128k output.mp4

downsize to half

ffmpeg -i $INPUT_VIDEO -c:v libx265 -vf scale="iw/2:ih/2" -map_metadata 0 -movflags use_metadata_tags -c:a aac -b:a 128k output.mp4

remove audio

ffmpeg -i $INPUT_VIDEO -c:v libx265 -map_metadata 0 -movflags use_metadata_tags -an output.mp4

batch.sh

#!/bin/bash
for video_file in *.mp4; do
  ffmpeg -i $video_file -c:v libx265 -map_metadata 0 -movflags use_metadata_tags -c:a aac -b:a 128k compressed/$video_file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment