Richard Bruno
navigation
Home
admin









Traitements et diffusion de videos
October 18th, 2016

Objectif : diffusion de vidéos sur le net en pseudo-streaming (possibilité de se déplacer dans la vidéo sans attendre son téléchargement complet)

Table des matières


Vidéo
Pseudo-streaming
Module Apache H264
Moov Atom
MP4Box
JW Player


Vidéo


On utilisera ffmpeg pour construire une vidéo ayant les caractéristiques suivantes
- container MP4
- codec vidéo libx264
- codec audio aac

Les formats supportés sont indiqués ici :
http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12539/supported-video-and-audio-formats

Exemple de ligne de commande :

ffmpeg -y -strict experimental -i video.wmv -vcodec libx264 -vpre libx264-normal -b 768k -acodec aac -ab 128k -ar 44100 -ac 2 -vf "movie=0:jpg:logo-70.jpg [logo];[in]scale=480:360,[logo] overlay=393:18,pad=640:360:80:0:black" -s 640x360 -aspect 16:9 -r 30 -y video.mp4




Pseudo-streaming


"For HTML5 mode, pseudostreaming works by default in all browsers and with all servers. It needs no specific provider and options."
Source : http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12534/video-delivery-http-pseudo-streaming
Mais on n'y est pas encore...
http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/22644/using-the-html5-video-tag#player

on fait comment alors ?

On peut utiliser des solutions comme xmoovstream + flvtool + container flv

On peut utiliser un container mp4 (vid x264, audio aac) + un module coté serveur http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Apache-Version2

cf http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12534/video-delivery-http-pseudo-streaming

Module Apache H264


Installation


wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar zxvf apache_mod_h264_streaming-2.2.7.tar.gz
cd mod_h264_streaming-2.2.7/
./configure --with-apxs=`which apxs2`
make
make install
vi /etc/apache2/apache2.conf
// Ajout des lignes :
LoadModule h264_streaming_module /usr/lib/apache2/modules/mod_h264_streaming.so
AddHandler h264-streaming.extensions .mp4



Tests

wget http://h264-demo.code-shop.com/demo/apache/workers_world_co64_box64.mp4
wget http://video/workers_world_co64_box64.mp4?start=45.5
ls -al
[...]
-rw-r--r-- 1 root root 50230160 jui 22 2011 workers_world_co64_box64.mp4
-rw-r--r-- 1 root root 45920132 jui 22 2011 workers_world_co64_box64.mp4?start=45.5


On voit bien que seule une partie du fichier a été téléchargée.


Moov Atom



H.264 files and metadata
In H.264-based video formats (mp4, m4v) the metadata is called a "moov atom". The moov atom is a part of the file that holds the index information for the whole file.

Many encoding software programs such as FFMPEG will insert this moov atom information at the end of the video file. This is bad. The moov atom needs to be located at the beginning of the file, or else the entire file will have to be downloaded before it begins playing.

Fortunately, Renaun Erickson at Adobe has kindly created a small AIR application that will take a standard H.264 file and relocate the moov atom to the front of the file, and then progressive downloading works properly. Running your video file through this application makes your MP4 files ready for pseudostreaming. Of course you need to have those keyframes in place (see above).

Another good project for PHP applications is MOOV Relocator which is a well documented small library written in PHP to relocate (or move) the MOOV-Atom of MP4-Files from the end to the beginning of a file.
Source : http://flowplayer.org/plugins/streaming/pseudostreaming.html

On peut aussi utiliser MP4Box.
http://www.longtailvideo.com/support/forums/jw-player/video-encoding/10436/ffmpeg-mp4box-h264-question

MP4Box -inter 0.5 video.mp4



Pour vérifier le positionnement de ces métadatas : (cf doc http://www.adobe.com/devnet/video/articles/mp4_movie_atom.html) on peut utiliser ce soft : http://www.dvbportal.de/projects/mp4muxer/
Si les métadatas sont positionnées en tête de fichier, on a :
ftyp > moov > mdat
Si ca n'est pas le cas, on a :
ftyp > mdat > moov


MP4Box



Concaténation
MP4Box permet de déplacer les métadatas (cf ci-dessus). Il permet également de concaténer des fichiers mp4.
Exemple :

MP4Box -add titre.mp4 -cat corps.mp4 -new final.mp4



Message d'erreur 1
Attention, on peut avoir des messages du genre :

[...]
IsoMedia import - track ID 1 - Video (size 640 x 360)
IsoMedia import - track ID 2 - Audio (SR 44100 - 1 channels)
Appending file final.mp4
No suitable destination track found - creating new one (type soun)
Saving final.mp4: 0.500 secs Interleaving


Solution : il semble qu'avec du aac, on ne puisse pas concaténer un fichier coder un mono avec un autre codé en stéréo.

Message d'erreur 2

Error renaming file out_[...] to [...]


Solution :
Utiliser l'option -out
Source : http://www.tivocommunity.com/tivo-vb/showthread.php?t=416858&page=44

JW Player


On utilise JW player
http://www.longtailvideo.com/players/

Doc intéressante : http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12534/video-delivery-http-pseudo-streaming
Attention, avec apache et son module h264, il faut définir 'http.startparam':'start'
et non pas 'http.startparam':'starttime' comme indiqué.

Exemple de page html

<html><body><div id="mediaplayer">JW Player goes here</div>
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "/jwplayer/player.swf",
file: "video-aac.mp4",
image: "titre.jpg",
height: "360",
width: "640",
"controlbar.idlehide": "true",
provider: "http",
"http.startparam": "starttime"
});
</script>
</body>
</html>




Dernières modifs
Gatekeeper (October 18th, 2016)
Jabber (October 18th, 2016)
Traitements et diffusion de videos (October 18th, 2016)
Vlc (October 18th, 2016)

Contact
Pour m'envoyer un mail,
Pour me laisser un commentaire :
richard.brunooo
chez
gmail.com


powered by kure, modified by Bruno