Skip to content

Commit 7db4ce5

Browse files
committed
updated progress handler readme data
1 parent 7eb5201 commit 7db4ce5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,17 @@ else
370370

371371
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.
372372

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.
374374

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.
376384

377385
**Example 1. Callback in the handler constructor**
378386

@@ -386,7 +394,7 @@ $video = new Video('BigBuckBunny_320x180.mp4', $config);
386394
$progress_handler = new ProgressHandlerNative(function($data)
387395
{
388396
echo '<pre>'.print_r($data, true).'</pre>';
389-
});
397+
}, $config);
390398

391399
$output = $video->purgeMetaData()
392400
->setMetaData('title', 'Hello World')
@@ -402,7 +410,7 @@ namespace PHPVideoToolkit;
402410

403411
$video = new Video('BigBuckBunny_320x180.mp4', $config);
404412

405-
$progress_handler = new ProgressHandlerNative();
413+
$progress_handler = new ProgressHandlerNative(null, $config);
406414

407415
$output = $video->purgeMetaData()
408416
->setMetaData('title', 'Hello World')

0 commit comments

Comments
 (0)