You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -370,9 +370,17 @@ else
370
370
371
371
Whilst the code above from Non-Blocking Saves looks like it is a progress handler (and it is in a sense, but it doesn't provide data on the encode), progress handlers provide much more detailed information about the current encoding process.
372
372
373
-
PHPVideoToolkit allows you to monitor the encoding process of FFmpeg. This is done by using ProgressHandler objects. There are two types of progress handlers. ProgressHandlerNative and ProgressHandlerOutput. If your copy of FFmpeg is recent you will be able to use ProgressHandlerNative which uses FFmpegs '-progress' command to provide data, where was ProgressHandlerOutput relies on only the output of the command line buffer. Apart from that difference both handlers return the same data and act in the same way.
373
+
PHPVideoToolkit allows you to monitor the encoding process of FFmpeg. This is done by using ProgressHandler objects. There are three types of progress handlers.
374
374
375
-
Progress Handlers can be made to block PHP or can be used in a non blocking fashion. They can even be utilized to work from a seperate script once the encoding has been initialised. However for purposes of this example the progress handlers are in the same script essentially blocking the PHP process. Again however, the two examples shown function very differently.
375
+
- ProgressHandlerNative
376
+
- ProgressHandlerOutput
377
+
- ProgressHandlerPortable
378
+
379
+
ProgressHandlerNative and ProgressHandlerOutput work and function in the same way, however one uses a native ffmpeg command, and the out outputs ffmpeg output buffer to a temp file. If your copy of FFmpeg is recent you will be able to use ProgressHandlerNative which uses FFmpegs '-progress' command to provide data. Apart from that difference both handlers return the same data and act in the same way and there is no real need to prioritise one over another unless you version of ffmpeg does not support '-progress'. If it doesn't then when you initialise the ProgressHandlerNative an exception will be thrown.
380
+
381
+
The third type of handler ProgressHandlerPortable (shown in example 3 below) operates somewhat differently and is specifically design to work with separate HTTP requests or threads. ProgressHandlerPortable can be initiated in a different script entirely, supplied with the PHPVideoToolkit portable process id and then probed independantly of the encoding script. This allows developers to decouple encoding and encoding status scripts.
382
+
383
+
Progress Handlers can be made to block PHP or can be used in a non blocking fashion. They can even be utilized to work from a seperate script once the encoding has been initialised. However for purposes of the first two examples the progress handlers are in the same script essentially blocking the PHP process. Again however, the first two examples shown function very differently.
376
384
377
385
**Example 1. Callback in the handler constructor**
378
386
@@ -386,7 +394,7 @@ $video = new Video('BigBuckBunny_320x180.mp4', $config);
386
394
$progress_handler = new ProgressHandlerNative(function($data)
387
395
{
388
396
echo '<pre>'.print_r($data, true).'</pre>';
389
-
});
397
+
}, $config);
390
398
391
399
$output = $video->purgeMetaData()
392
400
->setMetaData('title', 'Hello World')
@@ -402,7 +410,7 @@ namespace PHPVideoToolkit;
402
410
403
411
$video = new Video('BigBuckBunny_320x180.mp4', $config);
404
412
405
-
$progress_handler = new ProgressHandlerNative();
413
+
$progress_handler = new ProgressHandlerNative(null, $config);
0 commit comments