LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to force decoding a video at a certain fps (https://www.linuxquestions.org/questions/linux-software-2/how-to-force-decoding-a-video-at-a-certain-fps-4175629009/)

Mohammed BEY 05-04-2018 06:06 AM

How to force decoding a video at a certain fps
 
Hello,
I am working on video decoding using FFmpeg.
When I try to decode a video which is encoded with h265 at a certain fps (ex: fps=25), the result is a decoded video but at a different fps.
How can I decode a video at exactly fps=25, even if I have a high miss rate?
I use this command to decode:
ffmpeg -benchmark -i <file_name> -f null out.null

Please, any help is welcome.
Thank you in advance.

BW-userx 05-04-2018 09:00 AM

I use HandBrake. give it a try, it has both, gui, and cli.

Mohammed BEY 05-04-2018 12:26 PM

Thank you for your suggestion. I found it interesting.
However, in my research project, I have to work with FFmpeg.

teckk 05-04-2018 03:03 PM

Quote:

How to force decoding a video at a certain fps
What do you mean by that. 25fps is the play speed of that video.
25 frames every second.
Quote:

ffmpeg -benchmark -i <file_name> -f null out.null
This runs as fast as your machine will go.
From man ffmpeg
Code:

-benchmark (global)
    Show benchmarking information at the end of an encode.  Shows CPU time
    used and maximum memory consumption.  Maximum memory consumption is not
    supported on all systems, it will usually display as 0 if not
    supported.

-benchmark_all (global)
    Show benchmarking information during the encode.  Shows CPU time used
    in various steps (audio/video encode/decode).

Quote:

How can I decode a video at exactly fps=25
Play the video at normal speed.

What are you trying to accomplish?

Mohammed BEY 05-04-2018 03:32 PM

Thank you for your reply.
Yes, I mean by "fps" frame per second.
In my study, I want to decode a video without displaying it. Then, calculate the miss rate.
You mentioned an important point: "This runs as fast as your machine will go". However, I want that FFmpeg decodes at 25 fps in order to be able to calculate the miss rate.
Please, How to play a video at normal speed?

dave@burn-it.co.uk 05-05-2018 01:28 PM

Surely the important thing in your calculation is the rate at which it was ENCODED.?
You can then calculate how many frames would need to be dropped or not at any speed.

Mohammed BEY 05-05-2018 01:55 PM

Quote:

Originally Posted by dave@burn-it.co.uk (Post 5851087)
Surely the important thing in your calculation is the rate at which it was ENCODED.?
You can then calculate how many frames would need to be dropped or not at any speed.

I know the fps at which the video is encoded. I want to decode the video exactly at that fps.
Please, could you describe how to run at a specific speed (fps)?

dave@burn-it.co.uk 05-05-2018 02:04 PM

It should play at the rate you encoded it at if the machine is fast enough.
It should never play faster unless you deliberately ask it to or change your machines clock speed.
It may play slower if your machine cannot cope with the speed it was encoded at.

Mohammed BEY 05-05-2018 02:15 PM

Thank you for your explanation.
If the speed (fps) depends on the machine, so we never get the miss rate?
Could you explain to me how do the video players (like vlc) work? If we give it a video encoded at 30 fps it will play it at 30 fps, but the result is not the same if we use 2 different machines in terms of performance. One presents better quality than the other.

dave@burn-it.co.uk 05-05-2018 02:48 PM

If your cpu and video card are powerful enough to play at 30 fps at the resolution you have chosen (and no other programs are interfering) there should be no dropped frames.

VLC will play at the rate the file was encoded at unless you tell it otherwise or the machine cannot cope ( as above)

The QUALITY of the output will depend on the quality of the graphics card and the screen even if both have sufficient resources to play it, so you should not really expect the output to look exactly the same.
For instance: DIGITAL displays do not have as high a screen resolution as a CRT screens and also do not support the same range of colours. Even two CRTs stood next to each other may have been set up differently and display different colours.
Why do you think that graphics cards vary so much in price??

Mohammed BEY 05-05-2018 04:16 PM

Thank you for all these details.
I am a newbie to this field and I don't have enough knowledge.

ondoho 05-06-2018 07:55 AM

you need to get your terminology right.
what do you mean by "decode"?
this is what happens when you watch the video: it gets decoded into frames that you see, at the exact framerate, if your hardware is fast enough (otherwise, during playback, usually framedrops occur. is that what you mean by "miss"?).
if you don't want to watch it, choose /dev/null as video output, or dummy or something.
read ffmpeg documentation.

or maybe you mean "transcode"? the process of decoding the video, and then re-encoding it in a different format? that is usually much slower than watching ("decoding") it.

Mohammed BEY 05-06-2018 09:21 AM

Thank you for your reply.
Yes, this is what I mean by "miss rate".
I don't want to watch the video. I want to decode the frames and throw them into /dev/null. I am using this command:
ffmpeg -benchmark -i <file_name> -f null /dev/null
If I decode at the speed of my hardware, that means that if I want to decode a video of 10 seconds encoded at 25fps, it may take 1 minute or more to decode it if my hardware is not fast enough. But I want to decode it at 25fps in 10 seconds even if my hardware is not fast enough. Of course, I will get a bad visual quality. This is not a problem. My purpose is to assess the video decoding (calculate the miss rate).

ondoho 05-06-2018 01:37 PM

Quote:

Originally Posted by Mohammed BEY (Post 5851301)
If I decode at the speed of my hardware, that means that if I want to decode a video of 10 seconds encoded at 25fps, it may take 1 minute or more to decode it if my hardware is not fast enough. But I want to decode it at 25fps in 10 seconds even if my hardware is not fast enough. Of course, I will get a bad visual quality.

not exactly. i don't think there's a setting to "do it quicker, even if it doesn't look so good" - what you will get instead are frame drops.
and in the case of HEVC, if your GPU doesn't support it and your CPU isn't fast, it will eat a LOT of resources, to the extent that you might have to specifically tell ffmpeg to not just give up.
Quote:

My purpose is to assess the video decoding (calculate the miss rate).
you already provided all the numbers needed for the calculation.
it won't get more precise than that, because you never know what else your system is busy with atm, and how many cpu (or gpu) cycles it can spare for ffmpeg's decoding.

teckk 05-06-2018 06:19 PM

Quote:

that means that if I want to decode a video of 10 seconds encoded at 25fps, it may take 1 minute or more to decode it if my hardware is not fast enough.
I assume that you mean play the video when you say decode the video?
Then you have some really old hardware if it takes a minute to play a 10 second video.

Update your hardware
Enable frame dropping in your media player
Resize the video player window into a smaller size,
Or re-encode the video into a lesser bitrate.
Quote:

I don't want to watch the video. I want to decode the frames and throw them into /dev/null
Why? I still don't have any idea what you are trying to achieve.
You can't change the frame rate that a video is, without re encoding it. You could also dump the video to a rawvideo, then play the raw video.

If you have old hardware that won't play a modern video, then update it, drop frames, or reencode the video to a format that the old machine will handle.
Quote:

But I want to decode it at 25fps in 10 seconds even if my hardware is not fast enough
Then get new hardware or re-encode the video to a lesser quality that the old machine will play.


All times are GMT -5. The time now is 04:01 PM.