Prosanto / xuggle

Automatically exported from code.google.com/p/xuggle
0 stars 0 forks source link

Streaming H264 media fails on decodeVideo #213

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am having problems decoding UDP packets that are sent from the VLC 
tool, which I am using as my test driver.  It is streaming via UDP the 
MPEG4 video file found at http://www.archive.org/details/NasaKsnn-
HowDoSpaceShuttlesBlastOff. 
In my Xuggler application, I receive the UDP packets, and create an 
IStreamCoder: 

IStreamCoder istreamCoder = IStreamCoder.make 
(IStreamCoder.Direction.DECODING); 
                   istreamCoder.setCodec(ICodec.ID.CODEC_ID_MPEG4); 
                   istreamCoder.setPixelType
(IPixelFormat.Type.YUV420P); //.BGR24); 
                   istreamCoder.setHeight(480); 
                   istreamCoder.setWidth(640); 
                   istreamCoder.setFlag(IStreamCoder.Flags.FLAG_TRUNCATED, 
true); 
                   int result = istreamCoder.open(); 
                   if (result < 0) 
                           throw new RuntimeException("could not open 
coder"); 

the IStreamCoder opens successfully...so far so good. Next, I follow in a 
similar 
vein the DecodeAndPlayVideo.java, but without creating a container 
since I don't have a file.  I tried creating a container passing in 
the Datagram Channel, but then it failed on the 
container.readNextPacket(), so I decided not to make a container. 
Next, I make an IPacket from the datagram packet.

final byte[] data = dpack.getData(); 
final int length = dpack.getLength(); 
IBuffer iBuffer = IBuffer.make(null, data, 0, length); 
IPacket packet = IPacket.make(iBuffer); 
int pksz = packet.getSize(); // sanity check
packet.setComplete(true, pksz); 

// This is straight from the DecodeAndPlayVideo.java
IVideoResampler resampler = null; 
if (istreamCoder.getPixelType() != IPixelFormat.Type.BGR24) 
 { 
       resampler = IVideoResampler.make(istreamCoder.getWidth(), 
                          istreamCoder.getHeight(), 
IPixelFormat.Type.BGR24, 
                          istreamCoder.getWidth(), istreamCoder.getHeight
(), 
istreamCoder.getPixelType()); 
       if (resampler == null) 
                throw new RuntimeException("could not create color space " 
+ 
                                "resampler for: " );
} 

IVideoPicture videoPicture = IVideoPicture.make 
(istreamCoder.getPixelType(), 
                        istreamCoder.getWidth(), istreamCoder.getHeight());

int offset = 0; 
 while(offset < packet.getSize()) 
{ 
// Here is where the failure occurs in this loop. 
          int bytesDecoded = istreamCoder.decodeVideo(videoPicture, 
packet, offset); 

          if (bytesDecoded < 0) 
            throw new RuntimeException("got error decoding video in: 
"); 
          offset += bytesDecoded; 

} // end while 

The istreamCoder.decodeVideo(videoPicture, packet, offset) call generates
these errors: 

ERROR org.ffmpeg - [mpeg4 @ 0xae26970] hmm, seems the headers are not 
complete, trying to guess time_increment_bits 
ERROR org.ffmpeg - [mpeg4 @ 0xae26970] my guess is 8 bits ;) 
ERROR org.ffmpeg - [mpeg4 @ 0xae26970] hmm, seems the headers are not 
complete, trying to guess time_increment_bits 
ERROR org.ffmpeg - [mpeg4 @ 0xae26970] my guess is 2 bits ;) 
looks like this file was encoded with (divx4/(old)xvid/opendivx) -> 
forcing low_delay flag 
warning: first frame is no keyframe 
ac-tex damaged at 0 0 
Error at MB: 0 
concealing 1200 DC, 1200 AC, 1200 MV errors 
# An unexpected error has been detected by Java Runtime Environment: 

Original issue reported on code.google.com by p_gac...@yahoo.com on 22 Sep 2009 at 9:56

GoogleCodeExporter commented 9 years ago
The problem is I think related to not setting enough parameters to the 
IStreamCoder.
At least the timebase should be specified. I encountered the same errors as 
above
while decoding mpeg4 frames - secifying the timebase (which is 1/framerate) 
solved
the issue.

Original comment by beb...@gmail.com on 14 Jan 2010 at 12:35