Video Streaming
Codecs, aplicaciones y plataformas
4 minutos de lectura
CODECS
Audio
- Info
- Compatibilidades
- HTML5 audio element
- https://en.wikipedia.org/wiki/HTML5_audio
- https://caniuse.com/audio
- PCM/WAV (-{IE,Opera}), MP3, Opus(-{IE,Apple}), Vorbis(-IE,%Apple), ACC(%Firefox), FLAC
Video
- Info
- https://en.wikipedia.org/wiki/Comparison_of_video_container_formats -> MKV o webm
- https://en.wikipedia.org/wiki/Comparison_of_video_codecs
- https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs -> WebM(VP9+Opus) / WebM(AV1+Opus)
- Compatibilidades
- HTML5 video element
- https://en.wikipedia.org/wiki/HTML5_video#Browser_support -> WebM(VP9)
- https://caniuse.com/video
- WebM (-IE,#Safari_iOS), MPEG4/H.264, Ogg/Theora(-{IE, Apple, Android, …}), WebVTT, HEVC/H.265 (-{Firefox,Chrome, Android},%IE)
FFMPEG
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
-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
-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
- https://wiki.archlinux.org/index.php/Hardware_video_acceleration
- https://wiki.libav.org/Hardware/vaapi
- http://www.ffmpeg.org/ffmpeg-codecs.html#VAAPI-encoders
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
- https://www.reddit.com/r/VP9/comments/g9uzzv/hardware_encoding_vp9_on_intel/
- https://stackoverflow.com/questions/55007246/ffmpeg-vp9-vaapi-encoding-to-a-mp4-or-webm-container-from-given-official-ffm
- https://stackoverflow.com/questions/45476554/ffmpeg-hwaccel-error-with-hwupload
- https://gist.github.com/Brainiarc7/95c9338a737aa36d9bb2931bed379219
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
- Ficheros a modificar
config-default.yaml
->config.yaml
- Broadcasting software
- Video : x264
- rtmp://localhost/live
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
- Info
- Instalación
- Docker :
docker pull deamos/openstreamingplatform
- Docker :
Stream Services (self+hosted)
PeerTube
- Instancias: Buscador - Listado
- Desde la 3.0 se pueden hacer directos
- Usa HLS player with p2p-media-loader
- Configuración de OBS como el resto H264 High 4.1 MP4….
- Protocolo ingesta : solo RTMP
autistici.org
Info
rtmp://live.autistici.org/ingest/
- x264 sencillo -> OK
- ogg(Theora+Vorbis) -> OBS no deja (Function not implemented)
- webm/mkv(VP8+Vorbis) -> OBS no deja (Function not implemented)
- webm(VP9+Opus) -> OBS no deja (Function not implemented)
iframe
<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
- http://giss.tv/
- gissnetwork@gmail.com
- http://giss.tv:8000/my_channel.ogg
- http://giss.tv/wiki/index.php/Streaming_Tools
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
- https://www.dacast.com/support/knowledgebase/live-encoder-configuration/
- H.264 Profile : High
- https://manycam.com/blog/best-live-streaming-settings/
- 1080p 30FPS : H.264 4.1 Main/High
- 1440p 30FPS : H.264 5.0 Main/High
- https://obsproject.com/forum/resources/low-latency-high-performance-x264-options-for-for-most-streaming-services-youtube-facebook.726/
Youtube
- https://support.google.com/youtube/answer/4603579?hl=es
- Directos : https://support.google.com/youtube/answer/2853702?hl=es
- 720p 30FPS: 4 Mbps - 3000-8000 Kbps (Min/Max para AV1/H.265)
- 1080p 30FPS: 10 Mbps - 3000-8000 Kbps
- 1440p 30FPS: 15 Mbps - 5000-25000 Kbps
- Codec:
- CBR - H.264 de nivel 4.1 (Main/High) para 1080p como máximo y a 30 FPS
- CBR - AV1 / H.265 (HEVC) (recomendado)
- Audio : AAC o MP3 a 128-384 Kbps en estéreo 44,1-48 KHz
- OBS:
- Espacio de color: Rec. 709 para SDR / HLG o 2100 PQ para HDR
- Profundidad de bits: 8 SDR / P010 HDR (H.265 HEVC)
Archive.org
Derivates
https://help.archive.org/help/category/archive-org/files-formats-and-derivatives/
What encoding specifications are best for .mp4 files?
- https://help.archive.org/help/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
Comentarios
¿Fue útil esta página?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.