Changes of Revision 11

ffx264.changes Changed
x
 
1
@@ -1,4 +1,25 @@
2
 -------------------------------------------------------------------
3
+Mon Nov 07 16:25:00 UTC 2016 - neutrino8@opensuse.org
4
+
5
+- Update to version 2.9.5
6
+  * Cosmetics in the code for deinterlacing
7
+  * Instead of skipping FPS conversion if the FPS can't be detected,
8
+    ask the user to provide it
9
+  * Use single brackets instead of double ones in the nosound
10
+    setup code
11
+  * Added license snippet at the top of the script
12
+  * Added support for outputting to additional container formats
13
+  * Do some checking on supported audio codecs for the supported
14
+    containers
15
+  * Check specified container and warn and exit if it's not supported
16
+  * Support setting the FLAC compression level
17
+  * Added h264_mp4toannexb flag in case we're outputting to the AVI
18
+    container
19
+  * Break out of the if conditionals in the audio code and replace
20
+    them with two case statements
21
+  * Update to the README file
22
+  
23
+-------------------------------------------------------------------
24
 Sun Nov 06 09:52:00 UTC 2016 - neutrino8@opensuse.org
25
 
26
 - Update to version 3.1.0
27
ffx264.spec Changed
10
 
1
@@ -17,7 +17,7 @@
2
 
3
 
4
 Name:           ffx264
5
-Version:        3.1.0
6
+Version:        3.1.1
7
 Release:        0
8
 Summary:        A small shell script for encoding to H.264 with ffmpeg
9
 License:        GPL-2.0+
10
ffx264-3.1.0.tar.gz/ChangeLog -> ffx264-3.1.1.tar.gz/ChangeLog Changed
23
 
1
@@ -1,3 +1,21 @@
2
+2016-11-07 - ffx264 3.1.1
3
+   * Cosmetics in the code for deinterlacing
4
+   * Instead of skipping FPS conversion if the FPS can't be detected,
5
+     ask the user to provide it
6
+   * Use single brackets instead of double ones in the nosound
7
+     setup code
8
+   * Added license snippet at the top of the script
9
+   * Added support for outputting to additional container formats
10
+   * Do some checking on supported audio codecs for the supported
11
+     containers
12
+   * Check specified container and warn and exit if it's not supported
13
+   * Support setting the FLAC compression level
14
+   * Added h264_mp4toannexb flag in case we're outputting to the AVI
15
+     container
16
+   * Break out of the if conditionals in the audio code and replace
17
+     them with two case statements
18
+   * Update to the README file
19
+     
20
 2016-11-06 - ffx264 3.1.0
21
    * Bugfix: resampling wasn't working for fdk-aac due to missing
22
      value in the case statement
23
ffx264-3.1.0.tar.gz/README -> ffx264-3.1.1.tar.gz/README Changed
9
 
1
@@ -27,6 +27,7 @@
2
 - it supports cover art for the MKV container.
3
 - it supports the x264 presets and tune profiles.
4
 - it supports custom written preset files.
5
+- it can output to more than one container.
6
 
7
 Parameters:
8
 
9
ffx264-3.1.0.tar.gz/ffx264 -> ffx264-3.1.1.tar.gz/ffx264 Changed
714
 
1
@@ -2,15 +2,28 @@
2
 #
3
 # Small script to encode to H.264/AVC video using FFmpeg and libx264.
4
 # Author: Grozdan "microchip" Nikolov <neutrino8@opensuse.org>
5
-# Version: 3.1.0
6
-# Date: 2016-11-06
7
-# License: GNU GPLv2+
8
+# Version: 3.1.1
9
+# Date: 2016-11-07
10
+#
11
+# ffx264 is free software ; you can redistribute it and/or modify
12
+# it under the terms of the GNU General Public License as published by
13
+# the Free Software Foundation ; either version 2 of the License, or
14
+# (at your option) any later version.
15
+#
16
+# ffx264 is distributed in the hope that it will be useful,
17
+# but WITHOUT ANY WARRANTY ; without even the implied warranty of
18
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+# GNU General Public License for more details.
20
+#
21
+# You should have received a copy of the GNU General Public License
22
+# along with this program ; if not, write to the Free Software
23
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24
 
25
 green() { echo -e "\e[1;32m$1\e[0;39;49m"; }
26
 brown() { echo -e "\e[0;33m$1\e[0;39;49m"; }
27
 error() { echo -e "\e[1;31m$1\e[0;39;49m"; }
28
 
29
-version="3.1.0"
30
+version="3.1.1"
31
 
32
 CFG="$HOME/.ffx264"
33
 cfgversion="24"
34
@@ -356,11 +369,68 @@
35
        read confmt
36
        test -z "$confmt" && CON="mkv" || CON="$confmt"
37
    fi
38
+   
39
    CON="$(echo "$CON" | tr '[:upper:]' '[:lower:]')"
40
+   
41
    case "$CON" in
42
        mp4|m4v|mov)    movflags="-movflags +faststart" ;;
43
+       avi)        annexb="-bsf:v h264_mp4toannexb" ;;
44
+       mkv)        true ;;
45
+       *)
46
+       error "-> H.264 video not supported by chosen container!"
47
+       error "-> Supported containers are: mkv, mp4, mov, m4v and avi"
48
+       error "-> Check your config file, if needed, in '$CFG'"
49
+       exit 1
50
+       ;;
51
    esac
52
    
53
+   printf "Output to Additional Container Formats? [y/N]: "
54
+   read acf
55
+   if [ "$acf" = "y" -o "$acf" = "Y" ]; then
56
+       printf "Specify the Container Formats [example: mp4,mov,avi - press 'Enter' to skip]: "
57
+       read econ
58
+       test ! -z "$econ" && extracon="$(echo "$econ" | sed 's|,| |g' | tr '[:upper:]' '[:lower:]')"
59
+       if [ ! -z "$extracon" ]; then
60
+           for i in $extracon; do
61
+               if [ "$i" = "$CON" ]; then
62
+                   error "-> Additional container matches the main output container!"
63
+                   exit 1
64
+               fi
65
+               case "$i" in
66
+                   mkv|mp4|mov|m4v|avi) true ;;
67
+                   *)
68
+                   error "-> H.264 video not supported by the $i container!"
69
+                   error "-> Supported containers are: mkv, mp4, mov, m4v and avi"
70
+                   exit 1
71
+                   ;;
72
+               esac
73
+               echo
74
+               case "$i" in
75
+                   mkv)
76
+                   green "-> Note: additional container $i supports all the audio codecs"
77
+                   ;;
78
+                   mp4)
79
+                   green "-> Note: additional container $i supports the following audio codecs:"
80
+                   green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|copy|nosound"
81
+                   ;;
82
+                   mov)
83
+                   green "-> Note: additional container $i supports the following audio codecs:"
84
+                   green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|flac|copy|nosound"
85
+                   ;;
86
+                   m4v)
87
+                   green "-> Note: additional container $i supports the following audio codecs:"
88
+                   green "-> ac3|aac|fdk-aac|copy|nosound"
89
+                   ;;
90
+                   avi)
91
+                   green "-> Note: additional container $i supports the following audio codecs:"
92
+                   green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|pcm|flac|copy|nosound"
93
+                   ;;
94
+               esac
95
+           done
96
+           echo
97
+       fi
98
+   fi
99
+   
100
    OUTPUT="$OUTPUT.$CON"
101
    
102
    test -e "$OUTPUT" && mv -f "$OUTPUT" "$OUTPUT.old"
103
@@ -529,8 +599,8 @@
104
    esac
105
    green "-> Detected $fparity Parity"
106
    if [ "$fp" = "progressive" ]; then
107
-       error "-> Your file appears to be progressive but"
108
-       error "   this may be a misdetection!"
109
+       error "-> The video stream appears to be progressive"
110
+       error "   but this may be a misdetection!"
111
    elif [ "$fp" = "???" ]; then
112
        error "-> Could not detect the Field Parity!"
113
    fi
114
@@ -577,16 +647,15 @@
115
            video_fps_func
116
            if [ ! -z "$GETFPS" ]; then
117
                FPS1="$(echo "$GETFPS" | awk -F/ '{print $1}')"
118
-               FPS2="$(echo "$GETFPS"| awk -F/ '{print $2}')"
119
+               FPS2="$(echo "$GETFPS" | awk -F/ '{print $2}')"
120
                OFPS="$(($FPS1*2))/$FPS2"
121
                green "-> Detected: $FPS1/$FPS2 FPS"
122
                green "-> Setting output FPS to: $OFPS"
123
-               echo
124
                ofps="-r $OFPS"
125
            else
126
                error "-> Could not detect the FPS value!"
127
-               echo
128
            fi
129
+           echo
130
            video_deinterlace_func bob
131
            bob="1"
132
            ;;
133
@@ -752,7 +821,7 @@
134
            sleep 1
135
            video_fps_func
136
            if [ ! -z "$GETFPS" ]; then
137
-               green "-> Detected: $GETFPS FPS"
138
+               green "-> Detected $GETFPS FPS"
139
            else
140
                error "-> Could not detect the FPS value!"
141
            fi
142
@@ -762,141 +831,147 @@
143
                echo
144
                error "-> Detected FPS is not supported yet!"
145
                error "-> Supported FPS are: 24/1, 25/1, 24000/1001 and 30000/1001"
