PHP-FFMpeg: extractMultipleFrames creates too many frame images than expected

Q A
Bug? Yes
New Feature? no
Version Used ^0.11.1
FFmpeg Version ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers built with Apple LLVM version 8.1.0 (clang-802.0.42)
OS OSX 10.33.3

Actual Behavior

How does PHP-FFMpeg behave at the moment?

When I use extractMltipleFrames(ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, $dir) using 1 minutes video, I get 1682 images (frameXXXX.jpg) AND for some reason I also get output_XX files. (mentioned in https://github.com/PHP-FFMpeg/PHP-FFMpeg/issues/493)

NOTE For some reason I have to do $video->save($format, $path); at the end (see full code below). This ends up with frame*.jpg & output_*.png while the .png files are irrelevant in this case. Is it by design?

Expected Behavior

What is the behavior you expect?

For 1 minute video I’d expect to have 60 images (1 per second).

Steps to Reproduce

What are the steps to reproduce this bug? Please add code examples, screenshots or links to GitHub repositories that reproduce the problem.

$ composer require php-ffmpeg/php-ffmpeg $ curl -O https://gist.githubusercontent.com/Shaked/98bd85babc56f3b68605c2165dfc8797/raw/f496d59e2f6f2e1471e8f12aaebde9d4e02f1f53/php-ffmpeg.php $ php php-ffmpeg.php $ ls -la /tmp/test_dir

Possible Solutions

If you have already ideas how to solve the issue, add them here. Otherwise remove this section.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 15 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Awesome, could you please file a PR(with tests) as soon as the current one has been approved? Please do not do it yet, because your first PR is based on the master branch.

Yes I will start making one and file a PR this week. Thank you

Ah, okay.

Got it!

We’re setting the output thing twice, so instead of

ffmpeg -y -i test-video-494.mp4 output/frame-%02d.jpg -vcodec libx264 -acodec libfaac -b:v 1000k -refs 6 -coder 1 -sc_threshold 40 -flags +loop -me_range 16 -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -trellis 1 -b:a 128k -vf [in]fps=1/60[out] output/output_%d.png

we should use

ffmpeg -y -i test-video-494.mp4 -vcodec libx264 -acodec libfaac -b:v 1000k -refs 6 -coder 1 -sc_threshold 40 -flags +loop -me_range 16 -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -trellis 1 -b:a 128k -vf [in]fps=1/60[out] output/output_%d.png

Note that we’re only giving it one output stream and perhaps ffmpeg thinks we give two inputs to it.

Perhaps you want to fix it? It’s an easy bug after the first look. 😃

Alright, that is very helpful. Thank you! I’m going to investigate, now.

Thank you for the report! Will look into this in the next days, I’m in a hurry atm. Feel free to ping me when I don’t reply until Thursday. 😃