Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ffprobe frames and additional options #686

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Skyree
Copy link

@Skyree Skyree commented Nov 13, 2019

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets fixes #issuenum
Related issues/PRs #issuenum
License MIT

What's in this PR?

This PR adds a new api method to retrieve frames through ffprobe
It also adds a support for additional options allowing more custom calls
As an addition, as last method has been added to StreamCollection and FrameCollection for easier retrieval

I also regenerated the api doc which was largely outdated, using sami 1.4.1, feel free to hide this commit to make the review easier

Why?

Frames information can be needed in some cases (see example below)
Additional options allow some filtering directly within ffprobe which would otherwise require iteration and operations on our output and therefore defeat the purpose ffprobe having such features

Example Usage

Retrieving the starting byte and ending byte matching a timestamp interval in an audio file (needed to generate audio previews without persistence)

$probe = FFProbe::create();
$filepath = 'tests/files/Jahzzar_-_05_-_Siesta.mp3';

// Now we can do
$options = array('-select_streams a', '-read_intervals 00:08%00:18');
$frames = $probe->frames($filepath, $options);
$startByte = $frames->first()->get('pkt_pos');
$endByte = $frames->last()->get('pkt_pos');
echo sprintf('The byte interval closest to 08 -> 18 seconds is %d -> %d', $startByte, $endByte);

// Outputs: The byte interval closest to 08 -> 18 seconds is 193618 -> 433735

Backward compatibility

No BC break.
Interfaces are left unmodified and public api methods only offer a new parameter with a default value not altering the behavior in any way
Unit tests have been updated accordingly

* Add FFProbe::frames api method
* Add method last for StreamCollection and FrameCollection
* Add support for additional options in FFProbe api methods
@jens1o jens1o added this to the 1.x milestone Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants