Introduction
Introduction Statistics Contact Development Disclaimer Help
brtv-imgs-to-video.sh - bitreich-tv - Meme TV encoding and streaming
git clone git://bitreich.org/bitreich-tv git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfr…
Log
Files
Refs
Tags
LICENSE
---
brtv-imgs-to-video.sh (1698B)
---
1 #!/bin/sh
2 # read hashtags.txt as stdin, download all images, and convert them to v…
3 # requirements: hurl(1), ffmpeg(1), convert(1)
4
5 ### CONFIGURATION START
6
7 # dir to contain images as videos
8 out_dir="/br/gopher/tv/img2vid"
9
10 # ffmpeg flags for generated videos
11 video_ext="webm"
12 ffmpeg_codec="-loglevel error -acodec libopus -b:a 96K -f webm -vf scale…
13
14 # target video resolution
15 video_resolution=1280x720
16
17 # slide style
18 # xc:$color ( https://imagemagick.org/script/color.php )
19 # /some/file.png
20 bgcontent=/br/gopher/tv/bitreich-tv-bg.png
21
22 # show image memes for this duration [s]
23 image_display_time=10
24
25 ### CONFIGURATION END
26
27
28 die() {
29 printf '%s: error: %s\n' "${0##*/}" "$1" >&2
30 exit 1
31 }
32
33 regeximatch() {
34 printf '%s' "$1" | grep -iEq "$2"
35 }
36
37 fit_img_16_9() {
38 convert -resize "$video_resolution" -size "$video_resolution" "$…
39 "$bgcontent" +swap -gravity center -composite "$2"
40 }
41
42 video_from_img() {
43 ffmpeg -y \
44 -f lavfi \
45 -i anullsrc=r=48000 \
46 -i "$1" \
47 -t "${image_display_time}" \
48 $ffmpeg_codec \
49 "$2" < /dev/null
50 }
51
52 mkdir -p "$out_dir"
53
54 # generate video from each image
55 while read -r tag url; do
56 if ! regeximatch "$url" '\.(jpg|jpeg|png|gif)$'; then
57 continue
58 fi
59
60 imgfile="${out_dir}/${url##*/}"
61 out="${imgfile%.*}.${video_ext}"
62
63 if [ ! -f "$out" ]; then
64
65 if [ ! -f "$imgfile" ]; then
66 if ! hurl "$url" > "$imgfile"; then
67 die "hurl could not download $url"
68 fi
69 fi
70
71 if ! regeximatch "$(file -ib "$imgfile")" "^image\/"; th…
72 die "input image $imgfile is invalid ($(file -b …
73 fi
74 fit_img_16_9 "$imgfile" "${out%.*}_16-9.jpg"
75 video_from_img "${out%.${video_ext}}_16-9.jpg" "${out}"
76 printf '%s\n' "$out"
77 fi
78 done
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.