Table des matières
AstroFlux Technique
Les formats vidéo du stream
- Des éléments génériques sur les formats vidéo supportés par les différents fureteurs / OS http://diveintohtml5.info/video.html
- Vidéo for everybody : comment faire un player HTML5 avec fallback flash http://camendesign.com/code/video_for_everybody
- Le mystère derrière le delay du streaming + format RTSP vs RTMP http://forum.videohelp.com/threads/339852-Streaming-considerations-RTMP-vs-RTSP-vs-HLS-vs-MMS-vs ?
- Vidéo “Case study - Broadcast and Web Streaming with Gstreamer” : http://gstconf.ubicast.tv/videos/case-study-broadcast-and-web-streaming-with-gstreamer/
- Synchro with Gstreamer http://gstconf.ubicast.tv/videos/displaying-sychronized-video-2/
- HTML5 video and H.264 – what history tells us and why we’re standing with the web http://www.0xdeadbeef.com/weblog/2010/01/html5-video-and-h-264-what-history-tells-us-and-why-were-standing-with-the-web/
- H.264 Royalties: what you need to know http://www.streaminglearningcenter.com/articles/h264-royalties-what-you-need-to-know.html
- Google WebM pour concurrencer le H.264 http://www.presence-pc.com/actualite/WebM-Google-39382/
- Synchro audio video, les différentes couches du stream détaillées : http://users.ece.cmu.edu/~peha/streaming_video.pdf
- Un PDF générique sur les techniques de streaming http://oa.upm.es/1055/1/PFC_PABLO_RIESGO_FERREIRO.pdf
- La différence entre streaming et progressive download http://www.iis.net/learn/media/windows-media-services/windows-media-server-or-web-server
- Un ensemble de ressources autour de l'Open Video Forum http://wiki.creativecommons.org/Open_Video_Forum
- Un slide sur la compression et le streaming http://www.slideshare.net/samir/compression-video-pour-la-diffusion-web
- stream.js pour embed de flux, voir discussion https://groups.google.com/forum/?fromgroups&hl=en#!topic/mistserver/yWWD3Cn3wk4 à propos de http://mistserver.org
- Les formats préconisés pour youtube live https://support.google.com/youtube/answer/2853702?hl=en&topic=2853713&ctx=topic
- les espaces de couleurs http://linuxtv.org/downloads/v4l-dvb-apis/
- les formats supportés par Android http://developer.android.com/guide/appendix/media-formats.html
Wowza ressources
Gstreamer ressources
- Tuto OLPC sur Gstreamer pour les bases gst-launch-0.10 v4l2src ! ffmpegcolorspace ! ximagesink http://wiki.laptop.org/go/GStreamer
- Un autre générique http://paiiou.free.fr/Tutoriels/Utilisation/gst1.php
- Un ensemble de ressources sur Gstreamer :
- Streaming vidéo SD avec Gstreamer http://blog.nicolargo.com/2010/02/streaming-video-hd-avec-gstreamer.html
- Exemple pipeline gstreamer http://www.wowza.com/forums/showthread.php?24231-Gtreamer-Pipeline-enable-username-password-in-wowza
- Streamer avec gstreamer > wowza http://www.wowza.com/forums/showthread.php?1599-Using-gstreamer-0-10-with-Wowza
gst-launch-0.10 -vvv videotestsrc ! queue ! x264enc byte-stream=true bitrate=300 ! rtph264pay ! udpsink port=5000 host=127.0.0.1 sync=false
ok ci-dessous
gst-launch-0.10 -vvv videotestsrc is-live=true ! x264enc byte-stream=true bitrate=300 ! queue ! ffmux_mpegts ! udpsink port=10000 host=10.0.0.10 -v
- Synchro clock streaming http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+12%3A+Streaming
Mire
# gst-launch-0.10 videotestsrc ! ffmpegcolorspace ! video/x-raw-yuv,width=320,height=240 ! clockoverlay ! cairotextoverlay text="stream currently unavailable" shaded-background=true ! theoraenc quality=5 ! queue ! oggmux name=mux audiotestsrc ! audioconvert ! vorbisenc quality=0.1 ! queue ! mux. mux. ! queue ! shout2send ip=127.0.0.1 port=8000 password=monpass mount=mire.ogv
Périphérique v4l2
# gst-launch v4l2src ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! theoraenc quality=16 ! oggmux ! shout2send ip=labomedia.org port=8000 password=**** mount=live.ogv
# gst-launch-0.10 multifilesrc location=logo_2.png ! "image/png,framerate=1/1" ! pngdec ! alphacolor ! alpha method=0 alpha=0.5 ! videomixer name=mixer ! ffmpegcolorspace ! videoscale ! video/x-raw-yuv,width=320,height=240 ! theoraenc quality=16 ! oggmux ! shout2send ip=live.monsite.com port=8000 password=monpass mount=live.ogv v4l2src ! ffmpegcolorspace ! cairotextoverlay text="Plus d'infos - www.monsite.com" shaded-background=true ! clockoverlay halign=right valign=top text="En direct" shaded-background=true ! timeoverlay ! videoscale ! alpha method=0 alpha=1.0 ! mixer.
- ressources génériques gstreamer http://www.noah.org/wiki/video_4_linux_2_notes
- préréglages caméras
uvcdynctrl -s "Focus, Auto" 0
You can then adjust the focus with:
uvcdynctrl -s "Focus (absolute)" $amt
Where $amt is a number from 0 - 40
Gstreamer vs Wowza
- Des scripts type à télécharger : http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/tests/examples/rtp
#!/bin/sh # # A simple RTP server # sends the output of v4l2src as h264 encoded RTP on port 5000, RTCP is sent on # port 5001. The destination is 127.0.0.1. # the video receiver RTCP reports are received on port 5005 # sends the output of autoaudiosrc as alaw encoded RTP on port 5002, RTCP is sent on # port 5003. The destination is 127.0.0.1. # the receiver RTCP reports are received on port 5007 # # .-------. .-------. .-------. .----------. .-------. # |v4lssrc| |h264enc| |h264pay| | rtpbin | |udpsink| RTP # | src->sink src->sink src->send_rtp send_rtp->sink | port=5000 # '-------' '-------' '-------' | | '-------' # | | # | | .-------. # | | |udpsink| RTCP # | send_rtcp->sink | port=5001 # .-------. | | '-------' sync=false # RTCP |udpsrc | | | async=false # port=5005 | src->recv_rtcp | # '-------' | | # | | # .--------. .-------. .-------. | | .-------. # |audiosrc| |alawenc| |pcmapay| | rtpbin | |udpsink| RTP # | src->sink src->sink src->send_rtp send_rtp->sink | port=5002 # '--------' '-------' '-------' | | '-------' # | | # | | .-------. # | | |udpsink| RTCP # | send_rtcp->sink | port=5003 # .-------. | | '-------' sync=false # RTCP |udpsrc | | | async=false # port=5007 | src->recv_rtcp | # '-------' '----------' # # ideally we should transport the properties on the RTP udpsink pads to the # receiver in order to transmit the SPS and PPS earlier. # change this to send the RTP data and RTCP to another host DEST=127.0.0.1 # tuning parameters to make the sender send the streams out of sync. Can be used # ot test the client RTCP synchronisation. #VOFFSET=900000000 VOFFSET=0 AOFFSET=0 # H264 encode from the source VELEM="v4l2src" #VELEM="videotestsrc is-live=1" VCAPS="video/x-raw,width=352,height=288,framerate=15/1" VSOURCE="$VELEM ! queue ! videorate ! videoconvert ! $VCAPS" VENC="x264enc tune=zerolatency byte-stream=true bitrate=300 ! rtph264pay" VRTPSINK="udpsink port=5000 host=$DEST ts-offset=$VOFFSET name=vrtpsink" VRTCPSINK="udpsink port=5001 host=$DEST sync=false async=false name=vrtcpsink" VRTCPSRC="udpsrc port=5005 name=vrtpsrc" # PCMA encode from the source AELEM="autoaudiosrc" #AELEM="audiotestsrc is-live=1" ASOURCE="$AELEM ! queue ! audioresample ! audioconvert" AENC="alawenc ! rtppcmapay" ARTPSINK="udpsink port=5002 host=$DEST ts-offset=$AOFFSET name=artpsink" ARTCPSINK="udpsink port=5003 host=$DEST sync=false async=false name=artcpsink" ARTCPSRC="udpsrc port=5007 name=artpsrc" gst-launch-1.0 -v rtpbin name=rtpbin \ $VSOURCE ! $VENC ! rtpbin.send_rtp_sink_0 \ rtpbin.send_rtp_src_0 ! $VRTPSINK \ rtpbin.send_rtcp_src_0 ! $VRTCPSINK \ $VRTCPSRC ! rtpbin.recv_rtcp_sink_0 \ $ASOURCE ! $AENC ! rtpbin.send_rtp_sink_1 \ rtpbin.send_rtp_src_1 ! $ARTPSINK \ rtpbin.send_rtcp_src_1 ! $ARTCPSINK \ $ARTCPSRC ! rtpbin.recv_rtcp_sink_1
Régler les problèmes
Latence
VLC ressources
vlc v4l2:///dev/video0 --v4l2-fps=25 --sout '#transcode{venc=x264{keyint=60,profile=main},vcodec=x264,vb=512,scale=1,acodec=mp4a,ab=96,channels=2,samplerate=44100}:rtp{dst=10.0.0.10,port=10000,mux=ts}'
cvlc screen:// --screen-mouse-image cursor.png --screen-fps=12 --screen-width=1680 --screen-height=1050 --sout "#transcode{venc=theora,quality:10,scale=0.75,fps=12}:duplicate{dst=std{access=file,mux=ogg,dst=desktop.ogg}}}" --no-sout-audio
vlc vs jack
<code>
vlc --longhelp --advanced | grep jack
VLC media player 2.0.6 Twoflower (revision 2.0.6-0-gbe9623c)
--jack-auto-connect, --no-jack-auto-connect --jack-connect-regex <html><Chaîne></html>\\ --jack-input-use-vlc-pace, --no-jack-input-use-vlc-pace --jack-input-auto-connect, --no-jack-input-auto-connect
</code>
cvlc v4l2:///dev/video11 --jack-input-auto-connect --jack-auto-connect vlc jack://channels=vlc:ports=1,2
La bonne ligne de commande qui marche (presque)
vlc v4l2:///dev/video0 :v4l2-standard= :input-slave=jack://channels=2:ports=.* :live-caching=300
vlc -vvv v4l2:///dev/video1 :v4l2-standard= --input-slave=jack:// :input-slave= :live-caching=300
FFMPEG ressources
ffmpeg -re -i "sample.mp4" -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 2.1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://127.0.0.1:10000?pkt_size=1316| udp://127.0.0.1:10000?pkt_size=1316]]
une baseline qui marche avec ma webcam (le baseline ne supportait pas le 4:2:2 cf 1
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video0 -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 2.1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts -pix_fmt yuv420p [[udp://10.0.0.10:10012?pkt_size=1316| udp://10.0.0.10:10012?pkt_size=1316]]
changer le level 2.1 en level 3 ?
- capturer une webcam http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20capture%20a%20webcam%20input
ffmpeg -f v4l2 -r 25 -s 640x480 -i /dev/video0
- Capturer l'audio avec jack http://www.ffmpeg.org/ffmpeg-devices.html#jack
ffmpeg -f jack -i ffmpeg -y home/b01/out.wav
- Combiner les deux
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video1 -f avi -vcodec libxvid -b 50000k -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec libmp3lame -ab 320k Testxvid.avi
- En version stream
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video1 -vcodec libx264 -vb 150000 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://127.0.0.1:10000?pkt_size=1316| udp://127.0.0.1:10000?pkt_size=1316]]
- Le pousser sur une device virtuel pour retour image
ffmpeg -re -lavfi testsrc -f v4l2 /dev/video1
- Streamer en RTMP avec ffmpeg http://guillaume.vaillant.me/?p=73
ffmpeg -f alsa -ac 2 -i jackplug -f x11grab -r 30 -s 1440x900 -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mkv mplayer [[tv://| tv://]] -tv driver=v4l2:width=640:height=480:device=/dev/video11:alsa
- Générer 4 flux à partir d'un seul http://www.commandlinefu.com/commands/view/8938/create-4-rtp-streams-h264aac-from-a-single-source-with-a-single-ffmpeg-instance…
ffmpeg [source specification if needed] -i $src -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 13 -g 15 -crf 25 -s 320x224 -aspect 16:9 -r 15 -b 186000 -vb 186000 -minrate 176700 -maxrate 195300 -bt 9300 -bufsize 262500 -muxrate 195300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort1 -vn -acodec libfaac -async 2 -flags +global_header -ac 1 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort1 -newaudio -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 13 -g 20 -crf 25 -s 320x224 -aspect 16:9 -r 20 -b 286000 -vb 286000 -minrate 271700 -maxrate 300300 -bt 14300 -bufsize 367500 -muxrate 300300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort2 -newvideo -vn -acodec libfaac -async 2 -flags +global_header -ac 1 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort2 -newaudio -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 30 -g 25 -crf 25 -s 480x336 -aspect 16:9 -r 25 -b 386000 -vb 386000 -minrate 366700 -maxrate 405300 -bt 19300 -bufsize 472500 -muxrate 405300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort3 -newvideo -vn -acodec libfaac -async 2 -flags +global_header -ac 2 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort3 -newaudio -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 30 -g 25 -crf 25 -s 480x336 -aspect 16:9 -r 25 -b 686000 -vb 686000 -minrate 651700 -maxrate 720300 -bt 34300 -bufsize 787500 -muxrate 720300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort4 -newvideo -vn -acodec libfaac -async 2 -flags +global_header -ac 2 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort4 -newaudio
v4l2 loopback
v4l2 est un module permettant de créer des devices vidéos virtuels et d'y écrire avec des programmes (gstreamer, pix_record, ffmpeg) à l'instar d'une webcam
GoPro de m.
Récupérer le flux streamé de la gopro : il semblerait que le flux streamé soit en HLS (Apple …) soit des bouts de fichiers de 2 secondes regroupés via un fichier playlist
ffmpeg
ffplay -i [[http://10.5.5.9:8080/live/amba.m3u8| http://10.5.5.9:8080/live/amba.m3u8]]\\ ffmpeg -y -i [[http://10.5.5.9:8080/live/amba.m3u8| http://10.5.5.9:8080/live/amba.m3u8]] -c:v copy -an test.mp4 ffmpeg -y -i [[http://10.5.5.9:8080/live/amba.m3u8| http://10.5.5.9:8080/live/amba.m3u8]] -f v4l2 /dev/video1
ffmpeg -re -lavfi testsrc -f v4l2 /dev/video1
<code>
Input #0, hls,applehttp, from 'http://10.5.5.9:8080/live/amba.m3u8':
Duration: 00:00:00.02, start: 1248.215467, bitrate: 131 kb/s Stream #0:0: Video: h264 (High) (HDMV / 0x564D4448), yuvj420p, 432x240 [SAR 1:1 DAR 9:5], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, s16, 131 kb/s
Frame changed from size:0x0 to size:432x2405KB vq= 0KB sq= 0B f=0/0 [aac @ 0x9207980] Number of bands (14) exceeds limit (12).B f=0/0 f=0/0 [aac @ 0x9207980] channel element 2.1 is not allocated [mpegts @ 0x91fa7e0] PES packet size mismatch 3KB sq= 0B f=0/0 [aac @ 0x9207980] invalid band type0KB vq= 22KB sq= 0B f=0/0 [aac @ 0x9207980] channel element 3.9 is not allocated [mpegts @ 0x91fa7e0] PES packet size mismatch21KB sq= 0B f=0/0 </code>
gstreamer
gst-launch-0.10 -v souphttpsrc location=[[http://10.5.5.9:8080/live/amba.m3u8| http://10.5.5.9:8080/live/amba.m3u8]] is-live=true ! hlsdemux ! decodebin2 ! ffmpegcolorspace ! videoscale ! autovideosink
- gstreamer http://forums.openpilot.org/topic/15587-video-gadget/#entry159688 et http://forums.openpilot.org/topic/15545-gcs-go-pro-wifi-widget/ (commandes via http)
VLC + Pd
ça semble marcher, éventuellement indiquer le backend [driver 4< avant de créer la fenetre GEM
clearProps, setProps screen-fps 50, dimen 640 480, device [[http://10.5.5.9:8080/live/amba.m3u8| http://10.5.5.9:8080/live/amba.m3u8]]
Régie
Structure
User : astroflux
Nom ordi : RegieVideo
SSD 256 Go :
- /
- swap 8Go
Disque dur 1 To :
- /home
Workflow
- Créer des devices virtuels
sudo modprobe v4l2loopback video_nr=10,11,12,13,19
- Lancer le patch Pd qui appelle les différents flux avec pix_video et les renvoient sur les devices /dev/video10,11,12,13,19 via pix_record
- Lancer le patch Pd qui récupère le G+D de la console et le redispatch avec délais sur les sorties 2,3,4,5,6,7,8,9,10,11 de jack
- Lancer les encodeurs pour envoyers les flux à wowza
TEST
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video1 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 44100 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://127.0.0.1:10000?pkt_size=1316| udp://127.0.0.1:10000?pkt_size=1316]]\\
CONFIG LABO
Chaque ligne se différencient de son /dev/video.. et de son numéro de port 10001
Cam 1:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video10 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10000?pkt_size=1316| udp://10.0.0.10:10000?pkt_size=1316]]
Cam 2:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video11 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10001?pkt_size=1316| udp://10.0.0.10:10001?pkt_size=1316]]
Cam 3:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video12 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10002?pkt_size=1316| udp://10.0.0.10:10002?pkt_size=1316]]
Cam 4:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video13 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10003?pkt_size=1316| udp://10.0.0.10:10003?pkt_size=1316]]
Montage (en 19):
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video19 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10019?pkt_size=1316| udp://10.0.0.10:10019?pkt_size=1316]]
Test avec H264 profile :
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video10 -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 3 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts -pix_fmt yuv420p [[udp://192.168.0.10:10000?pkt_size=1316| udp://192.168.0.10:10000?pkt_size=1316]]
Test avec H264 profile + enregistrement simultané (nécessite ffmpeg > 03/02/2013) :
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video10 -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 3 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts -pix_fmt yuv420p - | ffmpeg -f mpegts -i - -c copy -f mpegts [[udp://192.168.0.10:10000?pkt_size=1316| udp://192.168.0.10:10000?pkt_size=1316]] -c copy -f mpegts record.ts
- voir les options de profile (youtube live préconise “main”, “baseline” est le plus compatible, notamment avec les vieux iOS) https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide
- et la compatibilité https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide#Compatibility
- les options x264 détaillées : https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping
- les profils h264 détaillés : http://blog.mediacoderhq.com/h264-profiles-and-levels/
- Pour streamer et enregistrer en même temps avec ffmpeg https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs
- Pour enregistrer le flux entrant et en même temps l'envoyer vers /dev/video2
/home/astroflux/Bureau/AstroFlux/armoire/bmdtools/bmdcapture -C 0 -m 2 -A 2 -V 4 -F nut -f pipe:1 | /home/astroflux/Bureau/AstroFlux/armoire/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -f mp4 -vcodec mpeg4 -qscale 0 -vb 6000k -acodec libmp3lame -ab 320k Testrec.mp4 -f v4l2 /dev/video2
On met un | quand il s'agit d'un stream
ffmpeg version 1.0ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers Copyright (c) 2000-2012 the FFmpeg developers built on Nov 17 2012 12:13:29 with gcc 4.7 (Debian 4.7.2-4) built on Nov 17 2012 12:13:29 with gcc 4.7 (Debian 4.7.2-4) configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --disable-decoder=libdirac --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/i386-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libdc1394 --disable-altivec configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --disable-decoder=libdirac --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/i386-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libdc1394 --disable-altivec libavutil 51. 73.101 / 51. 73.101 libavutil 51. 73.101 / 51. 73.101 libavcodec 54. 59.100 / 54. 59.100 libavcodec 54. 59.100 / 54. 59.100 libavformat 54. 29.104 / 54. 29.104 libavformat 54. 29.104 / 54. 29.104 libavdevice 54. 2.101 / 54. 2.101 libavdevice 54. 2.101 / 54. 2.101 libavfilter 3. 17.100 / 3. 17.100 libavfilter 3. 17.100 / 3. 17.100 libswscale 2. 1.101 / 2. 1.101 libswscale 2. 1.101 / 2. 1.101 libswresample 0. 15.100 / 0. 15.100 libswresample 0. 15.100 / 0. 15.100 libpostproc 52. 0.100 / 52. 0.100 libpostproc 52. 0.100 / 52. 0.100 [x264] Warning: Unrecognized parameter x264_i_weighted_pred [x264] Warning: Unrecognized parameter x264_b_fast_pskip [x264] Warning: Unrecognized parameter x264_b_dct_decimate Cannot lock down 82274202 byte memory area (Cannot allocate memory) [x264] Info: using SAR=1/1 [x264] Info: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX [x264] Info: profile Main, level 3.1 Cannot lock down 82274202 byte memory area (Cannot allocate memory) [jack @ 0x9514fa0] JACK client registered and activated (rate=48000Hz, buffer_size=1024 frames) [jack @ 0x9514fa0] Estimating duration from bitrate, this may be inaccurate Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, jack, from 'ffmpeg': Duration: N/A, start: 1377887869.965520, bitrate: 3072 kb/s Stream #0:0: Audio: pcm_f32le, 48000 Hz, stereo, flt, 3072 kb/s [video4linux2,v4l2 @ 0x951d100] Cannot find a proper format for codec_id 0, pix_fmt -1. /dev/video10: Input/output error
7:1.0-dmo4
Régie Puredata
Patch de contrôle de l'Alias8 (pad du haut rouge // pad du bas bleu) : alias8.pd
Pour Debug
- Envoyer le flux vidéo live vers un de ces devices virtuels
gst-launch videotestsrc ! v4l2sink device=/dev/video10
avec source live
gst-launch v4l2src device=/dev/video1 ! 'video/x-raw-yuv,width=320,height=240' ! v4l2sink device=/dev/video10
ce device virtuel peut apparemment être attaqué par 2 programmes : vlc qui le stream directement > wowza et Pd qui l'ouvre avec pix_video
gst-launch v4l2src device=/dev/video11 ! xvimagesink
pour debug
gst-launch -v --gst-debug-level=3 v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=352,height=288' ! v4l2sink device=/dev/video10
Récupérer des infos sur les devices / caméras
sudo apt-get install v4l-utils uvcdynctrl guvcview v4l2ucp
Tester la webcam
lsusb
Voir les périphériques
ls /dev/vid*
Infos v4l2
v4l-info /dev/video1
Les controles disponibles
v4l2-ctl -d /dev/video1 -l
Changer un parametre de controle
v4l2-ctl -s pal -d /dev/video1 (pour passer en pal une carte d'acquisition)
Les formats disponibles
v4l2-ctl -d /dev/video1 --list-formats-ext
Le format actuellement utilisé par la webcam
v4l2-ctl -d /dev/video1 -V
Changer la taille de capture de la webcam
v4l2-ctl -d /dev/video1 --set-fmt-video=width=640,height=360
cat /sys/devices/virtual/video4linux/video10/buffers
ou pour lister les formats d'une camera
uvcdynctrl -d /dev/video1 -f
voir tous les réglages avec une interface graphique
guvcview
changer les paramètres de la webcam quand Pure Data l'accapare
v4l2ucp
Pour gérer la bande passante des cameras et périphériques USB
Blackmagic sous Linux
installation
Tentative de faire marcher une blackmagick decklink quad sur linux (LMDE)
- une bonne ressource http://wiki.teltek.es/display/Galicaster/Blackmagic+capture+cards
- fichier txt de référence, à voir le problème de vmalloc du noyau 32 bits http://www.blackmagicdesign.com/media/5440492/Blackmagic_Desktop_Video_Linux_9.7.1.txt
Il faut installer desktopvideo_10.4.2a18_amd64.debTexte en gras pour avoir les drivers, paquet intégré au logiciel Blackmagic_Desktop_Video_Linux_10.4.2.tar.gz à télécharger là https://www.blackmagicdesign.com/support
sudo dpkg -i desktopvideo_10.4.2a18_amd64.deb
updater les firmwares si besoin :
sudo BlackmagicFirmwareUpdater status
sudo BlackmagicFirmwareUpdater update /dev/blackmagic/dv0 sudo BlackmagicFirmwareUpdater update /dev/blackmagic/dv1 sudo BlackmagicFirmwareUpdater update /dev/blackmagic/dv2 sudo BlackmagicFirmwareUpdater update /dev/blackmagic/dv3
Check if the driver and the card are loaded and ready
Run on a terminal:
lspci | grep Blackmagic lsmod | grep blackmagic ls /dev/blackmagic*
You will receive messages like:
_02:00.0 Multimedia video controller: Blackmagic Design Device a11b_ _blackmagic 2082944 1_ /dev/blackmagic0
gstreamer
pour connaitre les propriétés de la carte decklink
gst-inspect-0.10 decklinksrc
pour connaitre les modules installés de gstreamer
gst-inspect | grep sink
gst-launch-0.10 videotestsrc ! ximagesink gst-launch-0.10 videotestsrc ! autovideosink gst-launch-0.10 videotestsrc ! aasink
gst-launch-0.10 videotestsrc ! v4l2sink device=/dev/video0
gst-launch-0.10 -v decklinksrc mode=2 connection=0 subdevice=0 ! ffmpegcolorspace ! ximagesink sync=false
gst-launch-0.10 -v decklinksrc ! videoconvert ! ximagesink
les sources du module decklink de gstreamer http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/decklink
astroflux@regievideo ~ $ BlackmagicFirmwareUpdater status blackmagic0 [DeckLink SDI] 0x1d OK
réf:
- liste bugs “officiels” https://bugzilla.gnome.org/buglist.cgi?quicksearch=gstreamer+decklink
bmdtools
des outils de capture et de diffusion en ligne de commande
./bmdcapture -h
Pour compiler sur une ubuntu récente : https://github.com/lu-zero/bmdtools/issues/32
- soit utiliser cette version de bmdcapture https://github.com/lu-zero/bmdtools/tree/18371784a502e63807c816b12526ae066e86b254
- la placer dans le répertoire /home/simon/Téléchargements/Blackmagic DeckLink SDK 10.9/Linux/Samples/bmdtools-18371784a502e63807c816b12526ae066e86b254
make sudo cp bmdcapture /usr/bin/
Usage: bmdcapture -m <mode id> [OPTIONS] -m <mode id>: -> DeckLink SDI (-C 0 ) Supported video output display modes and pixel formats: 0: NTSC 720 x 486 29.97 FPS 1: NTSC 23.98 720 x 486 23.976 FPS 2: PAL 720 x 576 25 FPS 3: HD 1080p 23.98 1920 x 1080 23.976 FPS 4: HD 1080p 24 1920 x 1080 24 FPS 5: HD 1080p 25 1920 x 1080 25 FPS 6: HD 1080p 29.97 1920 x 1080 29.97 FPS 7: HD 1080p 30 1920 x 1080 30 FPS 8: HD 1080i 50 1920 x 1080 25 FPS 9: HD 1080i 59.94 1920 x 1080 29.97 FPS 10: HD 1080i 60 1920 x 1080 30 FPS 11: HD 720p 50 1280 x 720 50 FPS 12: HD 720p 59.94 1280 x 720 59.9401 FPS 13: HD 720p 60 1280 x 720 60 FPS -v Be verbose (report each 25 frames) -f <filename> Filename raw video will be written to -F <format> Define the file format to be used -c <channels> Audio Channels (2, 8 or 16 - default is 2) -s <depth> Audio Sample Depth (16 or 32 - default is 16) -p <pixel> PixelFormat Depth (8 or 10 - default is 8) -n <frames> Number of frames to capture (default is unlimited) -M <memlimit> Maximum queue size in GB (default is 1 GB) -C <num> number of card to be used -S <serial_device> data input serial -A <audio-in> Audio input: 1: Analog (RCA or XLR) 2: Embedded Audio (HDMI/SDI) 3: Digital Audio (AES/EBU) -V <video-in> Video input: 1: Composite 2: Component 3: HDMI 4: SDI 5: Optical SDI 6: S-Video Capture video and audio to a file. Raw video and audio can be sent to a pipe to avconv or vlc e.g.: bmdcapture -m 2 -A 1 -V 1 -F nut -f pipe:1
compil de bmdcapture : modif du code à faire !
-
- autre solution pas testée : https://github.com/lu-zero/bmdtools/issues/17
./bmdcapture -C 0 -m 5 -A 2 -V 4 -F raw -f output_file.raw
bmdcapture | ffmpeg
./bmdcapture -C 0 -m 8 -A 2 -V 4 -F nut -f pipe:1 | ffmpeg -re -i - -vcodec mpeg2video -b 6500k -acodec mp2 -ab 224k -f vob test.mpg
./bmdcapture -C 0 -c 8 -A 2 -V 3 -m 14 -F nut -f pipe:1 | ffmpeg -threads 6 -y -i - -f matroska -vcodec libx264 -preset ultrafast -qp 18 -acodec ac3 -ab 384k -ac 6 -y blackmagic.mkv
./bmdcapture -m 2 -C 0 -A 2 -V 4 -F nut -f pipe:1 |ffmpeg -re -i - -copyts -r 25 -aspect 16:9 -copyts -vcodec libx264 -vprofile main -preset medium -crf 17 -s 640x360 -b:a 196k -ar 44100 -b:v 1100k -maxrate 1300k -bufsize 1500k -pix_fmt yuv420p -y /tmp/testfile.mp4
./bmdcapture -C 0 -m 8 -A 2 -V 4 -F nut -f pipe:1 | /home/astroflux/Bureau/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -f v4l2 /dev/video10 ./bmdcapture -C 1 -m 8 -A 2 -V 4 -F nut -f pipe:1 | /home/astroflux/Bureau/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -f v4l2 /dev/video11
Possibilité de réduire la taille d'acquisition à la volée
./bmdcapture -C 1 -m 8 -A 2 -V 4 -F nut -f pipe:1 | /home/astroflux/Bureau/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -s 640x480 -f v4l2 /dev/video11
./bmdcapture -C 0 -m 2 -V 1 -F nut -f pipe:1 | /home/astroflux/Bureau/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -f v4l2 /dev/video10 ... Failed to set video input - result 80000001 pipe:: Invalid data found when processing input
Pd vlc gopro
Ligne pour [pix_video] + GoPro:
clearProps, setProps screen-fps 50, dimen 640 480, device [[http://10.5.5.9:8080/live/amba.m3u8| http://10.5.5.9:8080/live/amba.m3u8]]
Android Stream
- Pd de format de couleur pour android : http://stackoverflow.com/questions/5534032/display-yuv420p-on-android et http://developer.android.com/reference/android/graphics/Bitmap.Config.html
Minicaster Stream
configuration via l'ip de la minicaster dans le navigateur
root ****** ffmpeg -i [[udp://10.0.0.174:10000| udp://10.0.0.174:10000]] -f v4l2 /dev/video69
10.0.0.174 étant l'ip locale de l'ordinateur qui reçoit le flux
ouverture du périphérique v4l2loopback dans Pd
Ligne droite
Installer ffmpeg, v4l2loopback, Jack :
sudo apt-get install ffmpeg v4l2loopback-utils jackd xterm
Installer Pd-extended (wheezy i386) + GEM avec backend VLC + TestMosaic.zip + Readanysf
sudo apt-get install pd-readanysf
L'ajouter dans le path Edition > Préférences > New… (attention il se trouve dans pd/extra et non dans pd-extended/extra)
/usr/lib/pd/extra/readanysf~
Dans l'interface graphique de Jack : Réglages… > Options > Activer la persistance de la baie de brassage et aller chercher Brassage-AstroFlux.xml dans le dossier AstroFlux.
Surface de contrôle : Pure Data vs Alias8
Pour tester:
Mode manuel
- Créer les prériphériques vidéos virtuels (choisis ici arbitrairement: 10-13 pour les 4 flux originaux, 19 pour le montage) :
- Lancer Jack
- Lancer les deux patch Pd (vidéo/audio) sur deux instances différentes :
pd-extended audiodelaymix.pd & pd-extended TestMosaic.pd
- Lancer les différentes lignes ffmpeg :
Chaque ligne se différencient de son /dev/video.. et de son numéro de port 10001
Cam 0:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video10 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10000?pkt_size=1316| udp://10.0.0.10:10000?pkt_size=1316]]
Cam 1:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video11 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10001?pkt_size=1316| udp://10.0.0.10:10001?pkt_size=1316]]
Cam 2:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video12 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10002?pkt_size=1316| udp://10.0.0.10:10002?pkt_size=1316]]
Cam 3:
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video13 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10003?pkt_size=1316| udp://10.0.0.10:10003?pkt_size=1316]]
Montage (en 19):
ffmpeg -f jack -i ffmpeg -y -f v4l2 -s 640x480 -i /dev/video19 -vcodec libx264 -vb 150000 -g 60 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts [[udp://10.0.0.10:10019?pkt_size=1316| udp://10.0.0.10:10019?pkt_size=1316]]
Mode lanceur
Pour que la création des périphériques virtuels soit permanente il faut ajouter cette ligne à /etc/modules :
v4l2loopback video_nr=2,3,10,11,12,13,19
Script bash à créer pour tout lancer automatiquement (chemin du cd à adapter au besoin)
v4l2-ctl -d pal /dev/video0 v4l2-ctl -d pal /dev/video1 ./bmdcapture -C 0 -m 2 -V 1 -F nut -f pipe:1 | /home/astroflux/Bureau/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -f v4l2 /dev/video2 & ./bmdcapture -C 1 -m 2 -V 1 -F nut -f pipe:1 | /home/astroflux/Bureau/ffmpeg.static.64bit.2013-06-01/ffmpeg -y -i - -f v4l2 /dev/video3 & #qjackctl & #sleep 5 cd /home/astroflux/Bureau/AF #pd-extended -jack testSon.pd & sleep 5 pd-extended -noaudio -alsamidi 00-AstroFlux-Interface.pd
Autoriser l'exécution du fichier comme un programme (bt droit > propriétés > permissions).
Puis double-clic dessus et “Lancer dans un terminal”.
Pour tout fermer : ctrl+c dans la console où doivent défiler les lignes ffmpeg.
Régie icecast
sudo apt-get install oggfwd
ffmpeg -f jack -i ffmpeg -f v4l2 -i /dev/video11 -s 640x480 -r 25 -aq 2 -ac 2 -ar 44100 -acodec libvorbis -f ogg - | oggfwd labomedia.org 8000 hackme /b01stream.ogg
Variable Bitrate (VBR) Exemple
ffmpeg -i input.mkv -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 output.ogv -qscale:v – video quality. Range is 0–10, where 10 is highest quality. 5–7 is a good range to try. If you omit -qscale:v (or the alias -q:v) then ffmpeg will use the default -b:v 200k which will most likely provide a poor quality output. -qscale:a – audio quality. Range is 0–10, where 10 is highest quality. 3–6 is a good range to try. Default is -qscale:a 3.
Lien vers Ruru
Nouvelle installation sur une Ubuntu 14.04
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg jackd xterm vlc nautilus-open-terminal gnome-session-fallback puredata pd-readanysf gem pd-ggee pd-cyclone pd-maxlib
Ajouter gem, ggee, cyclone et readanysf~ dans les “path” de Puredata (le chemin est /usr/lib/pd/extra).
Ajouter “Gem” dans le “startup” de Puredata
Nouvelle installation sur une Debian Jessie
Pour ffmpeg, ajouter les dépots :
deb [[http://www.deb-multimedia.org| http://www.deb-multimedia.org]] jessie main
sudo apt-get update
sudo apt-get install ffmpeg jackd xterm vlc nautilus-open-terminal puredata pd-readanysf gem pd-ggee pd-cyclone pd-maxlib build-essential git curl
Ajouter gem, ggee, cyclone et readanysf~ dans les “path” de Puredata (le chemin est /usr/lib/pd/extra).
Ajouter “Gem” dans le “startup” de Puredata
Dans Jack, ajouter AstroFlululu.xml comme “Brassage” puis l'activer. Dans Réglages > Divers > Démarrer le serveur Jack au démarrage.
Compilation v4l2loopback pour avoir 10 devices
git clone [[https://github.com/umlaeute/v4l2loopback.git| https://github.com/umlaeute/v4l2loopback.git]]
cd v4l2loopback
make KCPPFLAGS="-DMAX_DEVICES=10"
make install
Pour que la création des périphériques virtuels soit permanente il faut ajouter cette ligne à /etc/rc.local (effectif après un redémarrage) :
sudo modprobe v4l2loopback video_nr=2,3,4,10,11,12,13,14,20
Compilation bmdcapture
Voir ici