Advertisement
thureinfree

ffmpeg mp4 conversion

Oct 17th, 2024 (edited)
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Find an example file in the current folder that follows the sequence pattern
  4. example_file=$(ls *.jpg | grep -E '\.[0-9]{4}\.jpg' | head -n 1)
  5.  
  6. # Check if a matching file was found
  7. if [[ -z "$example_file" ]]; then
  8. echo "No files found matching the pattern <file_name>.####.jpg"
  9. exit 1
  10. fi
  11.  
  12. # Extract the pattern by replacing the numeric part with %04d
  13. input_pattern=$(echo "$example_file" | sed -E 's/\.([0-9]{4})\.jpg$/\.%04d\.jpg/')
  14.  
  15. # Convert the image sequence to MP4
  16. ffmpeg -framerate 30 -i "$input_pattern" -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p output.mp4
  17.  
  18. echo "Conversion completed: output.mp4 created"
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement