MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / VideoReader

Class VideoReader

CodenameOne/src/com/codename1/media/VideoReader.java:44–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42///
43/// Obtain an instance from `VideoIO#openReader(String)`. Always `#close()` it when done.
44public abstract class VideoReader {
45 /// The width of the video track in pixels, or -1 if there is no video.
46 public abstract int getWidth();
47
48 /// The height of the video track in pixels, or -1 if there is no video.
49 public abstract int getHeight();
50
51 /// The total duration of the clip in milliseconds, or -1 if unknown.
52 public abstract long getDurationMillis();
53
54 /// The average/nominal frame rate of the source video track. For variable frame rate
55 /// sources this is an average; use `#readFrames(float, FrameCallback)` to obtain an
56 /// evenly spaced sequence.
57 public abstract float getFrameRate();
58
59 /// True if the clip has a decodable video track.
60 public abstract boolean hasVideo();
61
62 /// True if the clip has a decodable audio track.
63 public abstract boolean hasAudio();
64
65 /// The sample rate of the audio track in Hz, or -1 if there is no audio.
66 public abstract int getAudioSampleRate();
67
68 /// The number of channels in the audio track, or -1 if there is no audio.
69 public abstract int getAudioChannels();
70
71 /// Returns the frame at (or nearest at/before) the given timestamp, decoded to RGBA.
72 /// Unlike seeking a `Media` player, the returned frame corresponds exactly to the
73 /// requested position rather than the closest key frame.
74 ///
75 /// #### Parameters
76 ///
77 /// - `millis`: the timestamp to seek to in milliseconds
78 ///
79 /// #### Returns
80 ///
81 /// the decoded `VideoFrame`, or null if the position is past the end of the clip
82 ///
83 /// #### Throws
84 ///
85 /// - `IOException`: if decoding fails
86 public abstract VideoFrame frameAt(long millis) throws IOException;
87
88 /// Walks the entire clip, decoding and resampling it to the requested constant frame
89 /// rate, invoking the callback once per output frame in increasing timestamp order.
90 /// This converts a variable frame rate source to a constant frame rate sequence by
91 /// duplicating or dropping source frames as needed.
92 ///
93 /// #### Parameters
94 ///
95 /// - `fps`: the target constant output frame rate in frames per second
96 ///
97 /// - `callback`: receives each decoded frame; return false from it to stop early
98 ///
99 /// #### Throws
100 ///
101 /// - `IOException`: if decoding fails

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected