php - Get the thumbnail contents in a variable instead of saving on a file
751
I need to create a thumbnail from a remote video URL but I do not want this thumbnail to be stored. I need to get it in a variable so I can save it later.
shell_exec("ffmpeg -i video.mp4 -s 150x150 -ss 00:00:00.750 -vframes 1 output.png");
How to I get the output.png instead of saving it as a file?
Answer
Solution:
You could combining the following commands:
ffmpeg -i video.mp4 -s 150x150 -ss 00:00:00.750 -vframes 1 output.png -hide_banner -loglevel panic
This will make the output from
ffmpeg
as quiet as possiblecat output.png
Print the file contents to the console (and be returned by
shell_exec
)rm output.png
to the following:
I'm not aware of any method to get ffmpeg to dump data directly without placing it into a file.
Hope this helps.