C #: Obtain the thumbnail of a video frame,

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.