in the same PHP process I'm trying to open a file that was manipulated and saved, and then I'm trying to open it with as a new FFMpeg\Video. For example, in the same process:
Open -> original.MOV
Manipulate & save to -> new.mp4
Open -> new.mp4
However when I'm trying to open the manipulated file I get this InvalidArgumentException exception:
InvalidArgumentException: Unable to detect file format, only audio and video supported
It's thrown by the FFMpeg::open() after it could not detect that it's a either Video or Audio stream.
FFMpeg::open()
public function open($pathfile) { if (null === $streams = $this->ffprobe->streams($pathfile)) { throw new RuntimeException(sprintf('Unable to probe "%s".', $pathfile)); } if (0 < count($streams->videos())) { return new Video($pathfile, $this->driver, $this->ffprobe); } elseif (0 < count($streams->audios())) { return new Audio($pathfile, $this->driver, $this->ffprobe); } throw new InvalidArgumentException('Unable to detect file format, only audio and video supported'); }
The filters I applied to the video are audio mute and speedup (setpts).
So I wonder, why FFMpeg doesn't recognise it as video?
Apparently I was trying to open a video file that was corrupted or incomplete. Anyway, the problem wasn't with the code or god forbid - php-ffmpeg. 🙃