Skip to content

Commit 6bdeb5c

Browse files
committed
Fix for #393
1 parent 317a047 commit 6bdeb5c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All Notable changes to `pbmedia/laravel-ffmpeg` will be documented in this file
44

5+
## 8.1.1 - 2022-05-13
6+
7+
- Bugfix for parsing the average frame rate.
8+
59
## 8.1.0 - 2022-05-12
610

711
- You may now specify a separate temporary disk for processing HLS exports.

src/Support/StreamParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function new(Stream $stream): StreamParser
2121

2222
public function getFrameRate(): ?string
2323
{
24-
$frameRate = trim(Str::before(optional($this->stream)->get('avg_frame_rate'), "/1"));
24+
$frameRate = trim(optional($this->stream)->get('avg_frame_rate'));
2525

2626
if (!$frameRate || Str::endsWith($frameRate, '/0')) {
2727
return null;

tests/StreamParserTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace ProtoneMedia\LaravelFFMpeg\Tests;
4+
5+
use FFMpeg\FFProbe\DataMapping\Stream;
6+
use ProtoneMedia\LaravelFFMpeg\Support\StreamParser;
7+
8+
class StreamParserTest extends TestCase
9+
{
10+
/** @test */
11+
public function it_can_extract_the_average_frame_rate()
12+
{
13+
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => 25]))->getFrameRate());
14+
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => '25/1']))->getFrameRate());
15+
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => '250/10']))->getFrameRate());
16+
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => '50/2']))->getFrameRate());
17+
}
18+
}

0 commit comments

Comments
 (0)