Advertisement
Guest User

ffmpeg_neighbor.sh

a guest
Oct 5th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.46 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # 引数を走査し -vf を見付けた場合、その左側に -sws_flags neighbor を
  4. # 追加して ffmpeg を呼び出す
  5.  
  6. # このファイルに実行権限を付与:
  7. #   chmod a+x ffmpeg_neighbor.sh
  8.  
  9. # vichan でこのスクリプトを使ってサムネイルを生成させる
  10. #   vichan/inc/instance-config.php
  11. #     $config['webm']['ffmpeg_path'] = '/path/to/ffmpeg_neighbor.sh';
  12. #   実行権限の付与が面倒くさい場合は
  13. #     $config['webm']['ffmpeg_path'] = 'bash -- /path/to/ffmpeg_neighbor.sh';
  14.  
  15.  
  16. # 設定値: ffmpeg 実体を指定
  17. real_ffmpeg_command=ffmpeg
  18.  
  19. function f() {
  20.     local -a args=( "$@" )
  21.  
  22.     local index=0
  23.  
  24.     for ((index=0; index < "${#args[@]}"; ++index)); do
  25.     if test '-vf' '=' "${args[index]}"; then
  26.  
  27.         args=("${args[@]:0:$index}"
  28.           '-sws_flags' 'neighbor'
  29.           "${args[@]:$index}")
  30.         break
  31.     fi
  32.     done
  33.  
  34.     "$real_ffmpeg_command" "${args[@]}"
  35. }
  36.  
  37. f "$@"
  38.  
  39.  
  40. # ---- vichan に default body を設定する
  41. # vichan/inc/instance-config.php
  42. #
  43. # event_handler('post', function($post) {
  44. #     if ($post->body == '') {
  45. #         # pixiv, Windows IME(?), たぶん old school
  46. #         $post->body = 'キタ━━━━(゚∀゚)━━━━!!';
  47. #         # # may, dec, jun
  48. #         # $post->body = 'キタ━━━(゚∀゚)━━━!!';
  49. #         # # img
  50. #         # $post->body = 'キタ━━━━━━(゚∀゚)━━━━━━ !!!!!';
  51. #     };
  52. # });
  53. # ----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement