Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st March 2024, 09:46   #2901  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by poisondeathray View Post
If the MP4 is timestamp VFR variety - It does not drop frames if you omit the fpsnum, fpsden options . You only get the encoded frames and average FPS.
AFAIK now, to preserve the audio sync, you must add the (...,timecodes = "timestamp.txt",... ) in order to mux video/audio with that in a container.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 21st March 2024, 14:47   #2902  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by tebasuna51 View Post
AFAIK now, to preserve the audio sync, you must add the (...,timecodes = "timestamp.txt",... ) in order to mux video/audio with that in a container.
Yes, and that will give you a file similar to the original in terms of VFR timing . You can also extract timestamps with other methods such as ffmpeg, mkvextract (for mkv), mp4fpsmod (for mp4)

One benefit of not using fpsnum, fpsden is you get unique frames - this is beneficial if you were using temporal filtering, or if you were using "slow" filters such as some machine learning - there is no reason to use duplicates

You can add ChangeFPS to add the duplicates frames and make it CFR afterwards . There are also VFR to CFR avs plugins that read the timestamp/timecodes file if you needed CFR
poisondeathray is offline   Reply With Quote
Old 22nd March 2024, 11:04   #2903  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by rgr View Post
And that's what I want to avoid. I just want all frames (without duplicating or dropping) like VirtualDub does. So I want to treat VFR as CFR. I'll change the FPS later anyway, and the audio doesn't matter.
FFMS2 can write the timecodes to a text file while indexing. You can use the TimeCodes argument to specify the name/location of the timecodes file.
The video is decoded at the average frame rate, but if you happen to be encoding with the x264 encoder, you can add the timecodes to the command line and it'll encode in VFR mode.

--tcfile-in "D:\timecodes.txt"

It's been a while since I've encoded anything as VFR, but the first line of the timecodes file should look like this:
# timecode format v2
or this:
# timestamp format v2
I can't remember if x264 accepts both these days, but if the timecodes file isn't recognized, try changing the first line.
hello_hello is offline   Reply With Quote
Old 22nd March 2024, 11:12   #2904  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by poisondeathray View Post
You can add ChangeFPS to add the duplicates frames and make it CFR afterwards . There are also VFR to CFR avs plugins that read the timestamp/timecodes file if you needed CFR
At the risk of being argumentative, ChangeFPS can't convert VFR to CFR correctly. If you had an imaginary video where the first half was 15fps and the second half was 30fps, the average frame rate would be 25fps. If you used ChangeFPS(30) to convert it to 30fps, the extra frames would be inserted evenly throughout the video, but to keep the A/V sync, the extra frames all need to be inserted in the first half.
hello_hello is offline   Reply With Quote
Old 22nd March 2024, 14:59   #2905  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by hello_hello View Post
At the risk of being argumentative, ChangeFPS can't convert VFR to CFR correctly. If you had an imaginary video where the first half was 15fps and the second half was 30fps, the average frame rate would be 25fps. If you used ChangeFPS(30) to convert it to 30fps, the extra frames would be inserted evenly throughout the video, but to keep the A/V sync, the extra frames all need to be inserted in the first half.
Correct - and that's important to clarify. I only mentioned ChangeFPS because rgr didn't need audio or sync . He could use AssumeFPS without drops or duplicates as well

I also mentioned avs plugins that read the timecodes when converting to CFR, which is better way to do it when you have audio.

https://github.com/Asd-g/TimecodeFPS

https://github.com/jojje/VfrToCfr-the-other-one
poisondeathray is offline   Reply With Quote
Old 25th March 2024, 13:55   #2906  |  Link
ravewulf
Registered User
 
Join Date: Dec 2010
Posts: 22
Quote:
Originally Posted by FranceBB View Post
yep, fixed.



You... can't, I'm afraid. You can only output a certain framerate and to obtain that ffms2 will either drop or duplicate.
The best bet is to set fpsnum and fpsden to get the maximum output framerate so that it will never drop frames.
Sure, there will be dups scattered here and there, but that's not a problem.
Why? Simple. It's because it's exactly what you would see if you were to open a VFR video on any other player.
Simply put, if you have a video with VFR that oscillates from 10fps to 60fps as the example I mentioned above and you were to play it on your computer connected to a 60Hz monitor, the player would output 60fps all the time to the monitor (that's excluding FreeSync/GSync monitors which are not that common anyway).


In other words, trust me, just set fpsnum and fpsden to the maximum FPS of the video and you're gonna be fine.
Encoding it as CFR is gonna be fine anyway 'cause x264 is really good at spotting duplicated frames so it will just put a B frame there with a reference to the former frame, thus wasting virtually no bitrate. Besides, if you still wanna re-encode it to VFR instead of CFR post Avisynth, you still can anyway as FFMpeg->libx264 can automatically remove dups and encode it as VFR for you.
Just to make sure this is explicitly corrected:

Quote:
int fpsnum = -1, int fpsden = 1
Controls the framerate of the output; used for VFR to CFR conversions. If fpsnum is less than or equal to zero (the default), the output will contain the same frames that the input did, and the frame rate reported to Avisynth will be set based on the input clip's average frame duration. If fpsnum is greater than zero, FFVideoSource will force a constant frame rate, expressed as a rational number where fpsnum is the numerator and fpsden is the denominator. This may naturally cause FFVideoSource to drop or duplicate frames to achieve the desired frame rate, and the output is not guaranteed to have the same number of frames that the input did.
https://github.com/FFMS/ffms2/blob/m...-int-fpsden--1
ravewulf is offline   Reply With Quote
Old 25th March 2024, 21:53   #2907  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Fair enough.
FranceBB is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:09.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.