Skip to content

Commit 7eb5201

Browse files
committed
added input and output file information to the progress handler probe data
1 parent fc70474 commit 7eb5201

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

src/PHPVideoToolkit/FfmpegProcess.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,19 @@ public function isCompleted()
546546
return $this->_callExecBufferFunction('isCompleted');
547547
}
548548

549+
/**
550+
* Returns the file name of the exec buffer output.
551+
*
552+
* @access public
553+
* @author Oliver Lillie
554+
* @see ExecBuffer::getBufferOutput
555+
* @return string
556+
*/
557+
public function getBufferOutput()
558+
{
559+
return $this->_callExecBufferFunction('getBufferOutput');
560+
}
561+
549562
/**
550563
* Returns a boolean value determining if the process has completed.
551564
*
@@ -561,7 +574,7 @@ public function getPortableId()
561574
throw new Exception('It is not possible to get a portable id as the exec process has been made blocking. To get a portable id make the process unblocking or call getPortableId() before the save occurs.');
562575
}
563576

564-
$output = $this->_callExecBufferFunction('getBufferOutput');
577+
$output = $this->getBufferOutput();
565578
return substr($output, strrpos($output, 'phpvideotoolkit_')+16).'.'.$this->_callExecBufferFunction('getBoundary').'.'.time();
566579
}
567580
}

src/PHPVideoToolkit/ProgressHandlerDefaultData.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ protected function _getDefaultData()
4040
'dup' => 0,
4141
'drop' => 0,
4242
'output_file'=> null,
43+
'input_file' => null,
44+
'process_file' => null,
4345
);
4446
}
4547

src/PHPVideoToolkit/ProgressHandlerNative.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
*/
2121
class ProgressHandlerNative extends ProgressHandlerAbstract
2222
{
23+
protected $_progress_file;
24+
protected $_input_file;
25+
protected $_output_file;
26+
2327
public function __construct($callback=null, Config $config=null)
2428
{
2529
// check that the "-progress" function is available.
@@ -33,6 +37,8 @@ public function __construct($callback=null, Config $config=null)
3337
parent::__construct($callback, $config);
3438

3539
$this->_progress_file = null;
40+
$this->_input_file = null;
41+
$this->_output_file = null;
3642
}
3743

3844
protected function _getRawData()
@@ -50,6 +56,8 @@ protected function _parseOutputData(&$return_data, $raw_data)
5056
{
5157
$return_data['started'] = true;
5258

59+
$return_data['process_file'] = $this->_progress_file;
60+
5361
// parse out the details of the data into the seperate chunks.
5462
$parts = preg_split('/frame=/', $raw_data);
5563
array_shift($parts);

src/PHPVideoToolkit/ProgressHandlerOutput.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ protected function _parseOutputData(&$return_data, $raw_data)
2424
{
2525
$return_data['started'] = true;
2626

27+
if(preg_match('/Input\s#0,\s+[^\s]+,\s+from\s+(.*):/', $raw_data, $input_matches) > 0)
28+
{
29+
$return_data['input_file'] = trim($input_matches[1], '\'"');
30+
}
31+
if(preg_match('/Output\s#0,\s+[^\s]+,\s+to\s+(.*):/', $raw_data, $output_matches) > 0)
32+
{
33+
$return_data['output_file'] = trim($output_matches[1], '\'"');
34+
}
35+
$return_data['process_file'] = $this->_ffmpeg_process->getBufferOutput();
36+
2737
// parse out the details of the data.
2838
if(preg_match_all(
2939
'/frame=\s*([0-9]+)\s'.

src/PHPVideoToolkit/ProgressHandlerPortable.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ protected function _processOutputFile()
106106
if($return_data['percentage'] >= 100)
107107
{
108108
$return_data['percentage'] = 100;
109-
$return_data['output_file'] = ''; // TODO
110109
$return_data['run_time'] = filemtime($this->_output)-$this->_time_started;
111110
}
112111
// or if it has been interuptted
@@ -188,6 +187,16 @@ protected function _parseOutputData(&$return_data, $raw_data)
188187
}
189188
$total_duration = new Timecode($total_duration, Timecode::INPUT_FORMAT_TIMECODE);
190189

190+
if(preg_match('/Input\s#0,\s+[^\s]+,\s+from\s+(.*):/', $raw_data, $input_matches) > 0)
191+
{
192+
$return_data['input_file'] = trim($input_matches[1], '\'"');
193+
}
194+
if(preg_match('/Output\s#0,\s+[^\s]+,\s+to\s+(.*):/', $raw_data, $output_matches) > 0)
195+
{
196+
$return_data['output_file'] = trim($output_matches[1], '\'"');
197+
}
198+
$return_data['process_file'] = $this->_output;
199+
191200
// parse out the details of the data.
192201
if(preg_match_all(
193202
'/frame=\s*([0-9]+)\s'.
@@ -198,6 +207,7 @@ protected function _parseOutputData(&$return_data, $raw_data)
198207
'bitrate=\s*([0-9\.]+\s?[bkBmg\/s]+)'.
199208
'(\sdup=\s*([0-9]+))?'.
200209
'(\sdrop=\s*([0-9]+))?'.
210+
'(\sdrop=\s*([0-9]+))?'.
201211
'/', $raw_data, $matches) > 0)
202212
{
203213
$last_key = count($matches[0])-1;

0 commit comments

Comments
 (0)