[Red5] Saving live stream problem

pankaj anand pankajanand18 at gmail.com
Fri Jun 5 02:50:12 PDT 2009


Hi folks,  I tried this following code to save a  live stream as soon as the
client start publishing the stream.

package org.red5.Recording;

import java.util.Timer;
import java.util.TimerTask;



import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.stream.ClientBroadcastStream;
import org.slf4j.Logger;

import com.xuggle.xuggler.IContainer;

public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter
{
 private static final Logger log =
Red5LoggerFactory.getLogger(ScopeApplicationAdapter.class, "recording");
private static ScopeApplicationAdapter instance;




public static ScopeApplicationAdapter getInstance()
{
return instance ;
}
 @Override
public boolean appStart(IScope scope)
{
try
{
instance=this;
System.out.println("Scope Started ");
log.debug("Scope started"+ scope);
}
catch(Exception e)
{
log.error("Error at roomStart"+e);
 }
return true;
}
/**
 * Delegate method used to accept/reject incoming connection requests.
 *
 * @param conn
 * @param params
 * @return true/false
 */
@Override
public boolean roomConnect(IConnection conn, Object[] params) {
log.debug("New connection attempt from " + conn.getRemoteAddress() + "...");
// Insure that the listeners are properly attached.
return super.roomConnect(conn, params);
}

/**
 * Delegate method which logs connection/client/user disconnections.
 *
 * @param conn
 */
@Override
public void roomDisconnect(IConnection conn) {
log.debug("Connection closed by " + conn.getRemoteAddress() + "...");
// Call the super class to insure that all listeners are properly
// dismissed.
super.roomDisconnect(conn);
}

public void pringMsg(String msg)
{
log.debug("Msg recived from the client"+msg);
}

public void streamBroadcastStart(IBroadcastStream stream)
{
log.debug("Stream received "+stream.getName() );
log.debug("Codec Used"+stream.getCodecInfo());
log.debug("Provider"+ stream.getProvider());
log.debug("log"+stream.getPublishedName());
try
{
stream.saveAs(stream.getName(), false);

}catch(Exception e)
{
log.error("Error in streamBroadcastStart "+e);
 }
}
 public void streamBroadcastClose(IBroadcastStream stream)
{
log.debug("Stream closed"+stream.getName() );
try
{
((ClientBroadcastStream) stream).stopRecording();
 }catch(Exception e)
{
log.error("Error in streamBroadcastStart "+e);
 }
}
}


The stream gets saved using this code and gets play back easily with some
media player.  But when i m using xuggler to play that file , it genrates
the excetpion
"Bad picture data" .

am i doing anything wrong in saving the stream ?


I m using an application called "OpenMeetings" which is based on Red5
itself. When i save the file with openmeetings , it creates the flv file as
well as .meta file contains the key frame information.

With my code it doesn't generate that .meta file.

please help..

with regards
Pankaj anand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/red5_osflash.org/attachments/20090605/3beaf072/attachment.html>


More information about the Red5 mailing list