| Q | A
| -------------- | ---
| Bug? | yes
| New Feature? | no
| Version Used | 0.12
| FFmpeg Version | FFmpeg 3.4.1
| OS | Windows 10
Adding a clip filter with the optional duration set to NULL throws an error.
Fatal error: Call to a member function toSeconds() on null in ...php-ffmpeg\src\FFMpeg\Media\AbstractVideo.php on line 89
Adding a clip filter with the optional duration set to NULL shouldn't throw an error.
$ffmpeg = \FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('path\to\video\input.mp4');
$video->filters()->clip(\FFMpeg\Coordinate\TimeCode::fromSeconds(10), NULL);
$video->save(new \FFMpeg\Format\Video\X264('libmp3lame'), 'path\to\video\output.mp4');
Modify \FFMpeg\Media\AbstractVideo::save() to avoid calling toSeconds() on NULL:
Change:
foreach ($filters as $filter) {
if ($filter instanceof ClipFilter) {
$duration = $filter->getDuration()->toSeconds();
break;
}
}
To:
foreach ($filters as $filter) {
if ($filter instanceof ClipFilter) {
if ($filter->getDuration() === NULL) {
continue;
}
$duration = $filter->getDuration()->toSeconds();
break;
}
}
I haven't found any issues yet with this change, with duration set to NULL it seems to happily create the video from the in point to the end of the file.
Thanks for reporting @mdolnik
Would you mind filing a pull request with your proposed change?
I've been trying to push a change for 20 mins to no avail.
I can't seem to get permission to push my commit, after all sorts of combinations of changing the remote repository settings back and forth between ssh and https and setting up oath keys and ssh keys and no luck.
The change is simple enough, can someone else make the change and pull request for me?
I can't seem to get permission to push my commit
Yes, you may not push directly here. However, you are allowed to fork this repository. Then you may push the commit to a new branch and then you can file a pull request on this repo.
Yes, you may not push directly here. However, you are allowed to fork this repository.
Sorry that seems to me like too much effort to make a 3 line change, I'll just have my change local for now, and someone else with an existing fork can make the effort if they wish.
I have attached a patch for anyone interested.
github_issue_566.zip