Tips and tricks

YouTube Download -
Install youtube dl
Get the list of qualities
yt-dlp -F [[YOUTUBE_ID]]

Complete script:
#!/usr/bin/env bash
# Script: merge_video_audio.sh
# Description: Prompts for two IDs, two formats, downloads them, and merges using ffmpeg.
# Prompt the user for the first ID
echo "Enter the first ID (video source) or URL:"
read FIRST_ID
# List available formats for the first ID
yt-dlp "$FIRST_ID" --list-formats
# Prompt the user to select a format for the first ID
echo "Enter the format code for the first ID (video):"
read FIRST_FORMAT
# Download the first ID as vtemp.mp4 using the chosen format
yt-dlp -i -f "$FIRST_FORMAT" "$FIRST_ID" -o "vtemp.mp4"
# Prompt the user to select a format for the second ID
echo "Enter the format code for the second ID (audio):"
read SECOND_FORMAT
# Download the second ID as vtemp.m4a using the chosen format
yt-dlp -i -f "$SECOND_FORMAT" "$FIRST_ID" -o "vtemp.m4a"
# Merge video and audio into output.mp4 using ffmpeg
ffmpeg -i vtemp.mp4 -i vtemp.m4a -c copy output.mp4
# Cleanup prompt (optional)
echo "Merging complete. The merged file is 'output.mp4'."
# Optionally, you might want to remove vtemp files if no longer needed:
# rm vtemp.mp4 vtemp.m4a