Package com.avpkit.mediatool.demos
Class DecodeAndCaptureFrames
- java.lang.Object
-
- com.avpkit.mediatool.AMediaListenerMixin
-
- com.avpkit.mediatool.MediaListenerAdapter
-
- com.avpkit.mediatool.demos.DecodeAndCaptureFrames
-
- All Implemented Interfaces:
IMediaListener
public class DecodeAndCaptureFrames extends MediaListenerAdapter
UsingIMediaReader, takes a media container, finds the first video stream, decodes that stream, and then writes video frames out to a PNG image file every 5 seconds, based on the video presentation timestamps.- Author:
- aclarke, trebor
-
-
Field Summary
Fields Modifier and Type Field Description static longMICRO_SECONDS_BETWEEN_FRAMESThe number of micro-seconds between frames.static doubleSECONDS_BETWEEN_FRAMESThe number of seconds between frames.
-
Constructor Summary
Constructors Constructor Description DecodeAndCaptureFrames(java.lang.String filename)Construct a DecodeAndCaptureFrames which reads and captures frames from a video file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidmain(java.lang.String[] args)Takes a media container (file) as the first argument, opens it and writes some of it's video frames to PNG image files in the temporary directory.voidonVideoPicture(IVideoPictureEvent event)Called after a video frame has been decoded from a media stream.-
Methods inherited from class com.avpkit.mediatool.MediaListenerAdapter
onAddStream, onAudioSamples, onClose, onCloseCoder, onFlush, onOpen, onOpenCoder, onReadPacket, onWriteHeader, onWritePacket, onWriteTrailer
-
-
-
-
Field Detail
-
SECONDS_BETWEEN_FRAMES
public static final double SECONDS_BETWEEN_FRAMES
The number of seconds between frames.- See Also:
- Constant Field Values
-
MICRO_SECONDS_BETWEEN_FRAMES
public static final long MICRO_SECONDS_BETWEEN_FRAMES
The number of micro-seconds between frames.
-
-
Constructor Detail
-
DecodeAndCaptureFrames
public DecodeAndCaptureFrames(java.lang.String filename)
Construct a DecodeAndCaptureFrames which reads and captures frames from a video file.- Parameters:
filename- the name of the media file to read
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Takes a media container (file) as the first argument, opens it and writes some of it's video frames to PNG image files in the temporary directory.- Parameters:
args- must contain one string which represents a filename
-
onVideoPicture
public void onVideoPicture(IVideoPictureEvent event)
Called after a video frame has been decoded from a media stream. Optionally a BufferedImage version of the frame may be passed if the callingIMediaReaderinstance was configured to create BufferedImages. This method blocks, so return quickly.- Specified by:
onVideoPicturein interfaceIMediaListener- Overrides:
onVideoPicturein classMediaListenerAdapter- Parameters:
event- An event containing either anIVideoPicture, aBufferedImage, or both. TheIVideoPictureis only valid for the duration of this callback. If you need to access it after you return, you must either copy the data into your own buffers, or callIVideoPicture.copyReference()to get your own reference to the data.
-
-