Suppose the input file does not have filename extension. FFmpeg detects input file format, but how to use the same format for output file automatically?
Try this script. For an input file without an extension we use ffprobe
to figure out a suitable extension, and tack it on to the output file.
Run it like ./script.sh input_file_wtithout_extension
#!/usr/bin/env bash
input_file="$1"
extension=$(ffprobe "$input_file" -show_entries format=format_name -v quiet |\
grep -oP 'format_name=\K\w+')
output_file="$input_file".$extension
ffmpeg -y -i "$input_file" -strict -2 $options "$output_file"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With