Advertisement
Guest User

davinci-convert

a guest
May 3rd, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.12 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Determine input and output directories based on the number of arguments
  4. if [ "$#" -eq 1 ]; then
  5.   input_dir="$(pwd)"
  6.   output_dir="$1"
  7. elif [ "$#" -eq 2 ]; then
  8.   input_dir="$1"
  9.   output_dir="$2"
  10. else
  11.   echo "Usage: $0 [input_folder] /path/to/output_folder"
  12.   echo "If input_folder is omitted, the current directory is used as the input."
  13.   exit 1
  14. fi
  15.  
  16. # Check if the input directory exists
  17. if [ ! -d "$input_dir" ]; then
  18.   echo "Error: Input directory '$input_dir' does not exist."
  19.   exit 1
  20. fi
  21.  
  22. # Create the output directory if it doesn't exist
  23. mkdir -p "$output_dir"
  24.  
  25. # Loop through all files in the input directory
  26. for input_file in "$input_dir"/*; do
  27.   # Process only regular files
  28.   if [ -f "$input_file" ]; then
  29.     # Extract the filename without its extension
  30.     filename=$(basename "$input_file")
  31.     name="${filename%.*}"
  32.  
  33.     # Define the output file path
  34.     output_file="$output_dir/$name.mov"
  35.  
  36.     echo "Converting $input_file to $output_file..."
  37.  
  38.     # Convert the video using FFmpeg
  39.     ffmpeg -i "$input_file" -c:v copy -c:a pcm_s16le -ar 48000 -ac 2 "$output_file"
  40.   fi
  41. done
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement