1

I'm trying to use FFMPEG in order to solve some complex logic on my videos.

The business logic is the following: I get videos from the formats: avi, mp4, mov.

I don't know what is the content in the video. It can be from 1M to 5G.

I want to output a list of images from this video with the higher quality I can get. Capturing only frames that have big changes from their previous frame. (new person, a new angle, big movement, etc)

In addition, I want to limit the number of frames per second that even if the video is dramatically fast and has changed all the time it will not produce more frames per second than this parameter.

I'm using now the following command:

./ffmpeg -i "/tmp/input/fast_movies/3_1.mp4" -vf fps=3,mpdecimate=hi=14720:lo=7040:frac=0.5 -vsync 0 -s hd720 "/tmp/output/fast_movies/(#%04d).png"

According to my understanding it doing the following: fps=3 - first cut the video to 3 frames per second (So that is the limit I talked about)

mpdecimate - filter frames that doesn't have greater changes than the thresholds I set.

-vsync 0 - sync video timestamp - I'm not sure why but without it - it makes hundereds of duplicate frames ignoring the fps and mpdecimate command. Can someone explain?

-s hd720 - set video size to

It works pretty well but I'm not so happy with the quality. Do you think I miss something? Is there any parameter in FFMPEG that I better use it instead of these ones?

Udi
  • 598
  • 8
  • 19

1 Answers1

1

You can set the frame quality by appending -qscale:v 1 to your command.

qscale stand for quality scale, v stands for video, and the range is 1 to 31. 1 being the highest quality, 31 being the lowest.

WyattBlue
  • 591
  • 1
  • 5
  • 21
  • The command in the question is outputting PNG, not JPG. `-qscale:v` has no effect on PNG. – llogan Jul 18 '20 at 18:49
  • @llogan I can store in as JPG if it will improve the quality. I did some tests on this issue and saw that JPG outputs weights less so I guess they are in lower quality. Isn't it? – Udi Jul 19 '20 at 05:36
  • 1
    @Udi PNG is lossless. JPG is lossy. However, certain images can be smaller or equivalent than JPG if they are suitable for PNG compression (animations, logos, solid colors, etc). JPG is suitable for photos and more complex images. – llogan Jul 19 '20 at 18:23
  • @llogan Thanks. I understood what you wrote but I can't understand the last call - "JPG is suitable for photos and more complex images". I'm using photos from a video and the quality is more important than compression so I will use PNG. So why is JPG is more suitable? only because of his compression capability? – Udi Jul 20 '20 at 07:45
  • @Udi It was a generalization. For file size JPG is generally used for photos, and PNG for line art, solid colors, logos, drawings, etc. – llogan Jul 20 '20 at 17:45