Advertisement
Guest User

how to abuse catbox

a guest
Apr 10th, 2023
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #!/bin/bash
  2. # Short script to split videos by filesize using ffmpeg by LukeLR
  3. #how to use: ./filesplitter.sh "file.mp4" 195000000 "-c:v libx265 -c:a copy -vf scale=960:-1"
  4. #how to use without reducing quality: ./filesplitter.sh "file.mp4" 195000000 "-c:v copy -c:a copy"
  5. #Split into 195 MB chunks
  6.  
  7. if [ $# -ne 3 ]; then
  8. echo 'Illegal number of parameters. Needs 3 parameters:'
  9. echo 'Usage:'
  10. echo './split-video.sh FILE SIZELIMIT "FFMPEG_ARGS'
  11. echo
  12. echo 'Parameters:'
  13. echo ' - FILE: Name of the video file to split'
  14. echo ' - SIZELIMIT: Maximum file size of each part (in bytes)'
  15. echo ' - FFMPEG_ARGS: Additional arguments to pass to each ffmpeg-call'
  16. echo ' (video format and quality options etc.)'
  17. exit 1
  18. fi
  19.  
  20. FILE="$1"
  21. SIZELIMIT="$2"
  22. FFMPEG_ARGS="$3"
  23.  
  24. # Duration of the source video
  25. DURATION=$(ffprobe -i "$FILE" -show_entries format=duration -v quiet -of default=noprint_wrappers=1:nokey=1|cut -d. -f1)
  26.  
  27. # Duration that has been encoded so far
  28. CUR_DURATION=0
  29.  
  30. # Filename of the source video (without extension)
  31. BASENAME="${FILE%.*}"
  32.  
  33. # Extension for the video parts
  34. #EXTENSION="${FILE##*.}"
  35. EXTENSION="mp4"
  36.  
  37. # Number of the current video part
  38. i=1
  39.  
  40. # Filename of the next video part
  41. NEXTFILENAME="$BASENAME-$i.$EXTENSION"
  42.  
  43. echo "Duration of source video: $DURATION"
  44.  
  45. # Until the duration of all partial videos has reached the duration of the source video
  46. while [[ $CUR_DURATION -lt $DURATION ]]; do
  47. # Encode next part
  48. echo ffmpeg -i "$FILE" -ss "$CUR_DURATION" -fs "$SIZELIMIT" $FFMPEG_ARGS "$NEXTFILENAME"
  49. ffmpeg -ss "$CUR_DURATION" -i "$FILE" -fs "$SIZELIMIT" $FFMPEG_ARGS "$NEXTFILENAME"
  50.  
  51. # Duration of the new part
  52. NEW_DURATION=$(ffprobe -i "$NEXTFILENAME" -show_entries format=duration -v quiet -of default=noprint_wrappers=1:nokey=1|cut -d. -f1)
  53.  
  54. # Total duration encoded so far
  55. CUR_DURATION=$((CUR_DURATION + NEW_DURATION))
  56.  
  57. i=$((i + 1))
  58.  
  59. echo "Duration of $NEXTFILENAME: $NEW_DURATION"
  60. echo "Part No. $i starts at $CUR_DURATION"
  61.  
  62. NEXTFILENAME="$BASENAME-$i.$EXTENSION"
  63. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement