Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] *Handling of VFR video.* #557

Open
SysVR opened this issue Oct 14, 2023 · 0 comments
Open

[Feature request] *Handling of VFR video.* #557

SysVR opened this issue Oct 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@SysVR
Copy link

SysVR commented Oct 14, 2023

Is your feature request related to a problem? Please describe.
Converting VFR (Variable Frame Rate) video to CFR (Constant Frame Rate) is indeed problematic, as it can lead to frame drops depending on the FPS.

Describe the solution you'd like
By exporting directly without converting VFR to CFR, you can prevent frame drops.

Describe alternatives you've considered
Export without converting VFR to CFR directly.

Additional context
The correct approach is to generate a pkt_pts_time list and directly output VFR to frame images. The FPS of the video, which can be read with tools like ffprobe, is the average frame rate.
You can obtain the frame timestamps of a video using the following command line:

ffprobe "filename" -select_streams v:0 -print_format json -show_entries frame=pkt_pts_time

This command will provide you with the frame timestamps for the video in JSON format.

The total number of frames in the video is multiplied by the Interpolation_multiplier, and the pkt_pts_time is also multiplied by the Interpolation_multiplier. Then, the values are interpolated by adding the frames before and after, and dividing the result by Interpolation_multiplier.

Here's the description you provided in English:

new_frames[int]: The value obtained after multiplying the total frame count by Interpolation_multiplier. This represents the total frame count after interpolation.

new_pts_time: The value obtained by multiplying the original pkt_pts_time by Interpolation_multiplier.

0.The original pkt_pts_time value multiplied by Interpolation_multiplier.
1.The result of adding the values at frames 0 and 2 of new_pts_time, and then dividing the sum by Interpolation_multiplier.
2.The original pkt_pts_time value multiplied by Interpolation_multiplier.

And so on, for each frame in the video.

for(frames){
new_calc_pkt_pts_time[frames]=pkt_pts_time[frames]*&Interpolation_multiplier;
}

new_frames=0;
for(frames){
   new_frames++;
   new_pkt_pts_time[new_frames]=new_calc_pkt_pts_time[frames];
   for((&Interpolation_multiplier-1)){
      new_pkt_pts_time[new_frames]=(new_pkt_pts_time[new_frames]+new_pkt_pts_time[new_frames++])/&Interpolation_multiplier;
      new_frames++;
   }
}

If you want to make the final video CFR instead of VFR, you can calculate the highest FPS using the frame intervals of the original video's pkt_pts_time and then use that FPS for the final video.

FPS=1/frame intervals.

@AaronFeng753 AaronFeng753 added enhancement New feature or request and removed Feature request labels Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants