C #: Obtain the thumbnail of a video frame,
Read method: Use ffmpeg to read data, so you need to download ffmpeg first. There are many online resources.
The principle is to use ffmpeg to execute a command to obtain a thumbnail of a video frame.
First, you must obtain the frame height and width of the video so that the obtained thumbnail will not be deformed.
Get the video frame height and frame width can be http://www.zhoumy.cn /? P = 35.
After obtaining the video frame height and frame width, you also need to obtain the height and width of the thumbnail, Which is scaled proportionally.
For example, if the maximum width and maximum height of the area where you store the thumbnail are 100, the height of the thumbnail should also be scaled to the corresponding size.
Then, run a command to obtain the thumbnail of a video frame:
String command = string. format ("\" {0} \ "-I \" {1} \ "-ss {2}-vframes 1-r 1-ac 1-AB 2-s {3} * {4}-f image2 \ "{5 }\"", ffmpegPath, oriVideoPath, frameIndex, thubWidth, thubHeight, thubImagePath );
Run the command to view: http://www.zhoumy.cn /? P = 35
Where:
FfmpegPath is the full path of ffmpeg
OriVideoPath indicates the video's full path. frameIndex indicates the number of seconds in which the frame is located. thubWidth indicates the width of the thumbnail.
ThubHeight is the height of the thumbnail.
ThubImagePath is the path of the generated Thumbnail (jpg and bmp may all be supported. You can try it yourself)
Reprinted statement: This article is reproduced from: http://www.zhoumy.cn/, the original link: http://www.zhoumy.cn /? P = 41