146
-               error "-> Skipping FPS conversion!"
147
-               skipfps="1"
148
+               echo
149
+               printf "Specify the FPS value of the Input File [no default!]: "
150
+               read infps
151
+               case "$infps" in
152
+                   24/1|25/1|24000/1001|30000/1001) true ;;
153
+                   ""|*)
154
+                   error "-> No value or unsupported value given!"
155
+                   exit 1
156
+                   ;;
157
+               esac
158
                ;;
159
            esac
160
            echo
161
-           if [ -z "$skipfps" ]; then
162
-               brown " FPS Conversion Filters"
163
-               brown " ~~~~~~~~~~~~~~~~~~~~~~"
164
-               echo " 0 -> fps (converts by duplicating/dropping of frames)"
165
-               echo " 1 -> setpts + atempo (converts by PTS + audio speedup/down)"
166
-               echo
167
-               printf "Specify the FPS conversion method [default is 0]: "
168
-               read fcm
169
+           brown " FPS Conversion Filters"
170
+           brown " ~~~~~~~~~~~~~~~~~~~~~~"
171
+           echo " 0 -> fps (converts by duplicating/dropping of frames)"
172
+           echo " 1 -> setpts + atempo (converts by PTS + audio speedup/down)"
173
+           echo
174
+           printf "Specify the FPS conversion method [default is 0]: "
175
+           read fcm
176
+           case "$fcm" in
177
+               0|1|"") true ;;
178
+               *)
179
+               error "-> Invalid option!"
180
+               exit 1
181
+               ;;
182
+           esac
183
+           echo
184
+           brown " NTSC <-> PAL and NTSC <-> NTSC FPS Conversion"
185
+           brown " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
186
+           echo " 0 --> 23.976 FPS (24000/1001) to 24 FPS"
187
+           echo " 1 --> 23.976 FPS (24000/1001) to 25 FPS"
188
+           echo " 2 --> 23.976 FPS (24000/1001) to 29.970 FPS"
189
+           echo
190
+           echo " 3 --> 24 FPS to 23.976 FPS (24000/1001)"
191
+           echo " 4 --> 24 FPS to 25 FPS"
192
+           echo " 5 --> 24 FPS to 29.970 FPS (30000/1001)"
193
+           echo
194
+           echo " 6 --> 25 FPS to 23.976 FPS (24000/1001)"
195
+           echo " 7 --> 25 FPS to 24 FPS"
196
+           echo " 8 --> 25 FPS to 29.970 FPS (30000/1001)"
197
+           echo
198
+           echo " 9 --> 29.970 FPS (30000/1001) to 23.976 FPS (24000/1001)"
199
+           echo " 10 -> 29.970 FPS (30000/1001) to 24 FPS"
200
+           echo " 11 -> 29.970 FPS (30000/1001) to 25 FPS"
201
+           echo
202
+           printf "Specify the FPS Conversion option [press 'Enter' to skip]: "
203
+           read fpsopt
204
+           case "$fpsopt" in
205
+               0)
206
                case "$fcm" in
207
-                   0|1|"") true ;;
208
-                   *)
209
-                   error "-> Invalid option!"
210
-                   exit 1
211
-                   ;;
212
+                   0|"")   fps="fps=fps=24," ;;
213
+                   1)  setpts="setpts=23976/24000*PTS,"; atempo="atempo=1.001001001," ;;
214
                esac
