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?

779

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 fromffmpeg as quiet as possible

  • cat output.png

  • Print the file contents to the console (and be returned byshell_exec)

  • rm output.png

  • Delete the file

to the following:

shell_exec("ffmpeg -i video.mp4 -s 150x150 -ss 00:00:00.750 -vframes 1 output.png -hide_banner -loglevel panic; cat output.png; rm output.png");

I'm not aware of any method to get ffmpeg to dump data directly without placing it into a file.

Hope this helps.

People are also looking for solutions to the problem: php - How do I fix the error of call to undefined function for add_settings_field()?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.