javascript 如何从 youtube 获取第一帧作为照片?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15337215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 00:26:19  来源:igfitidea点击:

How I can get First Frame as Photo from youtube?

javascriptimageyoutube

提问by user1560992

How I can get the first Frame in Youtube video as Image ?

如何将 Youtube 视频中的第一个 Frame 获取为 Image ?

or I have to use external too to help me to do this task?

或者我也必须使用外部来帮助我完成这项任务?

thanks

谢谢

回答by MarmiK

For instance, if the video link is http://www.youtube.com/watch?v=JJrNopvzCy8

例如,如果视频链接是 http://www.youtube.com/watch?v=JJrNopvzCy8

Extract the value of vand use it to download the the image..

提取的值v并使用它来下载图像..

Like:

喜欢:

http://img.youtube.com/vi/JJrNopvzCy8/0.jpg

http://img.youtube.com/vi/JJrNopvzCy8/0.jpg

I hope this will solve your problem,

我希望这能解决你的问题,

Just be careful with the ?v=xxxxxxxxcode

小心 ?v=xxxxxxxx代码

Note: For different frames, you may change the Number from 0.jpg to 1.jpg or more to fetch next frames of video in-case first starting frame of video is not required!

注意:对于不同的帧,您可以将数字从 0.jpg 更改为 1.jpg 或更多以获取下一帧视频,以防视频的第一个起始帧!

The Image will be by Default first frame of Video Size, so specify the image size in img tag, OR if sepcific size is must then use this YouTube Dev. API

默认情况下,图像将是视频大小的第一帧,因此在 img 标签中指定图像大小,或者如果必须使用特定大小,则使用此YouTube Dev。应用程序接口

Specific section in API link Thumbnails Section

API链接缩略图部分中的特定部分

OR we can try following example:

或者我们可以尝试以下示例:

Video: https://www.youtube.com/watch?v=JJrNopvzCy8

视频: https://www.youtube.com/watch?v=JJrNopvzCy8

  1. Default Thumb: http://i.ytimg.com/vi/JJrNopvzCy8/default.jpg

  2. MaxRes Thumb: http://i.ytimg.com/vi/JJrNopvzCy8/maxresdefault.jpg

  3. HQ Thumb: http://i.ytimg.com/vi/JJrNopvzCy8/hqdefault.jpg

  4. MQ Thumb: http://i.ytimg.com/vi/JJrNopvzCy8/mqdefault.jpg

  5. SD Thumb: http://i.ytimg.com/vi/JJrNopvzCy8/sddefault.jpg

  1. 默认拇指: http://i.ytimg.com/vi/JJrNopvzCy8/default.jpg

  2. MaxRes 拇指: http://i.ytimg.com/vi/JJrNopvzCy8/maxresdefault.jpg

  3. 总部拇指: http://i.ytimg.com/vi/JJrNopvzCy8/hqdefault.jpg

  4. MQ拇指: http://i.ytimg.com/vi/JJrNopvzCy8/mqdefault.jpg

  5. 标清拇指: http://i.ytimg.com/vi/JJrNopvzCy8/sddefault.jpg

Note: Some of the sizes will vary (OR may not be available as that follows resolutions available for the Video link)

注意:某些尺寸会有所不同(或可能不可用,因为以下分辨率可用于视频链接)

Edit:For First Frame use this: http://img.youtube.com/vi/JJrNopvzCy8/0.jpg

编辑:对于第一帧使用这个:http: //img.youtube.com/vi/JJrNopvzCy8/0.jpg