ravi
unread,May 2, 2013, 8:05:56 AM5/2/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xuggler-users
Hi,
In my project i need to send Video (audio and video packets) from
server to client machine and reconstruct Video at server. I am using
Sockets programming to send packets from server to client. At server,
for each IPacket i will get the byte array and send it to client,
followed by sending IPacket attributes such as timestamp, keyfame,
duration, position and size.
At client i make sure that i received all the bytes and reconstruct
the packet as follows:
byte[] data = .... (byte array received from server)
IPacket packet = IPacket.make(IBuffer.make(null, data, 0,
data.length));
packet.setTimeStamp(timeStamp);
packet.setDuration(dur);
packet.setPts(timeStamp);
packet.setPosition(position);
timeStamp = timeStamp + dur;
packet.setKeyPacket(isKey);
packet.setTimeBase(IRational.make(1, 25));
When I tried to encode this packet into a container, all the
IVideoPicture have complete attribute set to false. I am decoding
IPackets at client side as follows:
IMediaWriter writer = ToolFactory.makeWriter("output.mp4");
ICodec videocodec =
ICodec.findEncodingCodec(strVideoCodec.getCodecID());
writer.addVideoStream(0, 0, videocodec, IRational.make(25, 1),
704, 576);
writer.addAudioStream(1, 1, 2, 32000);
IVideoPicture videoPicture =
IVideoPicture.make(IPixelFormat.Type.YUV420P, 704, 576);
int offset = 0;
while (offset < packet.getSize()) {
int bytesDecoded = strVideoCodec.decodeVideo(videoPicture, packet,
offset);
if (bytesDecoded < 0) {
System.out.println("Error while decoding video in source");
System.exit(0);
}
offset += bytesDecoded;
if (videoPicture.isComplete()) {
//encode videoPicture
}
}
This code works perfectly for RAW video format, however for
compressed MP4 file the videopicture are not complete, even for KEY
Frames. Please correct me if i am doing something wrong or missing
something.
regards,
Ravi.