Repository navigation
Expand file tree
/
Copy pathrunFfmpeg.sh
More file actions
executable file
·46 lines (40 loc) · 1.52 KB
/
Copy pathrunFfmpeg.sh
File metadata and controls
executable file
·46 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#/bin/bash
if [ "$#" -ne 2 ]; then
echo "runFfmpeg.sh: Opinionated Bash Script to encode a gif and \
the looped alsa interface to a live stream url."
echo " "
echo "USAGE: ./runFfmpeg.sh [input.gif] [fileOfTextToDisplayOnVideo.txt]"
echo " "
else
# Get the passed input files
GIF=$1
STREAM_TEXT_PATH=$2
# Souce our config
source radioFiles/config.sh
# Define our private variables
# KEYINT represents the number of key frames.
# Should be somewhere between 2 to 4.
KEYINT=$(expr $VIDEO_FPS \* 3)
# Run our ffmpeg command
# Draw text on multiple lines
# https://stackoverflow.com/questions/11138832/ffmpeg-multiple-text-in-one-command-drawtext
# Scroll text
ffmpeg -f alsa -ac 2 \
-i hw:Loopback,1,0 -fflags +genpts \
-ignore_loop 0 -r $VIDEO_FPS -i "$GIF" -s $VIDEO_RESOLUTION \
-vf "[in]drawtext= \
text=:'$STREAM_TITLE': \
fontfile=${VIDEO_FONT}: \
fontsize=$FONT_SIZE: \
bordercolor=$FONT_BORDER_COLOR: borderw=1: fontcolor=$FONT_COLOR: \
y=$FONT_TITLE_Y_POS: x=w-mod(max(t\,0)*(w+tw)/$FONT_TITLE_SCROLL_SPEED\,(w+tw)), \
drawtext=fontfile=${VIDEO_FONT}: \
fontsize=$FONT_SIZE: \
fix_bounds=true: \
bordercolor=$FONT_BORDER_COLOR: borderw=1: fontcolor=$FONT_COLOR: \
textfile=$STREAM_TEXT_PATH: y=$FONT_MUSIC_Y_POS: x=$FONT_MUSIC_X_POS[out]" \
-vcodec h264_omx -x264opts keyint=$KEYINT:min-keyint=$KEYINT:scenecut=-1 \
-b:v $VIDEO_BIT_RATE -preset veryfast -pix_fmt yuv420p \
-c:a libfdk_aac -b:a $AUDIO_BIT_RATE -bufsize 960k \
-ar $AUDIO_SAMPLE_RATE -f flv $STREAM_URL
fi