![]() | ![]() | ||
Lecture via HTTPIl est possible de lire un fichier vidéo en passant simplement par un serveur HTTP. C'est la technique la plus fiable mais elle demande le réencodage préalable des vidéos. Seuls certains conteneurs permettent de se déplacer dans la vidéo. Encodage
ffmpeg -i "video.avi" -vcodec mpeg4 -b 400k -acodec mpeg4aac -ab 96k -s 400x304 -y "video.mp4"
ffmpeg -i "video.avi" -vcodec h264 -b 400k -acodec mpeg4aac -ab 96k -s 400x304 -y "video.mp4" rq : vérifier si le birate vidéo est bien pris en compte (bug ffmpeg?)
mencoder video_source.avi -nosound -of rawvideo -ovc x264 -x264encopts threads=2:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=2:b_pyramid:weight_b:qp=26 -o video_finale.h264 mplayer -msglevel all=1 -ao pcm:waveheader:fast:file=video_finale.wav -vc null -vo null video_source.avi wine enc_aacplus.exe video_finale.wav video_finale.aac --cbr 0.1 MP4Box -fps 25 -add video_finale.h264 -add video_finale.aac video_finale.mp4 rm -f video_finale.h264 video_finale.aac video_finale.wav Quelques infos supplémentaires sont sur la page CreerVideoFlv, section "Vidéo au format Flash 9.0 r60+ MP4 / H264".
Le vorbis n'est pas officiellement supporté par le conteneur MP4 mais MP4Box le gère très bien et ces fichiers sont lisibles (entre autres) sur : - mplayer - Windows Media Player après avoir installé Haali Media Splitter et FFdshow (le plugin WMP ie/firefox fonctionne aussi) mencoder "video.avi" -nosound -of rawvideo -ovc x264 -x264encopts qp=30:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -vf scale=400x304 -o "video_tmp.h264" && \ mplayer -vc null -vo null -ao pcm:fast:file="video_tmp.wav" "video.avi" && \ oggenc "video_tmp.wav" && \ rm -f "video.mp4" && \ MP4Box -add "video_tmp.h264"#video -add "video_tmp.ogg" "video.mp4" && \ rm -f "video_tmp.h264" "video_tmp.wav" "video_tmp.ogg" rq : j'ai utilisé mencoder pour l'encodage h264 car ffmpeg ne semblait pas suivre le débit demandé
Remarque sur l'AAC : Les fichiers contenant de l'audio AAC générés par ffmpeg entrainent un petit warning "FAAD: compressed input bitrate missing, assuming 128kbit/s!" lors de leur relecture par mplayer. Pour le supprimer, vous pouvez par exemple lancer : MP4Box -add "video.mp4" "video_aacfixed.mp4" Lecture
mplayer -cache 20000 -cache-min 5 -cache-seek-min 2 http://adresse/fichier.mp4 Les valeurs de cache sont en kilooctets. J'utilise 20Mo pour être sur de ne pas avoir de coupure (serveur sur simple ligne ADSL) mais vous pouvez utiliser vos propres valeurs.
Streaming via VideoLan- site officiel∞ - doc officielle sur la diffusion∞
vlc -vvv "video.avi" -I ncurses --sout '#transcode{width=400,height=304,vcodec=mp4v,venc=ffmpeg{keyint=50,hurry-up,trellis},acodec=mp3,vb=500,ab=64,audio-sync,channels=1}:std{access=udp,mux=ts,dst=127.0.0.1:6000,sap,name="TestStream"}'
vlc -vvv "video.avi" -I ncurses --sout '#transcode{width=400,height=304,vcodec=mp4v,venc=ffmpeg{keyint=50,hurry-up,trellis},acodec=vorb,vb=500,ab=64,audio-sync,channels=1}:std{access=http,mux=ogg,dst=:6000}'
vlc -vvv "video.avi" -I ncurses --sout '#transcode{width=400,height=304,vcodec=h264,venc=x264{keyint=50},acodec=mp3,vb=500,ab=64,audio-sync,channels=1}:std{access=http,mux=ts,dst=:6000}'
vlc -vvv "video.avi" -I ncurses --sout '#transcode{width=400,height=304,vcodec=DIV3,acodec=mp3,vb=500,ab=64,audio-sync,channels=1}:std{access=mmsh,mux=asfh,dst=:6000}'
Streaming via ffserver- site officiel∞ Configurer ffserver.conf (en se basant sur /usr/share/doc/packages/ffmpeg/doc/ffserver.conf) Exemple : # Port on which the server is listening. You must select a different # port from your standard HTTP web server if it is running on the same # computer. Port 8090 # Address on which the server is bound. Only useful if you have # several network interfaces. BindAddress 0.0.0.0 # Number of simultaneous requests that can be handled. Since FFServer # is very fast, it is more likely that you will want to leave this high # and use MaxBandwidth, below. MaxClients 1000 # This the maximum amount of kbit/sec that you are prepared to # consume when streaming to clients. MaxBandwidth 1000 # Access log file (uses standard Apache log file format) # '-' is the standard output. CustomLog - # Suppress that if you want to launch ffserver as a daemon. NoDaemon ################################################################## # Definition of the live feeds. Each live feed contains one video # and/or audio sequence coming from an ffmpeg encoder or another # ffserver. This sequence may be encoded simultaneously with several # codecs at several resolutions. <Feed feed1.ffm> File /tmp/feed1.ffm FileMaxSize 200K ACL allow 127.0.0.1 </Feed> ################################################################## # Now you can define each stream which will be generated from the # original audio and video stream. Each format has a filename (here # 'test1.mpg'). FFServer will send this stream when answering a # request containing this filename. <Stream test_webcam.flv> Feed feed1.ffm VideoBitRate 5200 # Experiment to get rid of rc buffer underflow error. Max is 16000 VideoBufferSize 32 # Adjust in conjunction with q and bitrate. 128 is a safe value Format swf VideoSize 352x288 # CIF size VideoFrameRate 29.97 VideoQMin 3 # Adjust bitrate with q (see below). VideoQMax 3 NoAudio </Stream> <Stream test_webcam.rm> Feed feed1.ffm Format rm VideoFrameRate 15 VideoSize 352x240 VideoBitRate 256 VideoBufferSize 40 VideoGopSize 30 StartSendOnKey NoAudio </Stream> <Stream test_fichier.rm> Feed feed1.ffm Format rm VideoSize 512x288 VideoFrameRate 25 VideoGopSize 25 VideoBitRate 600 AudioBitRate 64 </Stream> <Stream stat.html> Format status # Only allow local people to get the status ACL allow localhost ACL allow 192.168.0.0 192.168.255.255 #FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico </Stream> Lancer : ffserver -f ffserver.conf Pour une webcam : ffmpeg -deinterlace -r 29.97 -s cif -qmin 3 -qmax 3 -f video4linux -i /dev/video1 http://localhost:8090/feed1.ffm Pour un fichier .avi : ffmpeg -i video.avi http://localhost:8090/feed1.ffm Mémo (infos en vrac)Rediriger la sortie standard de mplayer vers un pipe : mplayer fichier.avi -dumpstream -dumpfile /dev/fd/3 3>&1 1>&2 | vlc - | |||
![]() | ![]() |