215
-               echo
216
-               brown " NTSC <-> PAL and NTSC <-> NTSC FPS Conversion"
217
-               brown " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
218
-               echo " 0 --> 23.976 FPS (24000/1001) to 24 FPS"
219
-               echo " 1 --> 23.976 FPS (24000/1001) to 25 FPS"
220
-               echo " 2 --> 23.976 FPS (24000/1001) to 29.970 FPS"
221
-               echo
222
-               echo " 3 --> 24 FPS to 23.976 FPS (24000/1001)"
223
-               echo " 4 --> 24 FPS to 25 FPS"
224
-               echo " 5 --> 24 FPS to 29.970 FPS (30000/1001)"
225
-               echo
226
-               echo " 6 --> 25 FPS to 23.976 FPS (24000/1001)"
227
-               echo " 7 --> 25 FPS to 24 FPS"
228
-               echo " 8 --> 25 FPS to 29.970 FPS (30000/1001)"
229
-               echo
230
-               echo " 9 --> 29.970 FPS (30000/1001) to 23.976 FPS (24000/1001)"
231
-               echo " 10 -> 29.970 FPS (30000/1001) to 24 FPS"
232
-               echo " 11 -> 29.970 FPS (30000/1001) to 25 FPS"
233
-               echo
234
-               printf "Specify the FPS Conversion option [press 'Enter' to skip]: "
235
-               read fpsopt
236
-               case "$fpsopt" in
237
-                   0)
238
-                   case "$fcm" in
239
-                       0|"")   fps="fps=fps=24," ;;
240
-                       1)  setpts="setpts=23976/24000*PTS,"; atempo="atempo=1.001001001," ;;
241
-                   esac
242
-                   ofps="-r 24/1"
243
-                   ;;
244
-                   1)
245
-                   case "$fcm" in
246
-                       0|"")   fps="fps=fps=25," ;;
247
-                       1)  setpts="setpts=23976/25000*PTS,"; atempo="atempo=1.04270937604270937604," ;;
248
-                   esac
249
-                   ofps="-r 25/1"
250
-                   ;;
251
-                   2)
252
-                   case "$fcm" in
253
-                       0|"")   fps="fps=fps=30000/1001," ;;
254
-                       1)  setpts="setpts=23976/29970*PTS,"; atempo="atempo=1.25," ;;
255
-                   esac
256
-                   ofps="-r 30000/1001"
257
-                   ;;
258
-                   3)
259
-                   case "$fcm" in
260
-                       0|"")   fps="fps=fps=24000/1001," ;;
261
-                       1)  setpts="setpts=24000/23976*PTS,"; atempo="atempo=0.999," ;;
262
-                   esac
263
-                   ofps="-r 24000/1001"
264
-                   ;;
265
-                   4)
266
-                   case "$fcm" in
267
-                       0|"")   fps="fps=fps=25," ;;
268
-                       1)  setpts="setpts=24000/25000*PTS,"; atempo="atempo=1.04166666667," ;;
269
-                   esac
270
-                   ofps="-r 25/1"
271
-                   ;;
272
-                   5)
273
-                   case "$fcm" in
274
-                       0|"")   fps="fps=fps=30000/1001," ;;
275
-                       1)  setpts="setpts=24000/29970*PTS,"; atempo="atempo=1.24875," ;;
276
-                   esac
277
-                   ofps="-r 30000/1001"
278
-                   ;;
279
-                   6)
280
-                   case "$fcm" in
281
-                       0|"")   fps="fps=fps=24000/1001," ;;
282
-                       1)  setpts="setpts=25000/23976*PTS,"; atempo="atempo=0.95904," ;;
283
-                   esac
284
-                   ofps="-r 24000/1001"
285
-                   ;;
286
-                   7)
287
-                   case "$fcm" in
288
-                       0|"")   fps="fps=fps=24," ;;
289
-                       1)  setpts="setpts=25000/24000*PTS,"; atempo="atempo=0.96," ;;
290
-                   esac
291
-                   ofps="-r 24/1"
292
-                   ;;
293
-                   8)
294
-                   case "$fcm" in
295
-                       0|"")   fps="fps=fps=30000/1001," ;;
296
-                       1)  setpts="setpts=25000/29970*PTS,"; atempo="atempo=1.1988," ;;
297
-                   esac
298
-                   ofps="-r 30000/1001"
299
-                   ;;
300
-                   9)
301
-                   case "$fcm" in
302
-                       0|"")   fps="fps=fps=24000/1001," ;;
303
-                       1)  setpts="setpts=29970/23976*PTS,"; atempo="atempo=0.8," ;;
304
-                   esac
305
-                   ofps="-r 24000/1001"
306
-                   ;;
307
-                   10)
308
-                   case "$fcm" in
309
-                       0|"")   fps="fps=fps=24," ;;
310
-                       1)  setpts="setpts=29970/24000*PTS,"; atempo="atempo=0.800800800801," ;;
311
-                   esac
312
-                   ofps="-r 24/1"
313
-                   ;;
314
-                   11)
315
-                   case "$fcm" in
316
-                       0|"")   fps="fps=fps=25," ;;
317
-                       1)  setpts="setpts=29970/25000*PTS,"; atempo="atempo=0.83416750083416750083," ;;
318
-                   esac
319
-                   ofps="-r 25/1"
320
-                   ;;
321
-                   "")
322
-                   true
323
-                   ;;
324
-                   *)
325
-                   error "-> Invalid option!"
326
-                   exit 1
327
-                   ;;
328
+               ofps="-r 24/1"
329
+               ;;
330
+               1)
331
+               case "$fcm" in
332
+                   0|"")   fps="fps=fps=25," ;;
333
+                   1)  setpts="setpts=23976/25000*PTS,"; atempo="atempo=1.04270937604270937604," ;;
334
                esac
