Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MPEG2 transport streams and Tk

12 views
Skip to first unread message

Alexandre Ferrieux

unread,
Jan 5, 2008, 4:14:15 PM1/5/08
to
Hi,

I'd like to know the simplest way of peeking at random images
(keyframes) in an MPEG2 transport stream.
The idea is to be able to seek to various offsets in the file,
identify the closest keyframe, and display it in Tk.
With this I can then write a simple and efficient tool to cut such TS
files where I want.

I have so far managed to demux the lowest level of the format
("PIDs"), but the next higher layer is much more complicated. I'm not
yet able to home in on a keyframe, let alone to decode it (it seems
its is not plain JPEG, though it's something similar). So, any help on
these two blocking points would help me tremendously.

Alternatively, a way of reading TS files within TkVideo would do the
job too.

TIA,

-Alex

Uwe Klein

unread,
Jan 5, 2008, 4:36:48 PM1/5/08
to

Alexandre Ferrieux

unread,
Jan 5, 2008, 5:11:55 PM1/5/08
to
On Jan 5, 10:36 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:

>
> What about wrapping transcode?
>        http://en.wikipedia.org/wiki/Transcode
>        http://freshmeat.net/search/?q=transcode§ion=projects&Go.x=0&Go.y=0
> uwe- Hide quoted text -

Thanks much Uwe, I didn't know this tool.
(the main site http://www.transcoding.org is currently down, but the
mirror http://fromani.exit1.org works !)

I see it is registered as UNIX/BSD only -- too bad since I intend to
use it primarily on Windows... Do you know how hard it would be to
port ? (I wonder what unix-specific syscalls are needed for a command-
line transcoder...)

-Alex

Uwe Klein

unread,
Jan 5, 2008, 5:42:15 PM1/5/08
to

and what about this:
http://freshmeat.net/projects/videoflowforsqueak/

OK, its not Tcl ;-)

uwe

Uwe Klein

unread,
Jan 5, 2008, 5:39:54 PM1/5/08
to
Alexandre Ferrieux wrote:
> On Jan 5, 10:36 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
> wrote:
>
>>What about wrapping transcode?
>> http://en.wikipedia.org/wiki/Transcode
>> http://freshmeat.net/search/?q=transcode告on=projects&Go.x=0&Go.y=0

>>uwe- Hide quoted text -
>
>
> Thanks much Uwe, I didn't know this tool.
> (the main site http://www.transcoding.org is currently down, but the
> mirror http://fromani.exit1.org works !)
>
> I see it is registered as UNIX/BSD only -- too bad since I intend to
> use it primarily on Windows... Do you know how hard it would be to
> port ? (I wonder what unix-specific syscalls are needed for a command-
> line transcoder...)
No idea. Should not be much more than file-io, but you need a gazillion
of libs. maybe leverage cygwin?

As an alternative you might want to look into
vlc:
http://freshmeat.net/projects/vlc/
and projects that attach to that codebase.

>
> -Alex
uwe

bs

unread,
Jan 5, 2008, 6:03:56 PM1/5/08
to
On Jan 5, 2:39 pm, Uwe Klein <uwe_klein_habertw...@t-online.de> wrote:
> Alexandre Ferrieux wrote:
> > On Jan 5, 10:36 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
> > wrote:
>
> >>What about wrapping transcode?
> >> http://en.wikipedia.org/wiki/Transcode
> >> http://freshmeat.net/search/?q=transcode§ion=projects&Go.x=0&Go.y=0

> >>uwe- Hide quoted text -
>
> > Thanks much Uwe, I didn't know this tool.
> > (the main sitehttp://www.transcoding.orgis currently down, but the
> > mirrorhttp://fromani.exit1.orgworks !)

>
> > I see it is registered as UNIX/BSD only -- too bad since I intend to
> > use it primarily on Windows... Do you know how hard it would be to
> > port ? (I wonder what unix-specific syscalls are needed for a command-
> > line transcoder...)
>
> No idea. Should not be much more than file-io, but you need a gazillion
> of libs. maybe leverage cygwin?
>
> As an alternative you might want to look into
> vlc:
> http://freshmeat.net/projects/vlc/
> and projects that attach to that codebase.
>
>
>
> > -Alex
>
> uwe

FWIW, I have vlc lib wrapped in Tcl, so you can initiate video playing
via vlc. Not sure
off hand if it will do what you want though. If you investigate vlc
and find it will do what you
need, let me know, and I'll check if the binding I wrote will do it as
well. Note that I just wrote it, and is alpha quality...

Alexandre Ferrieux

unread,
Jan 5, 2008, 6:40:19 PM1/5/08
to
> well. Note that I just wrote it, and is alpha quality...- Hide quoted text -

Interesting. Indeed I had started with VLC, thinking I could even use
it without scripting, just scrolling to the wanted cut frame and
reading the file offset somewhere ... except VLC doesn't give this
offset !
Does your wrapping expose it ? In fact, any of the two following
methods would be OK:

(a) adding the offset info to VLC-like interaction
(b) allowing an external source to feed unsynchronized raw TS, and
stop at the first complete keyframe and display it (or save in any
standard image format). By "unsynchronized" I mean, it would be cool
if I didn't need to demux or at least detect the GOP boundaries.

Thanks anyway for your signal. Would love to see your package.

-Alex

bs

unread,
Jan 5, 2008, 7:09:39 PM1/5/08
to
On Jan 5, 3:40 pm, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:

> On Jan 6, 12:03 am, bs <brett.schw...@gmail.com> wrote:
>
>
>
> > On Jan 5, 2:39 pm, Uwe Klein <uwe_klein_habertw...@t-online.de> wrote:
>
> > > Alexandre Ferrieux wrote:
> > > > On Jan 5, 10:36 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
> > > > wrote:
>
> > > >>What about wrapping transcode?
> > > >> http://en.wikipedia.org/wiki/Transcode
> > > >> http://freshmeat.net/search/?q=transcode§ion=projects&Go.x=0&Go.y=0
> > > >>uwe- Hide quoted text -
>
> > > > Thanks much Uwe, I didn't know this tool.
> > > > (the main sitehttp://www.transcoding.orgiscurrentlydown, but the

Humm, I'll have to dig more, it's been a couple months since I was
messing with it. I know you can set the position in a stream, and I
know you can take a snapshot, but I'm not sure if you can detect a
keyframe or not (from the API).

Here's the external API that I was going off of: http://wiki.videolan.org/ExternalAPI
(go down to VLC_Control section). I have probably half of those
functions wrapped now. There's also another API called the
MediaControlAPI (http://wiki.videolan.org/MediaControlAPI) that I was
going to look into too. To be honest, their API is kind of confusing
to me, and I am still learning, so that's why I can't tell you right
off if it can do it or not. You may want to look over the API too, to
see if anything looks good. I found their documentation to not be so
great, so I had to look at the header files sometimes to get the
correct info.

The binding I have works on Linux...that's all I have tested on. It
should work on any platform that Tcl and VLC run on, but I have not
tested.

If you go down the VLC path, and need something right away, let me
know and I can send the Tcl binding I have. Like I said, it's
definitely alpha quality...so I would rather wait until I have some
time to clean it up, if you don't need it right away.

Cheers,
--brett

Alexandre Ferrieux

unread,
Jan 5, 2008, 7:36:01 PM1/5/08
to
On Jan 6, 1:09 am, bs <brett.schw...@gmail.com> wrote:
>
> Humm, I'll have to dig more, it's been a couple months since I was
> messing with it. I know you can set the position in a stream, and I
> know you can take a snapshot, but I'm not sure if you can detect a
> keyframe or not (from the API).

Oh, no problem, I just want to see an image in order to see if I'm at
the beginning of the movie or not. I was mentioning keyframes because,
from an algorithmic point of view, decoding a keyframe is much simpler
than an interpolated one. But of course if you have a full MPEG2
decoder under the hood, the constraint is meaningless...

>
> Here's the external API that I was going off of:http://wiki.videolan.org/ExternalAPI
> (go down to VLC_Control section). I have probably half of those
> functions wrapped now. There's also another API called the
> MediaControlAPI (http://wiki.videolan.org/MediaControlAPI) that I was
> going to look into too.

Thanks very much Brett. I'll have a look.

> The binding I have works on Linux...that's all I have tested on. It
> should work on any platform that Tcl and VLC run on, but I have not
> tested.
>
> If you go down the VLC path, and need something right away, let me
> know and I can send the Tcl binding I have. Like I said, it's
> definitely alpha quality...so I would rather wait until I have some
> time to clean it up, if you don't need it right away.

In fact I can only test on Windows, and no access to a compiler...
So if you're binding vlc.exe with pipes, it's OK.
If you're using ffidl, it's still OK.
But otherwise (a Tcl loadable extension), I will need a DLL :-)
If you manage to build one, I'll be your dedicated alpha tester !

Thanks in any case !

-Alex

George Petasis

unread,
Jan 6, 2008, 4:31:53 PM1/6/08
to Alexandre Ferrieux
There was an extension called TMCI, written by Farzad Pezeshkpour.
I have used it in the past, and at least allowed to play mpeg files.
However, I couldn't find the sources, and the original site seems to be
down...
(I only have a binary but no manual :-) )

George

O/H Alexandre Ferrieux έγραψε:

Alexandre Ferrieux

unread,
Jan 6, 2008, 4:47:55 PM1/6/08
to
On Jan 6, 10:31 pm, George Petasis <peta...@iit.demokritos.gr> wrote:
> There was an extension called TMCI, written by Farzad Pezeshkpour.
> I have used it in the past, and at least allowed to play mpeg files.
> However, I couldn't find the sources, and the original site seems to be
> down...
> (I only have a binary but no manual :-) )

Thanks George. But for MCI to play a TS, we need a codec, just like
with TkVideo, right ?
Do you know of a good MPEG2 codec for DirectShow ?

-Alex

Pat Thoyts

unread,
Jan 6, 2008, 7:00:02 PM1/6/08
to
Alexandre Ferrieux <alexandre...@gmail.com> writes:

I don't know what you mean by TS files. But Tkvideo just hooks into
the DirectShow system so provided you have a codec installed for a
given format you should be able to play the files. Sounds like you are
after access to the time information in the video stream if you want
to know where the current position is. I think this is already
available as the demo can show the current time on the progress bar.

The ffdshow codec collection is pretty comprehensive. (sourceforge)

--
Pat Thoyts http://www.patthoyts.tk/
To reply, rot13 the return address or read the X-Address header.
PGP fingerprint 2C 6E 98 07 2C 59 C8 97 10 CE 11 E6 04 E0 B9 DD

Alexandre Ferrieux

unread,
Jan 6, 2008, 7:29:13 PM1/6/08
to
On Jan 7, 1:00 am, Pat Thoyts <cnggub...@hfref.fbheprsbetr.arg> wrote:
>
> I don't know what you mean by TS files.

MPEG2 Transport Streams.
So far the only player I know of that can read them is vlc, but it his
its own independent set of codecs, not integrated with DirectShow (vlc
is portable).

> Sounds like you are
> after access to the time information in the video stream if you want
> to know where the current position is. I think this is already
> available as the demo can show the current time on the progress bar.

Yup. If only I had a DirectShow codec.
I know of the Elecard MPEG2 decoder, but last time I checked it was
rather unstable (crashed).

-Alex

bs

unread,
Jan 7, 2008, 1:21:43 PM1/7/08
to
On Jan 5, 4:36 pm, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:

I might have something this week...

Alexandre Ferrieux

unread,
Jan 7, 2008, 1:38:15 PM1/7/08
to

Nice ! Thanks !

-Alex

0 new messages