Skip to content

Commit

Permalink
Fix for #393
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed May 13, 2022
1 parent 317a047 commit 6bdeb5c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## 8.1.1 - 2022-05-13

- Bugfix for parsing the average frame rate.

## 8.1.0 - 2022-05-12

- You may now specify a separate temporary disk for processing HLS exports.
Expand Down
2 changes: 1 addition & 1 deletion src/Support/StreamParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function new(Stream $stream): StreamParser

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

if (!$frameRate || Str::endsWith($frameRate, '/0')) {
return null;
Expand Down
18 changes: 18 additions & 0 deletions tests/StreamParserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace ProtoneMedia\LaravelFFMpeg\Tests;

use FFMpeg\FFProbe\DataMapping\Stream;
use ProtoneMedia\LaravelFFMpeg\Support\StreamParser;

class StreamParserTest extends TestCase
{
/** @test */
public function it_can_extract_the_average_frame_rate()
{
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => 25]))->getFrameRate());
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => '25/1']))->getFrameRate());
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => '250/10']))->getFrameRate());
$this->assertEquals(25, StreamParser::new(new Stream(['avg_frame_rate' => '50/2']))->getFrameRate());
}
}

0 comments on commit 6bdeb5c

Please sign in to comment.