335
-           fi
336
+               ofps="-r 25/1"
337
+               ;;
338
+               2)
339
+               case "$fcm" in
340
+                   0|"")   fps="fps=fps=30000/1001," ;;
341
+                   1)  setpts="setpts=23976/29970*PTS,"; atempo="atempo=1.25," ;;
342
+               esac
343
+               ofps="-r 30000/1001"
344
+               ;;
345
+               3)
346
+               case "$fcm" in
347
+                   0|"")   fps="fps=fps=24000/1001," ;;
348
+                   1)  setpts="setpts=24000/23976*PTS,"; atempo="atempo=0.999," ;;
349
+               esac
350
+               ofps="-r 24000/1001"
351
+               ;;
352
+               4)
353
+               case "$fcm" in
354
+                   0|"")   fps="fps=fps=25," ;;
355
+                   1)  setpts="setpts=24000/25000*PTS,"; atempo="atempo=1.04166666667," ;;
356
+               esac
357
+               ofps="-r 25/1"
358
+               ;;
359
+               5)
360
+               case "$fcm" in
361
+                   0|"")   fps="fps=fps=30000/1001," ;;
362
+                   1)  setpts="setpts=24000/29970*PTS,"; atempo="atempo=1.24875," ;;
363
+               esac
364
+               ofps="-r 30000/1001"
365
+               ;;
366
+               6)
367
+               case "$fcm" in
368
+                   0|"")   fps="fps=fps=24000/1001," ;;
369
+                   1)  setpts="setpts=25000/23976*PTS,"; atempo="atempo=0.95904," ;;
370
+               esac
371
+               ofps="-r 24000/1001"
372
+               ;;
373
+               7)
374
+               case "$fcm" in
375
+                   0|"")   fps="fps=fps=24," ;;
376
+                   1)  setpts="setpts=25000/24000*PTS,"; atempo="atempo=0.96," ;;
377
+               esac
378
+               ofps="-r 24/1"
379
+               ;;
380
+               8)
381
+               case "$fcm" in
382
+                   0|"")   fps="fps=fps=30000/1001," ;;
383
+                   1)  setpts="setpts=25000/29970*PTS,"; atempo="atempo=1.1988," ;;
384
+               esac
385
+               ofps="-r 30000/1001"
386
+               ;;
387
+               9)
388
+               case "$fcm" in
389
+                   0|"")   fps="fps=fps=24000/1001," ;;
390
+                   1)  setpts="setpts=29970/23976*PTS,"; atempo="atempo=0.8," ;;
391
+               esac
392
+               ofps="-r 24000/1001"
393
+               ;;
394
+               10)
395
+               case "$fcm" in
396
+                   0|"")   fps="fps=fps=24," ;;
397
+                   1)  setpts="setpts=29970/24000*PTS,"; atempo="atempo=0.800800800801," ;;
398
+               esac
399
+               ofps="-r 24/1"
400
+               ;;
401
+               11)
402
+               case "$fcm" in
403
+                   0|"")   fps="fps=fps=25," ;;
404
+                   1)  setpts="setpts=29970/25000*PTS,"; atempo="atempo=0.83416750083416750083," ;;
405
+               esac
406
+               ofps="-r 25/1"
407
+               ;;
408
+               "")
409
+               true
410
+               ;;
411
+               *)
412
+               error "-> Invalid option!"
413
+               exit 1
414
+               ;;
415
+           esac
416
        fi
417
    fi
418
 fi
419
@@ -904,7 +979,7 @@
420
 ################ Subs stuff #################
421
 
422
 if [ "$SUBS" = "y" ]; then
423
-   test -z "$skipfps" && echo
424
+   echo
425
    green "-> Detecting subtitles..."
426
    sleep 1
427
    SUBSDETECT="$($FFPROBE -i "$input" 2>&1 | grep 'Stream #' | grep 'Subtitle' | sed 's|    ||g')"
428
@@ -946,7 +1021,7 @@
429
 
430
 ################ Audio stuff ################
431
 
432
-test -z "$skipfps" && echo
433
+echo
434
 green "-> Detecting audio tracks..."
435
 echo
436
 sleep 1
437
@@ -1071,6 +1146,8 @@
438
            flac)
439
            acdc[i]="flac"
440
            ameta[i]="FLAC"
441
+           abropts[i]="0-8"
442
+           abrdef[i]="5"
443
            skiptfs="1"
444
            ;;
445
            pcm)
446
@@ -1099,7 +1176,7 @@
447
            abitrate[1]="0"
448
            # nosound takes precedence so
449
            # clear any audio options given
450
-           if [[ $i -ge 2 ]]; then
451
+           if [ $i -ge 2 ]; then
452
                for t in $(eval echo "{2..$MAX_AUD_TRACKS}"); do
453
                    audparams[t]=
454
                    auddis[t]=
455
@@ -1112,21 +1189,39 @@
456
            exit 1
