Video Streaming

Codecs, aplicaciones y plataformas

CODECS

Audio

Video

VP9

https://trac.ffmpeg.org/wiki/Encode/VP9

ffmpeg -h encoder=libvpx-vp9 # Mostrar opciones

-c:v libvpx-vp9 -b:v 2500k -c:a libopus -b:a 128k -ar 44100
#-framerate 25

Para Streaming

-qmin 4 -qmax 48 -quality realtime -speed 5 -static-thresh 0 -max-intra-rate 300 -error-resilient 1 \ #libvpx
-tile-columns 2 -frame-parallel 1 -row-mt 1 \ #VP9
-threads 5 -f webm output.webm # ffmpeg

https://developers.google.com/media/vp9/live-encoding

-r 25 -g 75 -s 1280x720 -quality realtime -speed 5 -threads 5 -row-mt 1 -tile-columns 2 -frame-parallel 1 -qmin 4 -qmax 48 -b:v 3000k

https://developers.google.com/media/vp9/bitrate-modes/

-minrate 2000k -maxrate 23000k #CBR
-crf 32 #CQ
  • Ejemplo completo CBR streaming
-c:v libvpx-vp9 -b:v 2000k -c:a libopus -b:a 128k -ar 48000 -minrate 2000k -maxrate 2000k -qmin 4 -qmax 48 -quality realtime -speed 8 -static-thresh 0 -max-intra-rate 300 -error-resilient 1 -tile-columns 1 -frame-parallel 1 -row-mt 1 -threads 5 -f webm output.webm

libva / VAAPI

vainfo --display drm --device /dev/dri/renderD128
ffmpeg -hide_banner -hwaccels
ffmpeg -hide_banner -h encoder=vp9_vaapi
for i in encoders decoders filters; do
  echo $i:; ffmpeg -hide_banner -${i} | grep -i "vaapi"
done
# Encode
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v vp9_vaapi \
-b:v 3M -maxrate:v 3M -minrate:v 3M vp9_output.webm

ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v vp9_vaapi \
-global_quality 50 -bf 2 -bsf:v vp9_raw_reorder,vp9_superframe output.webm

ffmpeg -vaapi_device /dev/dri/renderD128 -re -i input.mp4 -vf 'format=nv12,hwupload' -c:v vp9_vaapi \
-g 150 -compression_level 1 -bf 4 -bsf:v vp9_raw_reorder,vp9_superframe -b:v 3M -maxrate:v 3M -minrate:v 3M vp9_output.webm
# -re # Solo leyendo de ficheros para coger su framerate

# Transcode completamente en HW
ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i input.mp4 \
-c:v vp9_vaapi -b:v 3M vp9_output.webm

# TC HW + Si no sabemos el formato de la fuente
ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i input.mp4 \
-vf 'format=nv12|vaapi,hwupload' \
-c:v vp9_vaapi -b:v 3M vp9_output.webm

Stream Servers (self-hosted)

Owncast

  • Info
  • Instalación
    • curl -s https://owncast.online/install.sh | bash
    • Docker
  • Config
    • rtmp://localhost/live
      • http://localhost:8080
      • http://localhost:8080/admin
    • Por defecto
      • StreamQuality
        • IsAudioPassthrough: true
        • VideoBitrate: 1200
        • FPS: 24
        • Encoder preset : veryfast
    • Ficheros a modificar
      • config-default.yaml -> config.yaml
    • Broadcasting software
      • Video : x264
  • Debug owncast -enableVerboseLogging -enableDebugFeatures

FirewallD

FDSDIR='/etc/firewalld/services'
FDSOWNCAST="$FDSDIR/owncast.xml"

if [[ -d $FDSDIR ]] && [[ ! -f $FDSOWNCAST ]] ; then
  cat <<'EOF' > $FDSOWNCAST
<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>owncast</short>
  <description>Streaming (RTMP-1935) + chat out of the box (TCP-8080)</description>
  <port protocol="tcp" port="8080"/>
  <port protocol="tcp" port="1935"/>
</service>
EOF
  firewall-cmd --permanent --zone=home --add-service=owncast
  firewall-cmd --permanent --zone=home --add-service=http --add-service=https # Si usamos Traefik / proxy inverso
  systemctl restart firewalld.service
  systemctl --no-pager --full status firewalld.service
else
  echo "O no exite $FDSDIR"
  echo "O ya exite $FDSOWNCAST"
fi

Open Streaming Platform

Stream Services (self+hosted)

PeerTube

autistici.org

<p><iframe src="https://live.autistici.org/#gnulinuxvalenciasocial" width="800" height="600" frameborder="0" allowfullscreen="allowfullscreen"><span style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" data-mce-type="bookmark" class="mce_SELRES_start"></span></iframe></p>

G.I.S.S

SRT Protocol (verde aún)

https://obsproject.com/wiki/Streaming-With-SRT-Protocol

Services

SRT Live Server (free, open source)

https://github.com/Edward-Wu/srt-live-server

Nimble Streamer (free, closed source)

VP8/9 = RTSP

Configuraciones

Youtube

Archive.org

Derivates

https://archive.org/help/derivatives.php

What encoding specifications are best for .mp4 files?

https://help.archive.org/hc/en-us/articles/360017808151-Movies-and-Videos-A-Basic-Guide-

For your original mp4 to work in the online player we currently require the file to have:
audio: aac
video: h.264
moov atom: front
pixel format: yuv420p

If this is not the case we will derive a new mp4 with the file name suffix .ia.mp4
\

Última modificación 2021.27.07 : categorias y tags de todo (1f727f4)