I use these two all the time to encode and cut mp4s.
The flags are for maximum compatibility (e.g. without them, some MP4s don't play in WhatsApp, or Discord on mobile, or whatever.)
ffmp4() {
input_file="$1"
output_file="${input_file%.*}_sd.mp4"
ffmpeg -i "$input_file" -c:v libx264 -crf 33 -profile:v baseline -level 3.0 -pix_fmt yuv420p -movflags faststart "$output_file"
echo "Compressed video saved as: $output_file"
}
ffmp4 foo.webm-> foo_sd.mp4
fftime() {
input_file="$1"
output_file="${input_file%.*}_cut.mp4"
ffmpeg -i "$input_file" -c copy -ss "$2" -to "$3" "$output_file"
echo "Cut video saved as: $output_file"
}
fftime foo.mp4 01:30 01:45-> foo_cut.mp4
Note, fftime copies the audio and video data without re-encoding, which can be a little janky, but often works fine, and can be much (100x) faster on large files. To re-encode just remove "-c copy"