/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 19:03:20 UTC
  • Revision ID: git-v1:5a81e50921d5c2c9c4e9c78d6293500f8de4b319
* pdf2images.sh:
   - Fixed usae message
* process_text_to_image.sh
  - Added sanity check
  - General logic fixes
  - Added --author argument
  - Fixed help message
  - formating.

* wav2mp4
  - minor formating errors
  - added sanity check
  - use /tmp/ instead of current folder for the temporary image

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.
15
19
######
16
20
 
17
 
__TMP_IMAGE_NAME=__SPEAKER_IMAGE.PNG
 
21
__SANITY=true
 
22
 
 
23
# FIXME: Use mktemp or mkdtemp instea of usin /tmp/ directly
 
24
__TMP_IMAGE_NAME=/tmp/__SPEAKER_IMAGE.PNG
18
25
__OUT_NAME=""
19
26
__IN_NAME=""
20
27
 
31
38
  echo "-o <video.mp4>        The output for the video."
32
39
  echo " "
33
40
  echo "--image <image.[png,gif]>"
34
 
  echo "                      Image to use. If non is provided a standard image"
 
41
  echo "                      Image to use. If none is provided a standard image"
35
42
  echo "                      will be used."
36
43
  echo ""
37
 
  exit
 
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
38
66
}
39
67
 
40
68
function __do_cleanup () {
42
70
}
43
71
 
44
72
function __do_convertion_gif () {
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"
 
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"
53
81
}
54
82
 
55
83
function __do_convertion () {
60
88
      __do_convertion_gif
61
89
    ;;
62
90
    *)
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
 
     ;;
 
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
    ;;
71
100
  esac
72
101
}
73
102
 
423
452
 
424
453
 
425
454
function __main () {
426
 
  
 
455
  __sanity_check
 
456
  __parse_args "${@}"
 
457
 
427
458
  if [[ $__USE_DIFFERENT_IMAGE == true ]]
428
459
  then
429
460
    # Let's not make this any more complicated.
444
475
    exit 1
445
476
  fi
446
477
  
447
 
  
448
478
  __do_convertion
449
479
  
450
480
  if [[ $__USE_DIFFERENT_IMAGE == false ]]
453
483
  fi
454
484
}
455
485
 
456
 
__parse_args "${@}"
457
 
__main
 
486
__main "${@}"