Skip to content

Instantly share code, notes, and snippets.

@wommy
Created April 22, 2025 19:11
Show Gist options
  • Save wommy/bf7e4659970bffa249c0770a7986df96 to your computer and use it in GitHub Desktop.
Save wommy/bf7e4659970bffa249c0770a7986df96 to your computer and use it in GitHub Desktop.
# Assuming you are in the target directory in a Bash terminal
# 1. Get directory name and define list file name
current_dir_name=$(basename "$(pwd)")
list_file="${current_dir_name}_list.txt"
# 2. Generate the list of files recursively into the named list file
find . -type f -name "*.mp4" | sed "s/^/file '/;s/$/'/" > "$list_file"
# 3. Define output video name and run FFmpeg -c copy
output_file="${current_dir_name}_combined_mega_video.mp4"
ffmpeg -f concat -safe 0 -i "$list_file" -c copy "$output_file"
# --- If the above command fails, manually run this one ---
# 4. Define re-encoded output video name and run FFmpeg with re-encoding
# output_file_reencoded="${current_dir_name}_combined_mega_video_reencoded.mp4"
# ffmpeg -f concat -safe 0 -i "$list_file" -c:v libx264 -c:a aac "$output_file_reencoded"
# Optional: Clean up the named list file
# rm "$list_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment