1. Call bitmap = (-1);
This code gets bitmap,
2. Then this code is called in
The code for getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC) is:
Explain the meaning of the two variables: timeUs, and OPTION_CLOSEST_SYNC
timeUs The time position where the frame will be retrieved.
* When retrieving the frame at the given time position, there is no
* guarentee that the data source has a frame located at the position.
* When this happens, a frame nearby will be returned. If timeUs is
* negative, time position and option will ignored, and any frame
* that the implementation considers as representative may be returned
3. Since timeUs is equal to -1, then pass in
extractVideoFrameWithCodecFlags() function
if (frameTimeUs < 0) {
if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)
|| thumbNailTime < 0) {
thumbNailTime = 0;
}
(thumbNailTime, mode);
}else{
...................
}
Get thumbnailTime,
thumbnailTime is to take the largest frame of data in the synchronous frame, that is, it may not be the first I frame of the video file.
() function, then the third item is called, and then the code is called err = decoder->read(&buffer, &options); and its options->seekMode is the value SEEK_CLOSEST_SYNC
5. If video codec is mpeg4, the function of read() in it is called.
According to the previous thumbnailtime, find the vidoe frame index at this time point, and then search for the adjacent synchronization frame (i.e., I frame)
In the findSyncSampleNear() function, find the adjacent synchronization frame.
All synchronization frames will be stored in the video file. This synchronization frame may also be the first value in this synchronization frame array, and the video frame index obtained in step 5 may also be located between two synchronization frames. Then we find the synchronization frame closest to the video frame index by computing.
7. Through the above steps, find the synchronization frame, and then generate the thumbnail bitmap based on this synchronization frame.
This code gets bitmap,
2. Then this code is called in
The code for getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC) is:
Explain the meaning of the two variables: timeUs, and OPTION_CLOSEST_SYNC
timeUs The time position where the frame will be retrieved.
* When retrieving the frame at the given time position, there is no
* guarentee that the data source has a frame located at the position.
* When this happens, a frame nearby will be returned. If timeUs is
* negative, time position and option will ignored, and any frame
* that the implementation considers as representative may be returned
3. Since timeUs is equal to -1, then pass in
extractVideoFrameWithCodecFlags() function
Copy the codeThe code is as follows:
if (frameTimeUs < 0) {
if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)
|| thumbNailTime < 0) {
thumbNailTime = 0;
}
(thumbNailTime, mode);
}else{
...................
}
Get thumbnailTime,
thumbnailTime is to take the largest frame of data in the synchronous frame, that is, it may not be the first I frame of the video file.
() function, then the third item is called, and then the code is called err = decoder->read(&buffer, &options); and its options->seekMode is the value SEEK_CLOSEST_SYNC
5. If video codec is mpeg4, the function of read() in it is called.
According to the previous thumbnailtime, find the vidoe frame index at this time point, and then search for the adjacent synchronization frame (i.e., I frame)
In the findSyncSampleNear() function, find the adjacent synchronization frame.
All synchronization frames will be stored in the video file. This synchronization frame may also be the first value in this synchronization frame array, and the video frame index obtained in step 5 may also be located between two synchronization frames. Then we find the synchronization frame closest to the video frame index by computing.
7. Through the above steps, find the synchronization frame, and then generate the thumbnail bitmap based on this synchronization frame.