457
            ;;
458
        esac
459
-       
460
-       if [ "$CON" != "mkv" ]; then
461
+
462
+       case "$CON" in
463
+           mp4)
464
            case "${acodec[i]}" in
465
-               opus|flac)
466
-               error "-> $(echo "${acodec[i]}" | tr '[:lower:]' '[:upper:]') is only supported by the MKV container!"
467
+               pcm|opus|flac)
468
+               error "-> $(echo "${acodec[i]}" | tr '[:lower:]' '[:upper:]') is not supported by the MP4 container!"
469
                error "-> Check your config file, if needed, in '$CFG'"
470
                exit 1
471
                ;;
472
            esac
473
-       fi
474
-       case "$CON" in
475
-           mp4|m4v|mov|ogv)
476
+           ;;
477
+           mov)
478
+           case "${acodec[i]}" in
479
+               pcm|opus)
480
+               error "-> $(echo "${acodec[i]}" | tr '[:lower:]' '[:upper:]') is not supported by the MOV container!"
481
+               error "-> Check your config file, if needed, in '$CFG'"
482
+               exit 1
483
+               ;;
484
+           esac
485
+           ;;
486
+           m4v)
487
+           case "${acodec[i]}" in
488
+               eac3|dts|vorbis|flac|pcm|opus)
489
+               error "-> $(echo "${acodec[i]}" | tr '[:lower:]' '[:upper:]') is not supported by the M4V container!"
490
+               error "-> Check your config file, if needed, in '$CFG'"
491
+               exit 1
492
+               ;;
493
+           esac
494
+           ;;
495
+           avi)
496
            case "${acodec[i]}" in
497
-               dts|pcm)
498
-               error "-> DTS and PCM are not supported by the MP4/M4V/MOV/OGV container!"
499
+               opus)
500
+               error "-> $(echo "${acodec[i]}" | tr '[:lower:]' '[:upper:]') is not supported by the AVI container!"
501
                error "-> Check your config file, if needed, in '$CFG'"
502
                exit 1
503
                ;;
504
@@ -1135,45 +1230,52 @@
505
        esac
506
        
507
        if [ "${acodec[i]}" != "copy" ]; then
