/useful/trunk-1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/useful/trunk-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
###################
# FILE NAME: video2lbry.sh
#
# Encodes videos so they are ready to be uploaded to LBRY.
#
####################
ARGS=()
ARGS="${@}"

__IN_NAME=
__OUT_NAME=

__help () {
  echo "video2lbry.sh -- Make vide ready for upload to LBRY."
  echo " "
  echo "-i <input video file>     Input Video File."
  echo " "
  echo "-o <output video file>    Output Video File"
  echo "                          (_lbry.mp4 will be added to the end)."
  echo " "
}

__enc_mp4 () {
  ffmpeg -y -i "$__IN_NAME"\
          -threads 7\
          -c:v libx264\
          -crf 21\
          -preset slower\
          -pix_fmt yuv420p\
          -maxrate 5000K\
          -bufsize 5000K\
          -vf 'scale=if(gte(iw\,ih)\,min(2560\,iw)\,-2):if(lt(iw\,ih)\,min(2560\,ih)\,-2)'\
          -movflags +faststart\
          -c:a aac\
          -b:a 256k\
          "${__OUT_NAME}_lbry.mp4"
}

__parse_args() {
  if [ -z "$1" ]
  then
    echo "Try --help or -h."
    exit 1
  fi
  
  
  while [[ $# -gt 0 ]]
  do
    eval key="${1}"
    
    case "${1}" in
      -i)
      __IN_NAME="$2"
      shift
      shift
      ;;
      -o)
      __OUT_NAME="$2"
      shift
      shift
      ;;
      -m)
      __USE_WEBM=true
      shift
      ;;
      -h|--help)
      __help
      shift
      ;;
      *)
      __help
      exit
      shift
      ;;
      --)
      shift
      break
      ;;
    esac
  done
}

__main () {
  if [ ! -e "$__IN_NAME" ]
  then
    echo "missing input audio. Please provide."
    exit 1
  fi
  
  if [ $__OUT_NAME == "" ]
  then
    echo "missing output file name. Please provide."
    exit 1
  fi
  
  
  if [ $__IN_NAME = ${__OUT_NAME}_lbry.mp4 ]
  then
    echo "Filenames can't be the same."
    exit
  fi
  __enc_mp4
}

__parse_args "${@}"
__main