Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTSP to RTMP Transcoding failure #162

Open
zpg0624 opened this Issue Mar 26, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@zpg0624
Copy link

zpg0624 commented Mar 26, 2019

public RTMPWriter(int height, int width, double frameRate, String appName) {
container = IContainer.make();
IContainerFormat containerFormat = IContainerFormat.make();
containerFormat.setOutputFormat("flv", url + appName, null);
// set the buffer length xuggle will suggest to ffmpeg for reading inputs
container.setInputBufferLength(0);
int retVal = container.open(url + appName, IContainer.Type.WRITE,
containerFormat);
if (retVal < 0) {
logger.error("Could not open output container for live stream");
} else {
logger.info("hava opened server " + url + appName + " for write!");
}
IStream stream = container.addNewStream(0);
coder = stream.getStreamCoder();
ICodec codec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_H264);
if (codec == null) {
logger.warn("cannot find h264 encoding codec!");
Collection icodec_collections = ICodec.getInstalledCodecs();
Iterator iterator = icodec_collections.iterator();
while (iterator.hasNext()) {
ICodec icodec = iterator.next();
logger.info("Your system supports codec:" + icodec.getName());
}
} else {
coder.setCodec(codec);
}
coder.setNumPicturesInGroupOfPictures(5);
coder.setBitRate(256000);
coder.setPixelType(IPixelFormat.Type.YUV420P);
if (width == 0 || height == 0) {
logger.error("cannot get the real size of the stream needed to read");
}
coder.setHeight(height);
coder.setWidth(width);
coder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
coder.setGlobalQuality(0);
IRational rationalFrameRate = IRational.make(frameRate);
coder.setFrameRate(rationalFrameRate);
coder.setTimeBase(IRational.make(rationalFrameRate.getDenominator(),
rationalFrameRate.getNumerator()));
coder.open();
logger.info("[ENCODER] address: " + url + appName +
"\n video size is " + width + "x" + height
+ " and framerate is " + frameRate);
if (container.writeHeader() < 0)
throw new RuntimeException("cannot write header");
}

The error is as follows
15:48:10.958 [Thread-0] WARN com.xuggle.xuggler - Error: no codec set for coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:831)
15:48:10.958 [Thread-0] INFO RTMPWriter - [ENCODER] address: rtmp://localhost:1935/live/
video size is 1000x1000 and framerate is 300.0
15:48:24.920 [Thread-0] WARN com.xuggle.xuggler - Got error: Attempting to encode video with non video coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1430)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.