/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/wav2mp4.sh

  • Committer: Gustav Hartvigsson
  • Date: 2024-07-10 14:25:13 UTC
  • Revision ID: git-v1:55fc68b13933a25315ad96a4c69e64d962d2c2d4
Fixed install script's --target flag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
# 2022-03-22:
13
13
#   * Make script work with gifs, and Make gifs loop.
14
14
#
15
 
# 2024-07-10:
16
 
#   * Fixed some formating errors.
17
 
#   * Added sanity check.
18
 
#   * Use /tmp/ instead of writing to FS.
19
15
######
20
16
 
21
 
__SANITY=true
22
 
 
23
 
# FIXME: Use mktemp or mkdtemp instea of usin /tmp/ directly
24
 
__TMP_IMAGE_NAME=/tmp/__SPEAKER_IMAGE.PNG
 
17
__TMP_IMAGE_NAME=__SPEAKER_IMAGE.PNG
25
18
__OUT_NAME=""
26
19
__IN_NAME=""
27
20
 
38
31
  echo "-o <video.mp4>        The output for the video."
39
32
  echo " "
40
33
  echo "--image <image.[png,gif]>"
41
 
  echo "                      Image to use. If none is provided a standard image"
 
34
  echo "                      Image to use. If non is provided a standard image"
42
35
  echo "                      will be used."
43
36
  echo ""
44
 
  exit 0
45
 
}
46
 
 
47
 
function __silent () {
48
 
  $@ >> /dev/null 2>&1
49
 
  return $?
50
 
}
51
 
 
52
 
function __sanity_check () {
53
 
  # Check that we have the tools needed.
54
 
  ___silent which ffmpeg 
55
 
 
56
 
  if [[ $? -gt 0 ]]; then
57
 
    echo "    Can't find tool \"ffmpeg\" (Required)."
58
 
    __SANITY=false
59
 
  fi
60
 
  
61
 
  if [[ $___SANITY == false ]]; then
62
 
    echo "Please install the missing tools."
63
 
    echo ""
64
 
    exit 1
65
 
  fi
 
37
  exit
66
38
}
67
39
 
68
40
function __do_cleanup () {
70
42
}
71
43
 
72
44
function __do_convertion_gif () {
73
 
  ffmpeg\
74
 
         -i "$__IN_NAME"\
75
 
         -ignore_loop 0\
76
 
         -i "$__TMP_IMAGE_NAME"\
77
 
         -c:v libx264 -tune stillimage\
78
 
         -c:a aac -b:a 256k -pix_fmt yuv420p\
79
 
         -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -shortest\
80
 
         "$__OUT_NAME"
 
45
    ffmpeg\
 
46
           -i "$__IN_NAME"\
 
47
           -ignore_loop 0\
 
48
           -i "$__TMP_IMAGE_NAME"\
 
49
           -c:v libx264 -tune stillimage\
 
50
           -c:a aac -b:a 256k -pix_fmt yuv420p\
 
51
           -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -shortest\
 
52
           "$__OUT_NAME"
81
53
}
82
54
 
83
55
function __do_convertion () {
88
60
      __do_convertion_gif
89
61
    ;;
90
62
    *)
91
 
    
92
 
    ffmpeg -loop 1\
93
 
           -i "$__TMP_IMAGE_NAME"\
94
 
           -i "$__IN_NAME"\
95
 
           -c:v libx264 -tune stillimage\
96
 
           -c:a aac -b:a 256k -pix_fmt yuv420p\
97
 
           -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -shortest\
98
 
           "$__OUT_NAME"
99
 
    ;;
 
63
      ffmpeg -loop 1\
 
64
            -i "$__TMP_IMAGE_NAME"\
 
65
            -i "$__IN_NAME"\
 
66
            -c:v libx264 -tune stillimage\
 
67
            -c:a aac -b:a 256k -pix_fmt yuv420p\
 
68
            -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -shortest\
 
69
            "$__OUT_NAME"
 
70
     ;;
100
71
  esac
101
72
}
102
73
 
452
423
 
453
424
 
454
425
function __main () {
455
 
  __sanity_check
456
 
  __parse_args "${@}"
457
 
 
 
426
  
458
427
  if [[ $__USE_DIFFERENT_IMAGE == true ]]
459
428
  then
460
429
    # Let's not make this any more complicated.
475
444
    exit 1
476
445
  fi
477
446
  
 
447
  
478
448
  __do_convertion
479
449
  
480
450
  if [[ $__USE_DIFFERENT_IMAGE == false ]]
483
453
  fi
484
454
}
485
455
 
486
 
__main "${@}"
 
456
__parse_args "${@}"
 
457
__main