Get random frame from FLV video and store it as png or jpg
Using ffmpeg, how can i get a random fr开发者_Python百科ame of an FLV video and save it as png or jpg ?
Generate your random time value in PHP, and then execute something like this in ffmpeg:
ffmpeg -vframes 1 -ss 5.5 -i yourvideo.flv yourframe.jpg
This will get a frame on or about 5.5 seconds in the video. I suggest you use ffmpeg ahead of time to determine the length of the video, then generate a random number between the start and end.
Also, leave plenty of padding at the end of the video, as it isn't always possible to determine its exact length ahead of time. If your video is 1 hour, you might get a frame somewhere between 0 and 57 minutes, for example.
精彩评论