API de transmisión en vivo de YouTube: la transmisión no aparece en Youtube

Estoy tratando de transmitir video desde mi cámara web a YouTube usando Xuggler y la API de transmisión en vivo de YouTube. Tuve éxito al conectarme a YouTube y al crear una transmisión siguiendo el ejemplo proporcionadoaquí.

Usé Xuggler para codificar los videos y enviarlos a YouTube usando el código a continuación. Los pasos para codificar los videos se toman de una publicaciónaquí.

No recibo ningún error en mi consola cuando ejecuto mi programa, pero la transmisión no se activará en Youtube. En la sala de control de Youtube Live, sigue mostrando un mensaje que dice "No estamos recibiendo datos de su codificador. Asegúrese de que esté configurado correctamente en la página Configuración de ingestión".

¿Qué estoy haciendo mal? Cualquier ayuda o consejos serán muy apreciados ...

String url =  returnedStream.getCdn().getIngestionInfo().getIngestionAddress(); 
String fileName = returnedStream.getCdn().getIngestionInfo().getStreamName() ;

IContainer container = IContainer.make();
IContainerFormat containerFormat_live = IContainerFormat.make();
containerFormat_live.setOutputFormat("flv", url + "/"+ fileName, null);
container.setInputBufferLength(0);
int retVal = container.open(url + "/"+ fileName, IContainer.Type.WRITE, containerFormat_live);
if (retVal < 0) {
    System.err.println("Could not open output container for live stream");
    System.exit(1);
}

Dimension size = WebcamResolution.QVGA.getSize();

IStream stream = container.addNewStream(0);
IStreamCoder coder = stream.getStreamCoder();
ICodec codec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_H264);
coder.setNumPicturesInGroupOfPictures(4);
coder.setCodec(codec);
coder.setBitRate(500000);
coder.setPixelType(IPixelFormat.Type.YUV420P);
coder.setHeight(size.height);
coder.setWidth(size.width);

System.out.println("[ENCODER] video size is " + size.width + "x" + size.height);
coder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
coder.setGlobalQuality(0);
IRational frameRate = IRational.make(24, 1);
coder.setFrameRate(frameRate);
coder.setTimeBase(IRational.make(frameRate.getDenominator(), frameRate.getNumerator()));

coder.open();
container.writeHeader();
long firstTimeStamp = System.currentTimeMillis();
long lastTimeStamp = -1;
int i = 0;
try {
    //Robot robot = new Robot();
    Webcam webcam = Webcam.getDefault();
    webcam.setViewSize(size);
    webcam.open(true);

    while (i < framesToEncode) {
        //long iterationStartTime = System.currentTimeMillis();
        long now = System.currentTimeMillis();
        //grab the screenshot
        BufferedImage image = webcam.getImage();
        //convert it for Xuggler
        BufferedImage currentScreenshot = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
        currentScreenshot.getGraphics().drawImage(image, 0, 0, null);
        //start the encoding process
        IPacket packet = IPacket.make();
        IConverter converter = ConverterFactory.createConverter(currentScreenshot, IPixelFormat.Type.YUV420P);
        long timeStamp = (now - firstTimeStamp) * 1000; 
        IVideoPicture outFrame = converter.toPicture(currentScreenshot, timeStamp);
        if (i == 0) {
            //make first frame keyframe
            outFrame.setKeyFrame(true);
        }
        outFrame.setQuality(0);
        coder.encodeVideo(packet, outFrame, 0);
        outFrame.delete();
        if (packet.isComplete()) {
            container.writePacket(packet);
            System.out.println("[ENCODER] writing packet of size " + packet.getSize() + " for elapsed time " + ((timeStamp - lastTimeStamp) / 1000));
            lastTimeStamp = timeStamp;
        }
        System.out.println("[ENCODER] encoded image " + i + " in " + (System.currentTimeMillis() - now));
        i++;
        try {
            Thread.sleep(Math.max((long) (1000 / frameRate.getDouble()) - (System.currentTimeMillis() - now), 0));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
} catch (Exception e) {
    e.printStackTrace();
}

Respuestas a la pregunta(0)

Su respuesta a la pregunta