Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

How can I use ffmpeg and youtube-dl to download the first frame of every video in a playlist?

I'm trying to download only the first frame of every video in a large playlist on YouTube. Does anybody know how I can use ffmpeg and youtube-dl to do this?

question from:https://stackoverflow.com/questions/65650733/how-can-i-use-ffmpeg-and-youtube-dl-to-download-the-first-frame-of-every-video-i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First you need to take the playlist ID of the youtube playlist and download the full playlist of the thumbnails you want to get like this:

youtube-dl -i PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2

Then you use the following script, which will extract the first frame of the all the videos, (do note that after downloading the full playlist all of the videos are in the same directory):

i=1
for avi in *.mp4; do
    name=`echo $avi | cut -f1 -d'.'`
    jpg_ext='.jpg'
    echo "$i": extracting the first frame of the video "$avi" into "$name$jpg_ext"
    ffmpeg -loglevel panic -i $avi -vframes 1 -f image2 "$name$jpg_ext"
    i=$((i+1))
 done

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...