Comment fix, Video size calculation base on the new video duration and added case on the VideoProgressListenerTest test class.
This commit is contained in:
parent
53a978e021
commit
368c65a7d5
3 changed files with 25 additions and 11 deletions
|
|
@ -255,9 +255,8 @@ abstract class AbstractProgressListener extends EventEmitter implements Listener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->totalSize = $format->get('size') / 1024;
|
$this->duration = (int) $this->duration > 0 ? $this->duration : $format->get('duration');
|
||||||
$this->duration = (int) $this->duration > 0 ? (int) $this->duration : $format->get('duration');
|
$this->totalSize = $format->get('size') / 1024 * ($this->duration / $format->get('duration'));
|
||||||
|
|
||||||
$this->initialized = true;
|
$this->initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,12 +83,10 @@ class Video extends Audio
|
||||||
if ($format instanceof ProgressableInterface) {
|
if ($format instanceof ProgressableInterface) {
|
||||||
$filters = clone $this->filters;
|
$filters = clone $this->filters;
|
||||||
$duration = 0;
|
$duration = 0;
|
||||||
/*
|
|
||||||
check the filters of the video,
|
// check the filters of the video, and if the video has the ClipFilter then
|
||||||
and if the video has the ClipFilter than:
|
// take the new video duration and send to the
|
||||||
take the new video duration and send to the
|
// FFMpeg\Format\ProgressListener\AbstractProgressListener class
|
||||||
FFMpeg\Format\ProgressListener\AbstractProgressListener class
|
|
||||||
*/
|
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
if($filter instanceof ClipFilter){
|
if($filter instanceof ClipFilter){
|
||||||
$duration = $filter->getDuration()->toSeconds();
|
$duration = $filter->getDuration()->toSeconds();
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class VideoProgressListenerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideData
|
* @dataProvider provideData
|
||||||
*/
|
*/
|
||||||
public function testHandle($size, $duration,
|
public function testHandle($size, $duration, $newVideoDuration,
|
||||||
$data, $expectedPercent, $expectedRemaining, $expectedRate,
|
$data, $expectedPercent, $expectedRemaining, $expectedRate,
|
||||||
$data2, $expectedPercent2, $expectedRemaining2, $expectedRate2,
|
$data2, $expectedPercent2, $expectedRemaining2, $expectedRate2,
|
||||||
$currentPass, $totalPass
|
$currentPass, $totalPass
|
||||||
|
|
@ -26,7 +26,7 @@ class VideoProgressListenerTest extends TestCase
|
||||||
'duration' => $duration,
|
'duration' => $duration,
|
||||||
))));
|
))));
|
||||||
|
|
||||||
$listener = new VideoProgressListener($ffprobe, __FILE__, $currentPass, $totalPass);
|
$listener = new VideoProgressListener($ffprobe, __FILE__, $currentPass, $totalPass, $newVideoDuration);
|
||||||
$phpunit = $this;
|
$phpunit = $this;
|
||||||
$n = 0;
|
$n = 0;
|
||||||
$listener->on('progress', function ($percent, $remaining, $rate) use (&$n, $phpunit, $expectedPercent, $expectedRemaining, $expectedRate, $expectedPercent2, $expectedRemaining2, $expectedRate2) {
|
$listener->on('progress', function ($percent, $remaining, $rate) use (&$n, $phpunit, $expectedPercent, $expectedRemaining, $expectedRate, $expectedPercent2, $expectedRemaining2, $expectedRate2) {
|
||||||
|
|
@ -57,6 +57,7 @@ class VideoProgressListenerTest extends TestCase
|
||||||
array(
|
array(
|
||||||
147073958,
|
147073958,
|
||||||
281.147533,
|
281.147533,
|
||||||
|
281.147533,
|
||||||
'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0',
|
'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0',
|
||||||
2,
|
2,
|
||||||
0,
|
0,
|
||||||
|
|
@ -71,6 +72,7 @@ class VideoProgressListenerTest extends TestCase
|
||||||
array(
|
array(
|
||||||
147073958,
|
147073958,
|
||||||
281.147533,
|
281.147533,
|
||||||
|
281.147533,
|
||||||
'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0',
|
'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0',
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
|
|
@ -81,6 +83,21 @@ class VideoProgressListenerTest extends TestCase
|
||||||
3868,
|
3868,
|
||||||
1,
|
1,
|
||||||
2
|
2
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
147073958,
|
||||||
|
281.147533,
|
||||||
|
35,
|
||||||
|
'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0',
|
||||||
|
60,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'frame= 854 fps=113 q=20.0 size= 4430kB time=00:00:33.04 bitrate=1098.5kbits/s dup=36 drop=0',
|
||||||
|
97,
|
||||||
|
0,
|
||||||
|
3868,
|
||||||
|
2,
|
||||||
|
2
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue