File tree Expand file tree Collapse file tree 4 files changed +6
-12
lines changed Expand file tree Collapse file tree 4 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -61,15 +61,9 @@ public function duration(string $input): float
61
61
{
62
62
$ metadata = $ this ->metadata ($ input );
63
63
64
- if ($ stream = $ metadata ['streams ' ][0 ] ?? null ) {
65
-
66
- // @phpstan-ignore-next-line
67
- $ duration = (float ) data_get ($ stream , 'duration ' );
64
+ $ duration = (float ) data_get ($ metadata , 'format.duration ' );
68
65
69
- return $ duration * 1_000 ;
70
- }
71
-
72
- throw VideoStreamNotFoundException::atPath ($ input );
66
+ return $ duration * 1_000 ;
73
67
}
74
68
75
69
/**
Original file line number Diff line number Diff line change 22
22
expect ($ conversion )->toBeInstanceOf (MediaConversion::class);
23
23
expect ($ conversion ->width )->toBe (10 );
24
24
expect ($ conversion ->extension )->toBe ('mp4 ' );
25
+ expect (round ($ conversion ->duration ))->toBe (2763.0 );
25
26
26
27
});
27
28
Original file line number Diff line number Diff line change 22
22
expect ($ conversion )->toBeInstanceOf (MediaConversion::class);
23
23
expect ($ conversion ->width )->toBe (10 );
24
24
expect ($ conversion ->extension )->toBe ('webm ' );
25
-
25
+ expect ( round ( $ conversion -> duration ))-> toBe ( 2740.0 );
26
26
});
27
27
28
28
it ('converts and resizes a gif into a webm ' , function () {
41
41
expect ($ conversion )->toBeInstanceOf (MediaConversion::class);
42
42
expect ($ conversion ->width )->toBe (10 );
43
43
expect ($ conversion ->extension )->toBe ('webm ' );
44
-
45
44
});
Original file line number Diff line number Diff line change 24
24
expect ($ dimension ?->width)->toBe (1080 );
25
25
});
26
26
27
- it ('get the correct duration of a video ' , function () {
27
+ it ('get the correct duration of an mp4 video ' , function () {
28
28
29
29
$ file = $ this ->getTestFile ('videos/horizontal.mp4 ' );
30
30
31
31
$ duration = Video::duration ($ file );
32
32
33
- expect ($ duration )->toBe (2736.067 );
33
+ expect (round ( $ duration )) ->toBe (2763.0 );
34
34
});
You can’t perform that action at this time.
0 commit comments