3

How to - 1.get the current frame position of an audio/video track ?? 2.how to go to a specific frame position of a track ?? using vlcj sdk . any code snippets would be highly appreciated !

4

2 回答 2

3

实际上你可以用一点数学来做到这一点。这不是最干净的方式,但它很容易理解。

VLCj 允许您使用.getLength(). 但是,请注意,这会以毫秒为单位返回媒体的长度。此外,您可以使用.getFPS().

所以现在你可以得到总帧数

total_frames = .getFPS * .getLength() /1000;

然后您可以使用.getPosition()以毫秒为单位找出您当前的位置,然后您可以将其转换为帧。这以百分比形式返回。

current_frame = .getPosition() * total_frames;

现在,如果你想去一个特定的框架,让我们称之为desired_frame. 您可以使用.setPosition()其中的百分比。因此,您需要确定代表您要跳转到的帧的总数的百分比。

.setPosition((float)desired_frame/total_frames);
于 2017-04-25T15:18:20.227 回答
0

VLCJ isn't really set up for this kind of frame by frame access directly - you can use setTime() and getTime() on the mediaplayer object, but that will return time from the beginning in milliseconds rather than the frame. Of course, if you know the frame rate it's then relatively trivial to convert from one to the other.

If you need lower level operations than VLCJ provides, then you may want to have a look at Xuggler.

于 2013-01-29T13:31:55.507 回答