diff --git a/README.md b/README.md index a8a0f12..3f7cc1f 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ below for more informations. You can extract a frame at any timecode using the `FFMpeg\Media\Video::frame` method. -This code return a `FFMpeg\Media\Frame` instance corresponding to the second 42. +This code returns a `FFMpeg\Media\Frame` instance corresponding to the second 42. You can pass any `FFMpeg\Coordinate\TimeCode` as argument, see dedicated documentation below for more information. @@ -145,6 +145,42 @@ $frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42)); $frame->save('image.jpg'); ``` +##### Generate a waveform + +You can generate a waveform of an audio file using the `FFMpeg\Media\Audio::waveform` +method. + +This code returns a `FFMpeg\Media\Waveform` instance. +You can optionally pass dimensions as arguments, see dedicated +documentation below for more information. + +The ouput file MUST use the PNG extension. + +```php +$waveform = $audio->waveform(640, 120); +$waveform->save('waveform.png'); +``` + +If you want to get a waveform from a video, convert it in an audio file first. + +```php +// Open your video file +$video = $ffmpeg->open( 'video.mp4' ); + +// Set an audio format +$audio_format = new FFMpeg\Format\Audio\Mp3(); + +// Extract the audio into a new file +$video->save('audio.mp3'); + +// Set the audio file +$audio = $ffmpeg->open( 'audio.mp3' ); + +// Create the waveform +$waveform = $audio->waveform(); +$waveform->save( 'waveform.png' ); +``` + ##### Filters You can apply filters on `FFMpeg\Media\Video` with the `FFMpeg\Media\Video::addFilter` diff --git a/docs/source/API/API/FFMpeg/Format/Video/X264.html b/docs/source/API/API/FFMpeg/Format/Video/X264.html index 399b173..bcf7d52 100644 --- a/docs/source/API/API/FFMpeg/Format/Video/X264.html +++ b/docs/source/API/API/FFMpeg/Format/Video/X264.html @@ -119,7 +119,17 @@ - string + integer + + + setPasses(integer $passes) +

Sets the number of passes.

+ + + + + + integer getPasses() @@ -499,12 +509,37 @@ + + + +

+
in X264 at line 68
+ public integer + setPasses(integer $passes) +

+
+

Sets the number of passes.

+

+

+
+ +

Parameters

+ + + + + + +
integer$passes
+ + +

-
at line 68
- public string +
in X264 at line 79
+ public integer getPasses()

@@ -517,7 +552,7 @@ - + diff --git a/docs/source/API/API/FFMpeg/Media/Audio.html b/docs/source/API/API/FFMpeg/Media/Audio.html index 3a8be2c..afdb3fe 100644 --- a/docs/source/API/API/FFMpeg/Media/Audio.html +++ b/docs/source/API/API/FFMpeg/Media/Audio.html @@ -171,6 +171,16 @@

Exports the audio in the desired format, applies registered filters.

+ + + + +
stringinteger
+ Audio + + waveform(integer $width, integer $height) +

Generates an image file representing the waveform of the audio file.

+
@@ -609,6 +619,59 @@
+

+
at line 113
+ public Audio + save(FormatInterface $format, string $outputPathfile) +

+
+

Exports the audio in the desired format, applies registered filters.

+

+

+
+

Parameters

+ + + + + + + + + + + + +
FormatInterface$format +
string$outputPathfile +
+ + +

Return Value

+ + + + + + +
Audio +
+ + +

Exceptions

+ + + + + + +
RuntimeException +
+ + +
+
+