View Full Version : ShowSMPTE() drop-frame algorithms
fvisagie
24th September 2015, 11:33
I'm looking for the algorithms used to implement ShowSMPTE's drop-frame counting. It's help file (http://avisynth.nl/index.php/ShowSMPTE) covers NTSC TV, but none of the others:Something similar holds also for the following framerates:
framerate range base-rate
[47.951, 47.953] 48
[59.939, 59.941] 60
[119.879, 119.881] 120
I've found some discussion of NTSC film rate (http://forum.doom9.org/showpost.php?p=1172728&postcount=11) and double NTSC film rate (http://forum.doom9.org/showpost.php?p=858937&postcount=6), but nothing that indicates what was eventually decided upon.
Any ideas how those were implemented?
raffriff42
24th September 2015, 14:43
Sure, it's in the source code:
http://avisynth2.cvs.sourceforge.net/viewvc/avisynth2/avisynth/src/filters/text-overlay.cpp?view=markup#l815 if (dropframe) {
if (rate == 30) {
int c = 0;
c = off_min + 60*off_hour; // number of drop events
c -= c/10; // less non-drop events on 10 minutes
c *=2; // drop 2 frames per drop event
offset_f -= c;
}
else {
// Need to cogitate with the guys about this
// gotta drop 86.3 counts per hour. So until
// a proper formula is found, just wing it!
offset_f -= 2 * ((offset_f+1001)/2002);
}
kolak
24th September 2015, 15:31
I have used this (in my own bash scripting)
From frames to DF timecode:
fps=30
D=$(( frames/17982 ))
M=$(( frames%17982 ))
frames=$(( frames+ 18*D + 2*((M - 2)/1798) ))
# Count frames, seconds, minutes and hours
frame=$(( frames%fps ))
second=$(( frames/fps%60 ))
minute=$(( frames/fps/60%60 ))
hour=$(( frames/fps/60/60%24 ))
It's based on the code provided by some SMPTE guy and works fine even up to 24H TC.
fvisagie
25th September 2015, 12:53
I was afraid of having to look at code. ;)
Thanks, I'm sure I'll be able to put this to good use.
kolak
25th September 2015, 12:56
It works well, even if it looks strange :)
I did figure it out, but don't remember anymore.
Also note that DF timecode only exists for 29.97p, 59.94i, 59.94p.
There is no such a thing in the industry for eg. 23.976p.
fvisagie
28th September 2015, 08:49
I managed, thank you both.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.