make a ffmpeg 6.0 basch scripts to make this process easier when creating a audio acc…
- User
make a ffmpeg 6.0 basch scripts to make this process easier when creating a audio acc file along with a video avi file coverted to mkv refining using this args in a bash scrit to exec: ffmpeg -i audio_acc.mp4 -i video.avi -attach “Cover.webp” -metadata title=“Cover” -metadata:s:t:0 filename=“Cover.webp” -metadata:s:t:0 mimetype=“image/webp” -c:v libx265 -preset medium -tune psnr -x265-params “qp=16:rc-lookahead=18” -crf 22 -filter_complex “scale=2560:1440,loop=loop=-1:size=65:start=1” -t 00:01:00.1 -movflags +write_colr -movflags +faststart -tag:v hvc1 “sc-test-crf22-4.mkv”
- Assistant
To create a bash script that executes the FFmpeg command you've provided, you'll first need to make sure that FFmpeg version 6.0 or later is installed on your system, as it may include options or codecs that were not available in earlier versions.
Here's a simple bash script that encapsulates the FFmpeg command you've given. The script will take an ACC audio file and an AVI video file as input and will create an MKV file with the specified encoding settings and additional metadata:
bash#!/bin/bash # Check if enough arguments are provided if [ "$#" -ne 2 ]; then echo "Usage: $0 <audio_acc.mp4> <video.avi>" exit 1 fi # Assign readable names to the input arguments audio_acc_file="$1" video_file="$2" output_file="sc-test-crf22-4.mkv" # Run the FFmpeg command with the specified options on the inputs ffmpeg -i "$audio_acc_file" -i "$video_file" -attach "Cover.webp" \ -metadata title="Cover" \ -metadata:s:t:0 filename="Cover.webp" \ -metadata:s:t:0 mimetype="image/webp" \ -c:v libx265 -preset medium -tune psnr \ -x265-params "qp=16:rc-lookahead=18" -crf 22 \ -filter_complex "scale=2560:1440,loop=loop=-1:size=65:start=1" \ -t 00:01:00.1 -movflags +write_colr -movflags +faststart \ -tag:v hvc1 \ "$output_file" # Check if FFmpeg exited successfully if [ $? -eq 0 ]; then echo "Conversion successful, created '$output_file'" else echo "FFmpeg failed, please check the input files and parameters." fiTo use this script:
- Save it as
convert_to_mkv.shor another name of your choice. - Make it executable by running
chmod +x convert_to_mkv.sh. - Run it with
./convert_to_mkv.sh audio_acc.mp4 video.avi.
The script assumes that
Cover.webpis located in the same directory from where the script is run. If not, you should either move theCover.webpfile to the correct directory or provide an exact path to it inside the script.Keep in mind that this script does not handle all possible edge cases or errors, such as checking whether the input files exist. It simply demonstrates how to wrap the FFmpeg command you've provided in a bash script. You might want to add more sophisticated error checking or logging for production use.
- Save it as