= Transcoding-Kommandos
Angenommen es trifft irgend eine 1920x1080 Quelle auf ''rtmp://live.ber.c3voc.de/stream/s2'' auf, muss dieser Quellstream in die anderen Stream-Formate umgerechnet werden. In der Vergangenheit (SD) haben wir das alles auf live.ber gemacht – inzwischen (HD) gibt es dafür [[hardware:reencoder|speedy und tweety]]. Die beiden erreicht man **per VPN** via ''speedy.lan.c3voc.de'' bzw. ''tweety.lan.c3voc.de''. Im home von voc liegt für jeden Quellstream ein Skript ''transcoding_sX.sh'' das eine neue tmux Session mit einem Window pro Transcoding Kommando startet. Mehr als drei HD Quellstreams pro Rechner sind mit der aktuellen Konfiguration nicht möglich -> Transcoding Prozesse entsprechend auf die Rechner verteilen.
ssh voc@speedy.lan.c3voc.de
tmux list-sessions
tmux attach-session -t s2
#or
tmux
./transcoding_s2.sh
Beispiel-Skript für Quelle s2
#!/bin/sh
TMUX_BIN=`command -v tmux`
# Only uncomment for Fritz
RAW_MASTER_URL=rtmp://live.ber.c3voc.de:1935/stream/s2_native_hd
SD_URL=rtmp://live.ber.c3voc.de:1935/stream/s2_native_sd
HD_URL=rtmp://live.ber.c3voc.de:1935/stream/s2_native_hd
METADATA='-metadata title="VOC Room 2"'
OPUS="while sleep 1; do ffmpeg -re -y -i $SD_URL -vn -c:a libopus -ac 2 -b:a 64k -vbr off -f ogg - | oggfwd live.ber.c3voc.de 8000 XXXX /s2_native.opus; done"
MP3="while sleep 1; do ffmpeg -re -i $SD_URL -vn -c:a libmp3lame -ac 2 -b:a 96k -y -f mp3 - | oggfwd -3 live.ber.c3voc.de 8000 XXXX /s2_native.mp3; done"
WEBM_SD="while sleep 1; do ffmpeg -re -y -i $SD_URL -aspect 16:9 -threads:0 0 -fflags +genpts -flags +global_header -c:v libvpx -g 75 -keyint_min 75 -deadline realtime -b:v 800k -ac 2 -maxrate:a 96k -c:v libvpx -c:a libvorbis -f webm - | /usr/local/bin/mse_webm_remuxer -cm 2000 - - | oggfwd -w live.ber.c3voc.de 8000 XXXX /s2_native_sd.webm; done"
WEBM_HD="while sleep 1; do ffmpeg -re -y -i $HD_URL -aspect 16:9 -threads:0 0 -fflags +genpts -flags +global_header -c:v libvpx -g 75 -keyint_min 75 -deadline realtime -b:v 2800k -ac 2 -maxrate:a 96k -c:v libvpx -c:a libvorbis -f webm - | /usr/local/bin/mse_webm_remuxer -cm 2000 - - | oggfwd -w live.ber.c3voc.de 8000 XXXX /s2_native_hd.webm; done"
H264_SD="while sleep 1; do ffmpeg -y -i $HD_URL -aspect 16:9 -threads:0 0 -c:v libx264 -filter_complex 'scale=720:576' -maxrate:v:0 800k -bufsize:v:0 8192k -crf:0 18 -pix_fmt:0 yuv420p -profile:v:0 main -g:v:0 25 -preset:v:0 veryfast -c:a copy $METADATA -y -f flv $SD_URL; done"
$TMUX_BIN new-window -n s2_native_sd "$H264_SD"
$TMUX_BIN new-window -n s2_webm_sd "$WEBM_SD"
$TMUX_BIN new-window -n s2_webm_hd "$WEBM_HD"
$TMUX_BIN new-window -n s2_mp3 "$MP3"
$TMUX_BIN new-window -n s2_opus "$OPUS"
== Erklärung der einzelnen Zeilen
Angenommen es trifft irgend eine 1920x1080 Quelle auf ''rtmp://live.ber.c3voc.de/test/q1''
Beispielkommando zum Testen einer Quelle:
ffmpeg -y -re -i http://cdn.media.ccc.de/events/camp2015/h264-hd/cccamp15-6799-en-de-How_to_Destroy_a_Laptop_with_Top_Secrets_hd.mp4 -c:v copy -c:a copy -f flv rtmp://live.ber.c3voc.de/test/q1
Quelle -> MP4 HD
while true; do ffmpeg -y -i rtmp://localhost/test/q1 -aspect 16:9 -threads:0 0 -c:v libx264 -filter_complex 'yadif=mode=2, hqdn3d' -map 0:0 -maxrate:v:0 3000k -bufsize:v:0 8192k -crf:0 21 -pix_fmt:0 yuv420p -profile:v:0 main -g:v:0 25 -preset:v:0 veryfast -ac 1 -c:a libfdk_aac -b:a 96k -ar 44100 -map 0:1 -ac:a:2 2 -y -f flv rtmp://localhost/stream/q1_native_hd; sleep 1; done
MP4 HD -> MP4 SD
while true; do ffmpeg -y -i rtmp://localhost/stream/q1_native_hd -aspect 16:9 -threads:0 0 -c:v libx264 -filter_complex 'scale=720:576' -maxrate:v:0 800k -bufsize:v:0 8192k -crf:0 18 -pix_fmt:0 yuv420p -profile:v:0 main -g:v:0 25 -preset:v:0 veryfast -c:a copy -y -f flv rtmp://localhost/stream/q1_native_sd; sleep 1; done
MP4 HD -> WebM HD
while true; do ffmpeg -y -i rtmp://localhost/stream/q1_native_hd -aspect 16:9 -threads:0 0 -fflags +genpts -flags +global_header -map 0:v -c:v libvpx -g 75 -keyint_min 75 -deadline realtime -b:v 3000k -ac 1 -maxrate:a 96k -map 0:1 -c:a libvorbis -f webm pipe: | /usr/local/bin/mse_webm_remuxer -cm 2000 - - | oggfwd -w localhost 8000 "password" /q1_native_hd.webm; sleep 1; done
MP4 SD -> WebM SD
while true; do ffmpeg -y -i rtmp://localhost/stream/q1_native_sd -aspect 16:9 -threads:0 0 -fflags +genpts -flags +global_header -map 0:v -c:v libvpx -g 75 -keyint_min 75 -deadline realtime -b:v 800k -ac 1 -maxrate:a 96k -map 0:1 -c:a libvorbis -f webm pipe: | /usr/local/bin/mse_webm_remuxer -cm 2000 - - | oggfwd -w localhost 8000 "password" /q1_native_sd.webm; sleep 1; done
MP4 SD -> MP3
while true; do ffmpeg -y -i rtmp://localhost/stream/q1_native_sd -ac 1 -c:a libmp3lame -map 0:a -ac 1 -b:a 96k -y -f mp3 pipe: | oggfwd -3 localhost 8000 "password" /q1_native.mp3; sleep 1; done
MP4 SD -> Opus
while true; do ffmpeg -y -i rtmp://localhost/stream/q1_native_sd -ac 1 -c:a libopus -map 0:a -b:a 64k -vbr off -f ogg pipe: | oggfwd localhost 8000 "password" /q1_native.opus; sleep 1; done