Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- input_file="google-io_p2_compressed.mp4"
- output_file="highlighted_gemini_p2.mp4"
- # Updated list of timestamps
- timestamps=("00:24" "04:00" "04:15" "04:35" "07:18" "09:15" "09:46" "11:27" "11:56" "12:07" "12:16" "12:58" "15:54" "16:43" "17:15" "18:29" "19:01" "19:30" "20:03" "24:09" "27:29" "28:09" "28:44" "29:02" "29:10" "29:27" "29:52" "31:20" "31:56" "34:46" "35:35" "35:40" "36:27" "36:31" "36:48" "36:56" "39:32")
- mkdir temp_segments
- cd temp_segments
- # Cutting video into segments ensuring they start on a keyframe
- for ts in "${timestamps[@]}"; do
- IFS=: read min sec <<< "$ts"
- start_time=$(bc <<< "scale=2; $min*60 + $sec - 0.5")
- end_time=$(bc <<< "scale=2; $min*60 + $sec + 0.5")
- ffmpeg -ss $start_time -to $end_time -i "../$input_file" -c:v libx264 -force_key_frames "expr:gte(t,n_forced*1)" -preset fast "segment_${min}_${sec}.mp4"
- done
- # Create a text file for file concatenation
- for f in segment_*.mp4; do
- echo "file '$f'" >> concat_list.txt
- done
- # Using the concat filter to re-encode and concatenate segments
- ffmpeg -f concat -safe 0 -i concat_list.txt -c:v libx264 -preset fast -c:a aac -b:a 192k "../$output_file"
- cd ..
- rm -r temp_segments
- echo "Processing complete. Check your output file: $output_file"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement