/useful/trunk-1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/useful/trunk-1

« back to all changes in this revision

Viewing changes to scripts/enc2firefox.sh

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-13 20:18:48 UTC
  • Revision ID: git-v1:df5c8db5509b9612b896bd2a9fc8b50ee5eedb1e
You can use git on Launchpad too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env bash
2
 
####
 
2
###################
3
3
# FILE NAME: enc2firefox.sh
4
4
#
5
5
# Encodes (mp4/x264) videos so they can be played in firefox.
8
8
# 2020-09-05:
9
9
#   * Removed an eval that made no sense.
10
10
#   * Added FJ mode for those spicy memes.
11
 
#
12
 
# 2021-01-13:
13
 
#   * Fixed up if statments
14
 
#
15
 
# 2024-07-10
16
 
#  * Simplefied if-else-statement.
17
 
#
18
 
####
 
11
####################
 
12
ARGS=()
 
13
ARGS="${@}"
19
14
 
20
 
__IN_NAME=""
21
 
__OUT_NAME=""
 
15
__IN_NAME=
 
16
__OUT_NAME=
22
17
__USE_WEBM=false
23
18
__USE_FJ=false
24
19
 
25
 
__usage () {
 
20
__help () {
26
21
  echo "enc2firefox.sh -- Make Videos Playable in Firefox"
27
22
  echo " "
28
23
  echo "-i <input video file>     Input Video File."
73
68
}
74
69
 
75
70
__parse_args() {
76
 
  if [[ -z "$1" ]]
 
71
  if [ -z "$1" ]
77
72
  then
78
73
    echo "Try --help or -h."
79
74
    exit 1
103
98
      shift
104
99
      ;;
105
100
      -h|--help)
106
 
      __usage
 
101
      __help
107
102
      shift
108
103
      ;;
109
104
      *)
110
 
      __usage
 
105
      __help
111
106
      exit 1
112
107
      shift
113
108
      ;;
120
115
}
121
116
 
122
117
__main () {
123
 
  if [[ ! -e "$__IN_NAME" ]]; then
 
118
  if [ ! -e "$__IN_NAME" ]
 
119
  then
124
120
    echo "missing input audio. Please provide."
125
121
    exit 1
126
122
  fi
127
123
  
128
 
  if [[ $__OUT_NAME == "" ]]; then
 
124
  if [ $__OUT_NAME == "" ]
 
125
  then
129
126
    echo "missing output file name. Please provide."
130
127
    exit 1
131
128
  fi
132
 
 
133
 
  if [[ $__USE_WEBM == true ]]; then
134
 
    if [[ $__IN_NAME == $__OUT_NAME.webm ]]; then
 
129
  
 
130
  
 
131
  if [ $__USE_WEBM = true ]
 
132
  then
 
133
    if [ $__IN_NAME = $__OUT_NAME.webm ]
 
134
    then
135
135
      echo "Filenames can't be the same."
136
136
      exit
137
137
    fi
138
138
    __enc_webm
139
 
  elif [[ $__IN_NAME == $__OUT_NAME.mp4 ]]; then
140
 
    if [[ $__USE_FJ == true ]]; then
141
 
      __enc_fj
142
 
    else
143
 
      __enc_mp4
 
139
  elif [ $__USE_FJ = true ]
 
140
  then
 
141
    if [ $__IN_NAME = $__OUT_NAME.mp4 ]
 
142
    then
 
143
      echo "Filenames can't be the same."
 
144
      exit
144
145
    fi
 
146
    __enc_fj
145
147
  else
146
 
    echo " Input and output files can't be the same."
147
 
    exit
 
148
    if [ $__IN_NAME = $__OUT_NAME.mp4 ]
 
149
    then
 
150
      echo "Filenames can't be the same."
 
151
      exit
 
152
    fi
 
153
    __enc_mp4
148
154
  fi
149
155
}
150
156