3

I used the xuggle-xuggler5.4 in my app to add video and audio playing functionality, I have dig into google and found following snippet:

long duration = container.getDuration();
long target = new Double(duration * .50).longValue();
container.seekKeyFrame(0, target, 0, 0, IContainer.SEEK_FLAG_BYTE);

I don't know if this snippet is not correct, or my xuggle is wrong, or I am SICK (just kidding) but every thing looks fine. when i play the video it always start from the first (not the location i want).

I would be very happy if someone can help me Thanks

Mohammad Hassany
  • 898
  • 1
  • 14
  • 30

1 Answers1

4

OK I got that ;)

I got the video duration and frame rate as below :

IStream stream = iContainerObj.getStream(i);
IStreamCoder coder = stream.getStreamCoder();

if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO
    && videoStreamId == -1) {
videoDuration = container.getDuration() == Global.NO_PTS ? 0
        : container.getDuration() / 1000;
frameRate = coder.getFrameRate().getDouble();
    // other ....
 }

then to jump to the specific location, I convert the duration which was in milli second to second then multiplied to frameRate and the second i want. And finally called seekKeyFrame to jump to position.

NOTE: also i used the =>> IContainer.SEEK_FLAG_FRAME, which indicate i am giving frame number to the method.

int jumpToThisSecond = 65;
long jumbTo = (long) (((videoDuration / 1000) * frameRate) * jumpToThisSecond);
container.seekKeyFrame(0, 0, jumbTo, container.getDuration(),
            IContainer.SEEK_FLAG_FRAME);
Community
  • 1
  • 1
Mohammad Hassany
  • 898
  • 1
  • 14
  • 30
  • I am using Xuggler lib. I have video in Cloud (4.5 gb video). I want for forward and fetch particular frame. My input video as InputStream to container. If i use seek frame it is not fetching if it is stream whereas loading file from filesystem i input as URL here seekframe works flawless. My question: Xuggler fail if video is a inputstream? Need Help. – Praveen Gopal Oct 20 '19 at 09:42
  • @PraveenGopal it has been ~6 years from the last time i worked with Xuggler. I recommend you to post your issue in a new question so that other active people can help you. – Mohammad Hassany Oct 21 '19 at 22:43
  • I posted but no reply. Can u check https://stackoverflow.com/questions/58483424/error-while-opening-video-file-from-url-and-seekframe-not-working-xuggler – Praveen Gopal Oct 22 '19 at 07:54