Extracting KLV

1,653 views
Skip to first unread message

ecks

unread,
Feb 10, 2010, 2:36:26 PM2/10/10
to xuggler-users
Hello xuggler-users,

I am trying to extract a KLV stream embedded in an MPEG file. Is this
possible with Xuggler? After seeing
http://groups.google.com/group/xuggler-users/browse_thread/thread/1f7db711ed56dcb8,
it seems possible but I'm having some difficulties.

I've been playing with the DecodeAndPlayVideo demo. As the video
plays, I want to dump out the KLV data to console. I've modified the
demo so I know what IPackets are the KLV data but I'm not sure what
the next step is. Should I be working with an IBuffer to do this
(packet.getData())? Is there some kind of built in mechanism that I'm
missing? If anyone has a piece of code or example to get me started,
that would be great. I'm not very good at working byte arrays and
buffers in Java and seems like this will be required at some point.
Any help is appreciated! Thanks!

Art Clarke

unread,
Feb 10, 2010, 3:20:31 PM2/10/10
to xuggle...@googlegroups.com
Hi Ecks,

You've got the flow basically correctly; You'll use IPacket.get(...) (it'll be faster that getData().getByteBuffer()), and then parse the KLV data yourself.

- Art


--
You received this message because you are subscribed to the Google Groups "xuggler-users" group.
To post to this group, send email to xuggle...@googlegroups.com.
To unsubscribe from this group, send email to xuggler-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xuggler-users?hl=en.




--
http://www.xuggle.com/
xu‧ggle (zŭ' gl) v. To freely encode, decode, and experience audio and video.

Use Xuggle to get the power of FFmpeg in Java.

Teddy Yueh

unread,
Feb 10, 2010, 3:35:01 PM2/10/10
to xuggler-users
Hey ecks,

Take a look at the KLV class that's provided here:
http://iharder.sourceforge.net/current/java/klv/

You can pass the packet data as such:

(assuming you have an IPacket packet)
byte[] data = packet.getData().getByteArray(0,
packet.getData().getSize());
List<KLV> klvs = KLV.bytesToList(data, 0, data.length,
KLV.KeyLength.SixteenBytes, KLV.LengthEncoding.BER);

That would give you all of the KLV's from that packet in a nice List
to work with, but beware that sometimes, you'd need to make sure that
the KLV are not wrapped by a checksum KLV. In other words, sometimes,
the KLV byte stream could be: <checksum key><checksum data
length><real KLV list stream>

Good luck!

-Teddy

On Feb 10, 12:36 pm, ecks <hine...@gmail.com> wrote:
> Hello xuggler-users,
>
> I am trying to extract a KLV stream embedded in an MPEG file. Is this

> possible with Xuggler? After seeinghttp://groups.google.com/group/xuggler-users/browse_thread/thread/1f7...,

Art Clarke

unread,
Feb 10, 2010, 3:39:51 PM2/10/10
to xuggle...@googlegroups.com
But let me reiterate... use IPacket.get(....), not IPacket.getData().getByteArray(); it's a MUCH simpler API and it's faster (please don't ask me why) :)

- Art

--
You received this message because you are subscribed to the Google Groups "xuggler-users" group.
To post to this group, send email to xuggle...@googlegroups.com.
To unsubscribe from this group, send email to xuggler-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xuggler-users?hl=en.

ecks

unread,
Feb 11, 2010, 12:34:08 PM2/11/10
to xuggler-users
Thanks for the help Art and Teddy, I'm making some progress now. Now
begins the fun of converting these values to strings, decimals, times,
lat/long, etc. :)

> > xuggler-user...@googlegroups.com<xuggler-users%2Bunsubscribe@goog legroups.com>


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/xuggler-users?hl=en.
>

> --http://www.xuggle.com/

Teddy Yueh

unread,
Feb 11, 2010, 1:04:40 PM2/11/10
to xuggler-users
That KLV library I pointed you to has that functionality. There's a
lot of getValueAs______ methods to return the value in a lot of
formats =). Are you trying to sent that KLV data back out? If so, I'm
trying to get that to work now with little to no luck =/.

ecks

unread,
Feb 11, 2010, 1:18:34 PM2/11/10
to xuggler-users
For now I'm just trying to get the data out so it can be stored in a
database. In the future I may need to take it out and put it back in
if we decide to use Xuggler for video conversion (assuming the KLV
stream needs to be separated when doing conversions).
Reply all
Reply to author
Forward
0 new messages