508
-           if [ "${acodec[i]}" != "flac" ]; then
509
-               if [ "${acodec[i]}" != "pcm" ]; then
510
-                   case "${acodec[i]}" in
511
-                       fdk*)
512
-                       printf "Track $i: Which AAC Profile to Use? [LC/HE/HEv2 - default is LC]: "
513
-                       read aprof[i]
514
-                       case "${aprof[i]}" in
515
-                           lc|LC|"")   ameta[i]="LC-AAC"; aacprof[i]="aac_low" ;;
516
-                           he|HE)      ameta[i]="HE-AACv1"; aacprof[i]="aac_he" ;;
517
-                           hev2|HEv2|HEV2) ameta[i]="HE-AACv2"; aacprof[i]="aac_he_v2" ;;
518
-                           *)
519
-                           error "- Invalid AAC profile!"
520
-                           exit 1
521
-                           ;;
522
-                       esac
523
-                       audprofile[i]="-profile:a:${audmapval[i]} ${aacprof[i]} -afterburner:a:${audmapval[i]} 1"
524
-                       ;;
525
-                   esac
526
-                   printf "Track $i: Specify the Audio Bitrate in kbps [${abropts[i]} - default is ${abrdef[i]}]: "
527
-                   read abr[i]
528
-                   test -z "${abr[i]}" && abitrate[i]="${abrdef[i]}k" || abitrate[i]="${abr[i]}k"
529
-                   audbtr[i]="-b:a:${audmapval[i]} ${abitrate[i]}"
530
-                   abtrmeta[i]="@ $(echo "${abitrate[i]}" | sed 's|k||') kbps"
531
-               else
532
-                   printf "Track $i: Which PCM Bit Depth to use? [16/24/32 - default is 24]: "
533
-                   read pcmbd[i]
534
-                   case "${pcmbd[i]}" in
535
-                       16) acdc[i]="pcm_s16le"; abtrmeta[i]="(16 bit)" ;;
536
-                       24|"")  acdc[i]="pcm_s24le"; abtrmeta[i]="(24 bit)" ;;
537
-                       32) acdc[i]="pcm_s32le"; abtrmeta[i]="(32 bit)" ;;
538
-                       *)
539
-                       error "-> Unsupported PCM Bit Depth!"
540
-                       exit 1
541
-                       ;;
542
-                   esac
543
-               fi
544
-           else
545
-               abtrmeta[i]="(Lossless)"
546
-           fi
547
+           case "${acodec[i]}" in
548
+               fdk*)
549
+               printf "Track $i: Which AAC Profile to Use? [LC/HE/HEv2 - default is LC]: "
550
+               read aprof[i]
551
+               case "${aprof[i]}" in
552
+                   lc|LC|"")   ameta[i]="LC-AAC"; aacprof[i]="aac_low" ;;
553
+                   he|HE)      ameta[i]="HE-AACv1"; aacprof[i]="aac_he" ;;
554
+                   hev2|HEv2|HEV2) ameta[i]="HE-AACv2"; aacprof[i]="aac_he_v2" ;;
555
+                   *)
556
+                   error "- Invalid AAC profile!"
557
+                   exit 1
558
+                   ;;
559
+               esac
560
+               audprofile[i]="-profile:a:${audmapval[i]} ${aacprof[i]} -afterburner:a:${audmapval[i]} 1"
561
+               ;;
562
+               flac)
563
+               printf "Track $i: Specify the FLAC Compression Level [${abropts[i]} - default is ${abrdef[i]}]: "
564
+               read abr[i]
565
+               test -z "${abr[i]}" && acomplevel[i]="${abrdef[i]}" || acomplevel[i]="${abr[i]}"
566
+               audcomplevel[i]="-compression_level:a:${audmapval[i]} ${acomplevel[i]}"
567
+               abtrmeta[i]="@ CL ${acomplevel[i]}"
568
+               ;;
569
+               pcm)
570
+               printf "Track $i: Which PCM Bit Depth to use? [16/24/32 - default is 24]: "
571
+               read pcmbd[i]
572
+               case "${pcmbd[i]}" in
573
+                   16) acdc[i]="pcm_s16le"; abtrmeta[i]="(16 bit)" ;;
574
+                   24|"")  acdc[i]="pcm_s24le"; abtrmeta[i]="(24 bit)" ;;
575
+                   32) acdc[i]="pcm_s32le"; abtrmeta[i]="(32 bit)" ;;
576
+                   *)
577
+                   error "-> Unsupported PCM Bit Depth!"
578
+                   exit 1
579
+                   ;;
580
+               esac
581
+               ;;
582
+           esac
583
+           
584
+           case "${acodec[i]}" in
585
+               ac3|eac3|dts|aac|fdk*|mp3|vorbis|opus|"")
586
+               printf "Track $i: Specify the Audio Bitrate in kbps [${abropts[i]} - default is ${abrdef[i]}]: "
587
+               read abr[i]
588
+               test -z "${abr[i]}" && abitrate[i]="${abrdef[i]}k" || abitrate[i]="${abr[i]}k"
589
+               audbtr[i]="-b:a:${audmapval[i]} ${abitrate[i]}"
590
+               abtrmeta[i]="@ $(echo "${abitrate[i]}" | sed 's|k||') kbps"
591
+               ;;
592
+           esac
593
            
594
            case "${acodec[i]}" in
595
                ac3|eac3|dts|"")        chanrange[i]="1-6"; defchan[i]="6" ;;
596
@@ -1186,6 +1288,7 @@
597
                esac
598
                ;;
599
            esac
600
+           
601
            printf "Track $i: How many Channels to Encode? [${chanrange[i]} - default is ${defchan[i]}]: "
602
            read achan[i]
603
            test -z "${achan[i]}" && ach[i]="${defchan[i]}" || ach[i]="${achan[i]}"
604
@@ -1405,11 +1508,65 @@
605
            test ! -z "${afilters[i]}" && audfilters[i]="-filter:a:${audmapval[i]} ${afilters[i]}"
606
        fi
607
        
608
-       audparams[i]="${audmap[i]} -c:a:${audmapval[i]} ${acdc[i]} ${audprofile[i]} ${audbtr[i]} ${audchan[i]} ${audfilters[i]} ${audlang[i]} ${audmeta[i]}"
609
+       audparams[i]="${audmap[i]} -c:a:${audmapval[i]} ${acdc[i]} ${audprofile[i]} ${audcomplevel[i]} ${audbtr[i]} ${audchan[i]} ${audfilters[i]} ${audlang[i]} ${audmeta[i]}"
610
        
611
    fi
612
 done
613
 
