Various compilation scripts & patches for Linux programs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0 KiB

7 years ago
  1. #!/bin/bash
  2. #<get_videofile_length>
  3. #ffmpeg -- get mediafile length
  4. #ffmpeg -- get start time
  5. #ffmpeg -- get end time
  6. #end time =
  7. ###GET FILE LENGTH
  8. DURATION_FORMATTED='-sexagesimal'
  9. DURATION_LENGTH=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $DURATION_FORMATTED)
  10. DURATION=$($DURATION_LENGTH $INPUT_FILE)
  11. ##PRINT FILE LENGTH
  12. implement to kdialog
  13. kdialog --msgbox "$(ffmpeg -i %u 2>&1 |grep -E '(Duration)|(Stream)' )"
  14. echo -e $DURATION #Show media file duration in hours:minutes:seconds.microseconds
  15. $DURATION_FORMATTED=''
  16. echo -e $DURATION #Show media file duration in seconds
  17. #USER INPUT - DESIRED CUT (IN SECONDS)
  18. $START_TIME=<desired media start time in seconds (set 0 to default value)>
  19. $END_TIME=<desired media end time in seconds (get video end time and use it as default value)>
  20. $INPUT_FILEFORMAT=<get input fileformat (suffix)>
  21. +STRING=$(kdialog --icon=system-search --caption='Search string' --inputbox='Enter String to Search' 2> /dev/null)
  22. +
  23. +if [ "$?" != "0" ]; then
  24. + exit 1
  25. +fi
  26. #0:03:14.921000
  27. #tunti :: minuutti :: sekunti :: millisekunti
  28. #outputtaa näin:
  29. #if 0 hours, dont show the field if <value number before the first : is zero, replace with '' with sed>
  30. #if 0 minutes, don't show the field if <value number between the first and the second : is zero, replace with '' with sed>
  31. #if 0 seconds, don't show the field if <value number between the second : and the third . is zero, replace with '' with sed>
  32. #if 0 milliseconds, don't show the field if <value number between the third and the fourth : is zero, replace with '' with sed>
  33. #but final output can now be like
  34. #and >>> final output
  35. #ffmpeg -i <mediafile> -ss <start_time> -to <end_time> <mediafile_cut (get original format)>
  36. while [ $# -gt 0 ]; do
  37. INPUT_FILE=$1
  38. OUTPUT_FILE=$(echo "$INPUT_FILE" | sed "s/\.\w*$/_cut.$INPUT_FILEFORMAT/")
  39. ffmpeg -i "$INPUT_FILE" -ss $START_TIME -to $END_TIME -y "$OUTPUT_FILE"
  40. shift
  41. done
  42. exit 0