Update FFmpeg command to include video scaling for vertical format conversion
This commit is contained in:
parent
96b3c05ac7
commit
d6991cfc86
11
tt
11
tt
@ -117,12 +117,15 @@ log_message "Audio length: $audio_length seconds"
|
||||
|
||||
log_message "Fade duration set to $fade_duration seconds"
|
||||
|
||||
# Prepare FFmpeg command for video concatenation
|
||||
# Prepare FFmpeg command for video scaling and concatenation
|
||||
concat_filter="concat=n=${#video_files[@]}:v=1:a=0"
|
||||
video_inputs=""
|
||||
scaled_inputs=""
|
||||
for i in "${!video_files[@]}"; do
|
||||
video_inputs+="-i \"${video_files[$i]}\" "
|
||||
scaled_inputs+="[${i}:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v${i}];"
|
||||
done
|
||||
concat_inputs=$(for i in $(seq 0 $((${#video_files[@]}-1))); do echo -n "[v${i}]"; done)
|
||||
|
||||
# Calculate total video length
|
||||
total_video_length=0
|
||||
@ -156,15 +159,15 @@ fi
|
||||
log_message "Random start time: $random_start seconds"
|
||||
|
||||
# Prepare FFmpeg command
|
||||
ffmpeg_command="ffmpeg -loglevel error -stats $video_inputs -ss $random_start -i \"$audio_file\" -filter_complex \""
|
||||
ffmpeg_command="ffmpeg -y -loglevel error -stats $video_inputs -ss $random_start -i \"$audio_file\" -filter_complex \""
|
||||
|
||||
if $vertical; then
|
||||
log_message "Converting to vertical format..."
|
||||
ffmpeg_command+="$concat_filter [v_concat]; [v_concat]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[v];"
|
||||
ffmpeg_command+="$scaled_inputs $concat_inputs$concat_filter [v_concat]; [v_concat]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[v];"
|
||||
ffmpeg_command+="[${#video_files[@]}:a]afade=t=in:st=0:d=$fade_duration,afade=t=out:st=$fade_out_start:d=$fade_duration[a]\""
|
||||
ffmpeg_command+=" -map \"[v]\" -map \"[a]\""
|
||||
else
|
||||
ffmpeg_command+="$concat_filter [v_concat];"
|
||||
ffmpeg_command+="$scaled_inputs $concat_inputs$concat_filter [v_concat];"
|
||||
ffmpeg_command+="[${#video_files[@]}:a]afade=t=in:st=0:d=$fade_duration,afade=t=out:st=$fade_out_start:d=$fade_duration[a]\""
|
||||
ffmpeg_command+=" -map \"[v_concat]\" -map \"[a]\""
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user