-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupted picture grabbed after setTimestamp() invocation #896
Comments
If you're not interested in audio frames, you should be calling grabImage()
after setTimestamp() and this problem won't happen.
|
Hi @saudet , video.setTimestamp(timestampInMicros);
BufferedImage image = new Java2DFrameConverter().convert(video.grabImage()); I really called
doesn't know what kind of frame was grabbed |
Ah, I see. Could you send a pull request with the fix? Thanks for reporting!
|
Okay, I'll try to make tidy refactoring of |
Thanks! I think we just need to set frameGrabbed to true only when we grab an image right? And it would be a good idea to rename it to "imageGrabbed" instead as well.. |
Replaced "frameGrabbed" boolean flag by FrameType enum
Removed commented old code
Thanks for starting work on that! Are you going to send a pull request? BTW, your code doesn't work because it returns audio frames with |
I've fixed the issue in the commit above. Let me know if you still have problems with this! Thanks |
Hi @saudet , |
Hi @saudet, public static void testPictures() throws IOException {
long timestampInMicros = 9000000;
String suffix = "test";
for(int increment=0; increment <100_000_000;increment+=1_000_000) {
try (FFmpegFrameGrabber video = new FFmpegFrameGrabber("https://www.dropbox.com/s/gilbbjjhft4tzxn/00A8.mp4?dl=1")) {
video.start();
timestampInMicros += increment;
System.out.println("timestampInMicros = " + timestampInMicros);
System.out.println("video.getLengthInTime() = " + video.getLengthInTime());
File outputFile = new File("picture_" + timestampInMicros + "_" + suffix + ".jpg");
video.setTimestamp(timestampInMicros);
BufferedImage image = new Java2DFrameConverter().convert(video.grabImage());
ImageIO.write(image, "jpg", outputFile);
System.out.println("video.getTimestamp() = " + video.getTimestamp());
}
}
} Stacktrace looks like this:
UPD: timestamp > video length. Ignore this comment! |
@saudet , sorry. There is my mistake. I set timeStamp > video length. |
Fix included in JavaCV 1.4.1! Thanks again for reporting and for testing this. Please let me know if you still have any issues though. |
Hi @saudet , |
Hi @saudet ,
Looks like last fix #870 breaks down picture grabbing functionality.
I mean if you invoke setTimestamp() and jump unluckily to the frame which contains audio data only then
frameGrabbed
flag will betrue
in any case. Let's reproduce using code belowFirst timestamp we are lucky and picture is okay
picture_9000000_correct.jpg
Another timestamp picture is broken
picture_9201000_invalid.jpg
Some fix - for correct picture grabbing after
setTimestamp()
invocation - force setupdoAudio
tofalse
It would be nice to have flagging about last grabbed frame - was there audio frame grabbed or video. Whtat do you think about it?
The text was updated successfully, but these errors were encountered: