File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why I get java.lang.NullPointerException for grabing image.

 
Wasin Raktham
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm beginner for JMF. I tried to write a java class to create a image to review video file.

I found a code from internet but it doesn't work for me. Because When I run the code, it show me..

Fobs4JMF - Native shared library found
635.088First Position: 0, 80 Duration: 635088
Frame Rate: 25
Opening Thread[JMF thread: com.sun.media.PlaybackEngine@f5da06[ com.sun.media.PlaybackEngine@f5da06 ] ( configureThread),9,system]
Fobs Java2DRenderer: setInputFormat
Fobs Java2DRenderer: setInputFormat
FobsVideoTrack: mapTimeToFrame
FobsVideoTrack: mapFrameToTime
Exception in thread "main" java.lang.NullPointerException
at com.user.vidtojpg.VideoUtility.getImageOfCurrentFrame(VideoUtility.java:66)
at com.user.vidtojpg.VideoUtility.getAllImages(VideoUtility.java:94)
at com.user.vidtojpg.VideoUtility.getAllImages(VideoUtility.java:105)
at com.user.vidtojpg.VideoUtility.main(VideoUtility.java:113)



What about Exception in thread "main" java.lang.NullPointerException? and How I fix it.

Then my code is :

 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line is #66? Which object is null?
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either fpc is null, or fgc is null, or frameBuffer is null.

Finding sources of (NullPointer)Exceptions should be a base skill when programming in Java, so I'm moving this to Beginning Java.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fgc.grabFrame() might be returning null.

The hard part of correcting an NPE is working out which object points to null. You will have to separate that block of code into separate lines, with one assignment on each, then print out the test.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic