Tout d'abord, merci en avance pour vos efforts de lire mon problème et de m'aider

Je résume la situation :
[OBJECTIF DE L'APPLICATION]
- Utiliser le webcam pour enregistrer la vidéo (avecl'application oflaDemo)
- Quand l'enregistrement se termine, on clique le bouton 'lire' pour vérifier l'enregistrement.
[/OBJECTIF DE L'APPLICATION]
[CE QUI FONCTIONNE]
- la connexion du webcam
- la connexion d'un flux
- l'enregistrement de la vidéo (la vidéo se trouve bien dans oflaDemo/streams/*.flv)
[/CE QUI FONCTIONNE]
[CE QUI NE FONCTIONNE PAS]
- la lecture de la vidéo
[/CE QUI NE FONCTIONNE PAS]
[MES TESTS]
Quand je clique sur le bouton 'lire', la vidéo apparait bien mais ne lit pas la vidéo, l'image reste figée....
J'ai essayé d'ouvrir cette vidéo avec VLC, ca lit mais, au début, l'image reste figée au bout de 2 ou 3 secondes et puis ca lit ...
J'ai vérifié le .meta de cette vidéo, j'ai constaté une chose qui pourrait être le probleme :
- ca commence par "<KeyFrame position="1182" timestamp="5493"/>".
J'ai comparé les autres .meta ('toystory3.flv', par exemple), il commence bien à 0 ...
J'ai utilisé la vidéo 'toystory3' dans mon application et ca se lit très bien ...
[/MES TESTS]
[PROBLEME ?]
A vos avis, c'est bien l'origine de ce problème (sur le timestamp qui ne commence pas par 0)? Si oui, donc le probleme vient l'enregistrement de la vidéo ?
Si vous avez déjà vécu ce probleme, n'hésistez pas de me proposer une solution :-D Merciiiiiiiii beaucoup !!!
[/PROBLEME ?]
[REGLAGE]
- serveur RED5 en local
- window 7
- je developpe avec l'IDE FlashDevelop
- Flex4 + AS3
Si vous avez besoin plus d'information, n'hésistez pas de me le demander.
[/REGLAGE]
[APPLICATION]
La fonction qui permet de connecter au serveur red5
public function init():void {
this.bouton_lecture.visible = false;
// Instanciation d'une nouvelle connection
this.netConnect = new NetConnection();
this.netConnect.connect("rtmp://localhost/oflaDemo");
this.netConnect.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
this.netConnect.client = this;
}
Ensuite la fonction qui permet d'utiliser le webcam
public function onNetStatus(event:NetStatusEvent):void {
if ( event.info.code == "NetConnection.Connect.Success" ) {
this.netStream = new NetStream(this.netConnect); //création un flux sur NetStream
var Client:Object = new Object();
Client.onMetaData = receiveMetaData ;
this.netStream.client = Client;
//réglage du webcam
this.webcam = Camera.getCamera();
this.webcam.setMode(this.resolutionWidth,this.resolutionHeight,this.fps,true);
this.webcam.setQuality(0,this.cameraQualite);
this.micro = Microphone.getMicrophone();
this.micro.rate = 44;
//attacher le webcam
this.netStream.attachCamera(this.webcam);
this.netStream.attachAudio(this.micro);
this.ecran.attachCamera(this.webcam);
this.netStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
}
else{
Alert.show('Error');
}
}
La fonction qui permet enregistrer la vidéo via webcam
public function enregistrerVideo(e:Event):void {
if (this.bouton_enregistrement.label=="Enregistrer") {
this.bouton_enregistrement.label="Stopper";
this.netStream.publish(this.nomVideo, "record");
} else {
this.netStream.close();
this.bouton_lecture.visible = true;
this.bouton_enregistrement.visible=false;
}
}
La fonction qui permet de lire la vidéo
public function lireVideo(e:Event):void {
this.lecteurVideo = new Video(400,320);
this.lecteurVideo.attachNetStream(this.netStream);
this.netStream.play(this.nomVideo);
this.ecran.addChild(this.lecteurVideo);
}
Le code complete
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="640" minHeight="515"
creationComplete="init()">
<fx:Script>
<![CDATA[
import flash.media.Video;
import mx.controls.Alert;
private var netConnect:NetConnection;
private var netStream:NetStream;
private var webcam:Camera;
private var micro:Microphone;
private var nomVideo:String = 'test';
private var lecteurVideo:Video;
//WEBCAM : parametre par défaut
private var resolutionWidth:int = 320;
private var resolutionHeight:int = 290;
private var fps:int = 20;
private var cameraQualite:int = 80;
/*******************************************
* FONCTION D'INITIALISATION
********************************************/
public function init():void {
this.bouton_lecture.visible = false;
// Instanciation d'une nouvelle connection
this.netConnect = new NetConnection();
this.netConnect.connect("rtmp://localhost/oflaDemo");
this.netConnect.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
this.netConnect.client = this;
}
/*******************************************
* PRINCIPALES FONCTIONS
********************************************/
public function onNetStatus(event:NetStatusEvent):void {
if ( event.info.code == "NetConnection.Connect.Success" ) {
this.netStream = new NetStream(this.netConnect); //création un flux sur NetStream
var Client:Object = new Object();
Client.onMetaData = receiveMetaData ;
this.netStream.client = Client;
//réglage du webcam
this.webcam = Camera.getCamera();
this.webcam.setMode(this.resolutionWidth,this.resolutionHeight,this.fps,true);
this.webcam.setQuality(0,this.cameraQualite);
this.micro = Microphone.getMicrophone();
//attacher le webcam
this.netStream.attachCamera(this.webcam);
this.netStream.attachAudio(this.micro);
this.ecran.attachCamera(this.webcam);
this.netStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
}
else{
Alert.show('Error');
}
}
public function enregistrerVideo(e:Event):void {
if (this.bouton_enregistrement.label=="Enregistrer") {
this.bouton_enregistrement.label="Stopper";
this.netStream.publish(this.nomVideo, "record");
} else {
this.netStream.close();
this.bouton_lecture.visible = true;
this.bouton_enregistrement.visible=false;
}
}
public function lireVideo(e:Event):void {
this.lecteurVideo = new Video(400,320);
this.lecteurVideo.attachNetStream(this.netStream);
this.netStream.play(this.nomVideo);
this.ecran.addChild(this.lecteurVideo);
}
/*******************************************
* FONCTIONS DE TEST
********************************************/
public function receiveMetaData(info:Object):void{
trace("info="+ info.duration);
}
public function statusHandler(event:NetStatusEvent):void {
switch (event.info.code){
case "NetStream.Play.Start":
trace("Start [" + this.netStream.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop":
trace("Stop [" + this.netStream.time.toFixed(3) + " seconds]");
break;
}
}
]]>
</fx:Script>
<s:Panel width='552' height='455' id="panel">
<mx:VideoDisplay id="ecran" width="552" height="420" source="">
</mx:VideoDisplay>
<s:controlBarContent>
<s:Button label="Enregistrer" id='bouton_enregistrement' height="35" click='enregistrerVideo(event)'/>
<s:Button label="Lire" id="bouton_lecture" height="35" click="lireVideo(event)" />
</s:controlBarContent>
</s:Panel>
</s:Application>
Grand merci à vous
