Skip to content

Instantly share code, notes, and snippets.

@nickferrando
Created August 25, 2023 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickferrando/e6427b6deede2c1062c4a343b4ee18ff to your computer and use it in GitHub Desktop.
Save nickferrando/e6427b6deede2c1062c4a343b4ee18ff to your computer and use it in GitHub Desktop.
BASH Script for HLS Single Rendition
#!/bin/bash
#This script will process each file in a given input directory
#and will create a corresponding output folder for each processed file.
# Input and output directories
input_dir="YOUR_INPUT_DIRECTORY"
output_dir="output_folder"
# Create the output directory if it doesn't exist
mkdir -p "$output_dir"
# Loop through each file in the input directory
for input_file in "$input_dir"/*; do
# Check if the item is a file (not a directory)
if [ -f "$input_file" ]; then
# Extract the filename without extension
filename=$(basename -- "$input_file")
filename_no_extension="${filename%.*}"
# Create a directory for this file's output
file_output_dir="$output_dir/$filename_no_extension"
mkdir -p "$file_output_dir"
# Your FFmpeg command here
ffmpeg -i "$input_file" -f hls -hls_time 2 -hls_playlist_type vod -hls_segment_type mpegts -hls_segment_filename "$file_output_dir data%02d.ts" "$file_output_dir stream.m3u8"
echo "Processed: $input_file"
fi
done
echo "All files processed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment