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
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
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...
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
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
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
O/H Alexandre Ferrieux έγραψε:
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
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
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
I might have something this week...
Nice ! Thanks !
-Alex