This API allows you to capture a single frame from a YouTube video at a specific timestamp. All you need is a single HTTP GET request. For example, to capture a frame from a video with ID qk1nnAHI1mI at timestamp 0:00:04, simply make this API call:
GET /frame?youtube_id=qk1nnAHI1mI×tamp=0:00:04
The process uses youtube-dl to extract the direct video URL from YouTube. Then, ffmpeg is used to capture the frame at the specified timestamp. Finally, the captured frame is returned as an image.
First, extract the URL using:
yt-dlp -f best --get-url "https://www.youtube.com/watch?v=qk1nnAHI1mI"
Then, use ffmpeg to capture the frame at the specified timestamp:
ffmpeg -ss 0:00:04 -i $URL_FROM_YOUTUBE_DL -vframes 1 -q:v 2 -y output.jpg