/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: 2024-07-21 16:04:22 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20240721160422-e59zjphfbbmwiymp
Added COPYING file with copyright and licencing informaiton information.

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