Im unexperienced in this way of using PHP, but Id like to like, create some variable for example $test, which would be exec("ffmpeg ...") as we know, ffmpeg does actively change its result, while PHP just waits till the command is finished, is there an option, that I would execute the command and by refreshing the page get active form of the result, since Id like to make a progress bar and things, but that seems to be impossible to me right now. I have tried basic things, but as I see, I have no idea how to do, it any suggestions how to make that? Please just do not close this, it is actually really hard for me to do these things and everytime people literally just reject me here with my questions
-
2FWIW: https://stackoverflow.com/questions/34867202/ffmpeg-progress-bar-in-php Your questions are probably being closed as too broad. Providing code and asking a specific question will get better answers. As is this is pretty broad and probably is best Googled until you have a better idea of what your options are. – ficuscr Sep 28 '20 at 16:32
-
ficuscr is correct that this question is too broad. Questions like this don't get much attention. Do you need help with the ffmpeg part? The PHP part? Both? If both it should be spit into two separate questions addressing each individual topic. As it is someone providing a comprehensive answer must know both topics. That being said I provided an answer about the ffmpeg stuff. – llogan Sep 28 '20 at 18:46
1 Answers
Since your question is so broad I can only give you a broad answer showing the basic steps for the ffmpeg
part of your question (also I don't know PHP). It should be enough info for you to be able to implement it into your script.
Use -progress
You can use the -progress
global option in ffmpeg
to continuously output progress information to a text file:
ffmpeg -progress progress.txt -i input.avi output.mp4
From the documentation:
-progress url
(global)
Send program-friendly progress information to url.Progress information is written approximately every second and at the end of the encoding process. It is made of
key=value
lines. A key consists of only alphanumeric characters. The last key of a sequence of progress information is alwaysprogress
.
Example output
Example excerpt from the progress file:
frame=106
fps=23.33
stream_0_0_q=28.0
bitrate= 0.2kbits/s
total_size=48
out_time_us=2080078
out_time_ms=2080078
out_time=00:00:02.080078
dup_frames=0
drop_frames=0
speed=0.458x
progress=continue
Note that this is only helpful if you know what the final duration or number of frames that the output will be. If you know your input and output will have approximately the same duration or frames then you should have no problem using it. But of course it depends on your command.
Getting duration or frames
Once you know the duration or number of frames you can utilize frame
or out_time_ms
to determine the progress for the queried interval.
You can use ffprobe
to determine input info:
Also see:

- 121,796
- 28
- 232
- 243