614
+if [ ! -z "$extracon" ]; then
615
+   formats_url="https://en.wikipedia.org/wiki/Comparison_of_video_container_formats#Formats_supported"
616
+   for i in $extracon; do
617
+       case "$i" in
618
+           # MKV is missing from the list since it supports
619
+           # all the supported audio codecs by the script
620
+           mp4)
621
+           for a in $(eval echo "{1..$MAX_AUD_TRACKS}"); do
622
+               case "${acodec[a]}" in
623
+                   pcm|opus|flac)
624
+                   error "-> Additional container $i does not support ${acodec[a]} audio!"
625
+                   error "-> See: $formats_url"
626
+                   exit 1
627
+                   ;;
628
+               esac
629
+           done
630
+           ;;
631
+           mov)
632
+           for a in $(eval echo "{1..$MAX_AUD_TRACKS}"); do
633
+               case "${acodec[a]}" in
634
+                   pcm|opus)
635
+                   error "-> Additional container $i does not support ${acodec[a]} audio!"
636
+                   error "-> See: $formats_url"
637
+                   exit 1
638
+                   ;;
639
+               esac
640
+           done
641
+           ;;
642
+           m4v)
643
+           for a in $(eval echo "{1..$MAX_AUD_TRACKS}"); do
644
+               case "${acodec[a]}" in
645
+                   eac3|dts|vorbis|flac|pcm|opus)
646
+                   error "-> Additional container $i does not support ${acodec[a]} audio!"
647
+                   error "-> See: $formats_url"
648
+                   exit 1
649
+                   ;;
650
+               esac
651
+           done
652
+           ;;
653
+           avi)
654
+           for a in $(eval echo "{1..$MAX_AUD_TRACKS}"); do
655
+               case "${acodec[a]}" in
656
+                   opus)
657
+                   error "-> Additional container $i does not support ${acodec[a]} audio!"
658
+                   error "-> See: $formats_url"
659
+                   exit 1
660
+                   ;;
661
+               esac
662
+           done
663
+           ;;
664
+       esac
665
+   done
666
+fi
667
+
668
 if [ ! -z "$skipsetpts" ]; then
669
    echo
670
    error "-> FPS conversion with the 'setpts' and 'atempo' filters has"
671
@@ -1494,7 +1651,7 @@
672
 case "$mode" in
673
    1p) pass="1-pass" ;;
674
    2p) pass="2-pass" ;;
675
-   *|"")   pass="CRF"; mode="crf" ;;
676
+   crf|"") pass="CRF"; mode="crf" ;;
677
 esac
678
 
679
 echo
680
@@ -1510,7 +1667,7 @@
681
    case "$1" in
682
        1p|crf)
683
        test "$mode" = "1p" && pmode="bitrate=$vbitrate" || pmode="crf=$CRF"
684
-       OPTS1="-map 0:0 -disposition:v:0 default $ofps $NOSUBS $MDATA $CHPS $METATITLE $METAGENRE $METAYEAR $METACOMMENT $vfilters $sws"
685
+       OPTS1="-map 0:0 -disposition:v:0 default $ofps $annexb $NOSUBS $MDATA $CHPS $METATITLE $METAGENRE $METAYEAR $METACOMMENT $vfilters $sws"
686
        OPTS2="${audparams[*]} ${auddis[*]} ${subcopy[*]} ${subdis[*]} $strict $movflags $METACOVER \"$OUTPUT\""
687
        ;;
688
        2p)
689
@@ -1518,7 +1675,7 @@
690
        passtwo="stats=\"$OUTFILE.log\":pass=2:bitrate=$vbitrate"
691
        OPTS1="-map 0:0"
692
        OPTS2="-an -f null -y /dev/null"
693
-       OPTS3="-map 0:0 -disposition:v:0 default $ofps $NOSUBS $MDATA $CHPS $METATITLE $METAGENRE $METAYEAR $METACOMMENT $vfilters $sws"
694
+       OPTS3="-map 0:0 -disposition:v:0 default $ofps $annexb $NOSUBS $MDATA $CHPS $METATITLE $METAGENRE $METAYEAR $METACOMMENT $vfilters $sws"
695
        OPTS4="${audparams[*]} ${auddis[*]} ${subcopy[*]} ${subdis[*]} $strict $movflags $METACOVER \"$OUTPUT\""
696
        ;;
697
    esac
698
@@ -1535,6 +1692,15 @@
699
 echo "" >> "$OUTFILE.sh"
700
 encoder_func $mode >> "$OUTFILE.sh"
701
 echo "" >> "$OUTFILE.sh"
702
+if [ ! -z "$extracon" ]; then
703
+   for i in $extracon; do
704
+       case "$i" in
705
+           avi)    echo "$FFMPEG -i \"$OUTPUT\" -map 0 -c copy -bsf:v h264_mp4toannexb \"${OUTPUT%.*}.$i\"" >> "$OUTFILE.sh" ;;
706
+           *)  echo "$FFMPEG -i \"$OUTPUT\" -map 0 -c copy \"${OUTPUT%.*}.$i\"" >> "$OUTFILE.sh" ;;
707
+       esac
708
+       echo "" >> "$OUTFILE.sh"
709
+   done
710
+fi
711
 chmod +x "$OUTFILE.sh"
712
 
713
 source "$OUTFILE.sh"
714