Tagi:
  1. pigers
    Co robi:
    Tworzy miniaturki (jeśli są to pomija tworzenie) o rozmiarze 400px (na podstawie proporcji z filmu) z przypadkowego momentu w filmie wg standardów KODI. Jak minaturka jest nieodpowiednia to skasuj ją i włącz skrypt jeszcze raz.

    Program:
    Kod (Bash):
    1. cat generate_thumbs.sh
    2. #!/bin/bash
    3. #check for required software
    4. command -v shuf >/dev/null 2>&1 || { echo "I require shuf but it's not installed.  Aborting." >&2; exit 1; }
    5. command -v ffmpegthumbnailer >/dev/null 2>&1 || { echo "I require ffmpegthumbnailer but it's not installed.  Aborting." >&2; exit 1; }
    6.  
    7. # check if crucial parameter is missing ...
    8. if [ $# -eq 0 ]
    9.   then
    10.   echo "Usage: $0 /video/folder/to/scan/ > thumbs.sh ; bash thumbs.sh"
    11.   exit 1;
    12. fi
    13. source_dir="${1}"
    14. #function which creates commands to create pics ...
    15. function create_commands()
    16. {
    17. #check if parameter is empty or so ...
    18. if [ -z "$1" ]
    19. then return 1
    20. fi
    21. #little bash magic here
    22. Upload=False
    23. SQL_User=root
    24. SQL_Password=haslo123
    25. generator=/usr/bin/ffmpegthumbnailer
    26. fname="${1}"
    27. #fname=$(echo $fname | sed "s/'/\\\'/g")
    28. filename=$(basename "$1")
    29. DIR=$(dirname "$1")
    30. extension="${filename##*.}"
    31. filename_o="${filename%.*}"
    32. file1="$DIR/$filename_o-thumb.jpg"
    33. file2="$DIR/$filename_o-poster.jpg"
    34. #create thumb if is not present
    35. if [ ! -f "${file1}" ]; then
    36. echo $generator -i \"${fname}\" -o \"${file1}\" -q 10 -s 400 -t `shuf -i10-85 -n1`%
    37. Upload=True
    38. fi
    39. #create poster if is not present
    40. if [ ! -f "${file2}" ]; then
    41. echo $generator -i \"${fname}\" -o \"${file2}\" -q 10 -s 400 -t `shuf -i10-85 -n1`%
    42. Upload=True
    43. fi
    44. #Upload info to DB ..
    45. #Uncomment to disable info upload to DB
    46. #Upload=False
    47. if [ "$Upload" == "True" ]; then
    48. echo "INSERT INTO ThumbsInfo (ID, Filename, CreationDate) VALUES (NULL,"\"${fname}\"", '`date +"%Y-%m-%d %T"`');" | mysql -u$SQL_User -p$SQL_Password ThumbsInfo;
    49. fi
    50. return 0
    51. }
    52.  
    53. input_file_types=(mkv mp4 avi)
    54.  
    55. #loop over the types and convert
    56. for input_file_type in "${input_file_types[@]}"
    57. do
    58.   #let find do magic with -print0 to keep null char at end of line
    59.   find "$source_dir" -name "*.$input_file_type" -print0 | while IFS= read -r -d $'\0' in_file
    60.   do
    61.   #create some commands from provided paths
    62.   create_commands "${in_file}"
    63.   done
    64. done
    Użycie:
    Podgląd co się bedzie działo:
    ./generate_thumbs.sh /PC/anime/Seriale/
    Kod (Bash):
    1. $ ./generate_thumbs.sh /PC/anime/Seriale/
    2. /usr/bin/ffmpegthumbnailer -i "/PC/anime/Seriale/Game of Thrones/Game of Thrones - 6x09 - Battle of the Bastards.mkv" -o "/PC/anime/Seriale/Game of Thrones/Game of Thrones - 6x09 - Battle of the Bastards-poster.jpg" -q 10 -s 400 -t 26%
    3. /usr/bin/ffmpegthumbnailer -i "/PC/anime/Seriale/Game of Thrones/Game of Thrones - 6x10 - The Winds of Winter.mkv" -o "/PC/anime/Seriale/Game of Thrones/Game of Thrones - 6x10 - The Winds of Winter-poster.jpg" -q 10 -s 400 -t 67%
    Wykonanie:
    ./generate_thumbs.sh /PC/anime/Seriale/ > thumbs.sh ; bash thumbs.sh &> /dev/null

Ostatnie aktualizacje

  1. SQL update fix #2
  2. SQL update fix
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Odrzuć powiadomienie.