/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:11:39 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20240721161139-052huagi6gtew3ax
Added copyright information to all files.

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