View Full Version : New Filter: DVInfo


WarpEnterprises
18th September 2003, 12:09
This FILTER (http://www.avisynth.org/users/warpenterprises/files/dvinfo_25_dll_20030920.zip) grabs the timestamp and recording date info out of a DV-AVI.
It should work with Type-1 and Type-2, standard AVI and openDML.

You can specify the time/date as an expression which is then Subtitle'ed on the video clip.

Simplest example:

LoadPlugin("c:\myprojects\dvinfo\release\dvinfo.dll")

file="c:\myprojects\type2.avi" # so you don't need to type the filename twice

Avisource(file) #open the video content
DVInfo(file, "rec_time") # reads the recording timestamp


The filter does NOT read the video content, it only reads the timestamps of the framenumber currently passed through!

You may also look here (http://virtualdub.everwicked.com/index.php?act=ST&f=7&t=4344) for something closely related...


Technical note:
it uses AVI-file code from "kino", which I had to modify a little.

WarpEnterprises
21st September 2003, 21:23
Small Update:
* added parameter "show_error" to switch off error messages
* updated AVI code to latest version of kino
* added default value for "output" so it's enough to write DVInfo(filename)
* made docs nicer

tempetai
22nd September 2003, 02:29
WarpEnterprises,

Thanks for the filter. It is really cut down a lot of step to have recording time and date inserted into the clip. Before this I used DVSubmaker, subresync, textsub for this job. BTW, is there anyway to have AM/PM instead of 24-hours time format? Perhaps, it is good to have this feature inserted as well as different language option.

Thanks.

WarpEnterprises
22nd September 2003, 07:30
it's there, well hidden, read the readme :)

It uses the current (windows) localisation!

Example for result like: "26.Juli 2003 04:01 PM"

dvinfo(file,"rec_time",rec_format="%d.%B %Y %I:%M %p")

Here are all format specifiers:


Codes for output formatting
%a Abbreviated weekday name
%A Full weekday name
%b Abbreviated month name
%B Full month name
%c Date and time representation appropriate for locale
%d Day of month as decimal number (01 – 31)
%H Hour in 24-hour format (00 – 23)
%I Hour in 12-hour format (01 – 12)
%j Day of year as decimal number (001 – 366)
%m Month as decimal number (01 – 12)
%M Minute as decimal number (00 – 59)
%p Current locale‚s A.M./P.M. indicator for 12-hour clock
%S Second as decimal number (00 – 59)
%U Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w Weekday as decimal number (0 – 6; Sunday is 0)
%W Week of year as decimal number, with Monday as first day of week (00 – 53)
%x Date representation for current locale
%X Time representation for current locale
%y Year without century, as decimal number (00 – 99)
%YYear with century, as decimal number
%z, %Z Time-zone name or abbreviation; no characters if time zone is unknown
%% Percent sign
The # flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows.

%#a, %#A, %#b, %#B, %#p, %#X, %#z, %#Z, %#% # flag is ignored.
%#c Long date and time representation, appropriate for current locale. For example: “Tuesday, March 14, 1995, 12:41:29„.
%#x Long date representation, appropriate to current locale. For example: “Tuesday, March 14, 1995„.
%#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y Remove leading zeros (if any).

tempetai
23rd September 2003, 01:58
Great...

Thanks.

Basilik
29th October 2003, 08:36
As an alternative the same kind of plugin which I have done for myself long time ago but didn't announce widely: http://mvideo.nm.ru
Unlike DVInfo, my plugin has function for automatic time stamping when date/time changes by some value more than given threshold.

WarpEnterprises
7th January 2004, 23:45
New version (2003-12-16): I added the autoframe-features to DVInfo, too.

http://www.avisynth.org/warpenterprises/

Basilik
1st June 2004, 15:25
New features added to my plugin DVTimeStampEx (note, name changed a bit):
1) you can define a timeoffset from original taping time
2) you can force the timestamp to appear in auto mode if no DV time change occured for a long period
3) multiline support
4) font is fully customisable
5) visual effects added (same as in my SubtitleEx plugin)

See all details on my site (http://mvideo.ddpp.net).

whwhwhwh9
17th July 2005, 06:48
does DVinfo support DV files larger than 4GB? I have problems with it when processing a 6GB DV AVI, but it works OK on files smaller than 4GB...

WarpEnterprises
18th July 2005, 22:51
1) how did the error / problems look like? (error messages or the like)
2) What AVI Type (1 or 2) did you use?
3) Was there any sound inside?

whwhwhwh9
6th August 2005, 03:41
#LoadPlugin("decomb521.dll")
LoadPlugin("TDeint.dll")
LoadPlugin("DVinfo.dll")
#LoadPlugin("MPEG2Dec3dg.dll")

filename = "g:\uvs050806-003.AVI"

v = DirectShowSource(filename)

### for mpeg2: DirectShowSource("test.mpg")
### for DV AVI: DirectShowSource("test.avi")

AssumeFieldBased(v)
AssumeBFF(v)

v2 = TDeint(v)
v3 = BilinearResize(v2, 352, 288)

DVinfo(v3, filename) # <---- Line 19

WarpEnterprises
8th August 2005, 11:19
two more questions:
- does the error occur when you open the AVS or after you do some seeking beyond a frame?
- does it crash without AssumeFieldBased(v) ...BilinearResize(v2, 352, 288) ?

whwhwhwh9
10th August 2005, 03:38
To your question #1: I didn't even have chance to seek. I just opened the AVS file in VirtualDub, then it took 100% CPU cycles, then about 2~3 minutes later, error message pops up.

To your question #2:

LoadPlugin("decomb521.dll")
LoadPlugin("dvinfo.dll")
LoadPlugin("TDeint.dll")
filename = "\tt.AVI"
v = DirectShowSource(filename)

#AssumeFieldBased(v)
#AssumeBFF(v)

#v2 = TDeint(v)
#v2 = FieldDeinterlace(v)
#v3 = BilinearResize(v2, 352, 288)

dvinfo(v, filename) # <==== line 14

WarpEnterprises
12th August 2005, 08:07
get the new version (2005-08-11)
http://www.avisynth.org/warpenterprises/index.html#dvinfo

Thanks for reporting, it was indeed a bug for files > 4GB.

whwhwhwh9
14th August 2005, 08:15
got the new version, and it works great.

Boulder
9th December 2005, 17:31
WarpEnterprises: Could you (or possibly someone else) make it possible to display the timecode whenever the day of month changes?

WarpEnterprises
10th December 2005, 22:07
Isn't that the same if you use a large "threshold" value (e.g. 10000 seconds) or do you really want to display the timecode exactly at midnight with your video actually spanning over midnight?

Boulder
11th December 2005, 06:32
I sometimes have stuff that is shot before midnight and then continued during the early hours of day. It would be much easier to have a single option for displaying when the day of month changes than calculating the threshold for each instance :)

WarpEnterprises
23rd December 2005, 21:39
After some thought it turned out to be trivial AND general, check it:

http://www.avisynth.org/warpenterprises/#dvinfo

Wilbert
23rd December 2005, 22:11
Is it still GPL (since source is not included)?

medp7060
24th December 2005, 12:37
Is it possible to make this filter work with Motion JPEG avi?

Boulder
26th December 2005, 12:49
After some thought it turned out to be trivial AND general, check it:

http://www.avisynth.org/warpenterprises/#dvinfo
Thanks, I owe you one :)

I'll try it as soon as I get home from the holidays.

WarpEnterprises
27th December 2005, 22:41
@Wilbert: of course, just forgot the code.
@medp7060: no, it's really DV-specific.

Boulder
3rd February 2006, 18:11
I'm sorry but I can't get it to work as I want to..

I tried this script:

video1="i:\dvnauha.avi"
AVISource(video1).DVInfo(video1,"rec_time",fix_format="%d",threshold=1,autoframes=50,font="Arial",x=500,y=500,text_color=$FFFFFF,size=24)

I'd like it to output the date and time when the day of month changes but it doesn't do that. Am I misunderstanding the syntax?

WarpEnterprises
3rd February 2006, 21:25
does it display
- always
- never
- at wrong deltas

You should use a very big threshold (10000) as it starts to display when the jump is bigger than threshold OR the fix_format changes).
Does it display anything if you DON'T use fix_format and set threshold=0 ?

Boulder
3rd February 2006, 22:01
You should use a very big threshold (10000) as it starts to display when the jump is bigger than threshold OR the fix_format changes)
Thank you, that one fixed it. I thought that threshold was in this case used for determining the fix_format change threshold. It works perfectly :)

tacman1123
31st January 2009, 20:37
I'm trying to write a file that shows the frame number, rec_time and tc_time whenever there's a break in the timecode. DVInfo will display that information when the threshold is passed, but I can't figure out how to get it into a variable that I can use.

What I'm looking for is something like

rec_time = GetDVInfo(file, "rec_time")
tc_time=GetDVInfo(file, "tc_time")
WriteFile(..."frame_count, rec_time, tc_time)

The other problem I'm having is that even displaying the tc_time and rec_time it's showing up on my files as "No time code" and "no recording date", yet when I put that same file through other programs, I see both. I'd be happy to send my AVI file if that would help debugging.

Thanks!

Tac

WarpEnterprises
31st January 2009, 21:31
Which filter-plugin exactly are you talking about?
Mine is dvinfo.dll and the function is "dvinfo".
Please post the hole script.

tacman1123
31st January 2009, 21:54
This displays "No Record Time":

LoadPlugin("c:\as\plugins\dvinfo\dvinfo.dll")
filename="c:/avi/p474_090115_064745_000.avi"

DirectShowSource(filename)
DVInfo(filename, "tc_time + chr(32) + rec_time + chr(32) + current_frame")


What I want is a way to get the rec_time and tc_time as variables, then I can do whatever, including creating a file, that has the frame number, timecode and record_time:


WriteFile(output_filename, "tc_time + chr(32) + rec_time + chr(32) + current_frame")


Even better would be a way to trigger it based on some threshold, the same logic that dvinfo uses for the threshold, so that what I'd end up with is a file with the timecode breaks.

This would be similar to the scene detection that's used for finding scene changes:

# creates a csv file of the current frame and YDifference() when YDifferenceFromPrevious is greater than some threshold
threshold=18
a=video
a=a.WriteFileStart(filename, """video_fn + " " + string(threshold)""", append=false)

a=WriteFileIf(a, filename, "YDifferenceFromPrevious() > threshold", "current_frame", """ ":" """, "YDifferenceFromPrevious()")

Gavino
1st February 2009, 12:58
What I want is a way to get the rec_time and tc_time as variables, then I can do whatever, including creating a file, that has the frame number, timecode and record_time
Since DVInfo sets tc_time and rec_time as (string) script-level variables, I think this ought to work (haven't tried it though):
LoadPlugin("c:\as\plugins\dvinfo\dvinfo.dll")
filename="c:/avi/p474_090115_064745_000.avi"
output_filename = " ... "
DirectShowSource(filename)
WriteFile(output_filename, "tc_time", "rec_time", "current_frame")
DVInfo(filename, """ "" """)

WriteFile has to come before DVInfo in the script because of the order in which frames are fetched from the filter chain (as with ScriptClip, etc).

tacman1123
1st February 2009, 14:55
Great, thanks, getting closer now, here's my script:

LoadPlugin("c:\as\plugins\dvinfo\dvinfo.dll")

filename="p468_090108_074859_437.avi"

tc_filename="timecodes.txt"

DirectShowSource(filename)
WriteFileStart(tc_filename, """ "Frame:Timecode file for " """, """filename""", append=false)

WriteFile(tc_filename, """current_frame""", """ ":" """, """tc_time""")
DVInfo(filename, "tc_time + chr(32) + rec_time + chr(32) + current_frame")

The problem is that I'm not getting the rec_time or tc_time, either in the file or displayed on the screen. I'm certain both are in there, becasue I see them in 2 other other programs I'm using. This is timecodes.txt

Frame:Timecode file for p468_090108_074859_437.avi
0:no timecode
1:no timecode
2:no timecode
3:no timecode
4:no timecode
5:no timecode
6:no timecode
7:no timecode
8:no timecode
9:no timecode
10:no timecode
11:no timecode
12:no timecode


I think I'm using the most recent DLL:

12/23/2005 07:49 PM 122,880 dvinfo.dll

I've saved the smallest file I could create (about 1.5 Meg, but very short) to

http://entrevistasargentinas.com/p468_090108_074859_437.avi

The dv_date that another library I'm using shows:

tc: 00:00:00 12 dv date: 08/01/09 08:48:21

Is it the file? The codec? Something else? As always, thanks for the help!

Thx,

Tac

alexzeit
8th February 2009, 08:52
Dear All,
Like in the thread above from 3rd February 2006 I'd like to output date and time when the day of month changes. I use:

DVInfo(file, "rec_time", size=40, x=40, y=500, rec_format="%d.%m.%Y", autoframes=100, show_error = false, fix_format = "%Y%m%d", threshold=100000)

It works fine except one thing:
In some places I have transitions, and in this places DV does not contain Date/Time information. After such places DVInfo display Date although day of the month was not changed. Is there way to ignore places in DV where date/time information is missing?

WarpEnterprises
9th February 2009, 22:32
@tacman1123: the plugin cannot read the info, I don't know why. Is it made with a HDV-camera?

@alexzeit: try this version:
www.avisynth.org/warpenterprises/files/dvinfo_ignoremissing.zip
The original version sets the time string to "" when there is no timecode, this version simply does nothing.

alexzeit
14th April 2009, 05:26
@WarpEnterprises: Thank you very much the new version works fine.

tacman1123
14th April 2009, 12:52
"the plugin cannot read the info, I don't know why. Is it made with a HDV-camera?"

No, basic SD video camera, Canon ZR500 I think. I know the timecode is there (other programs see it), but I guess its some codec for internal formatting issue.

Do Quicktime MOV files also have DV Timecode info in each frame? Other formats? I'd love to solve this problem, I'm trying to write a script to sync up some data, and having access to the clock time (according to the camera) would be great.

What software do you use for importing a tape via firewire? Maybe the software I'm using isn't writing the right format.

Thx,

Tac

JohnnyMalaria
14th April 2009, 16:27
I've had a look at the example .avi and it does not contain any time/date etc. I've used our own two products and dv_date. Ours both scour the DV stream for all VAUX recording time/date packets, AAUX recording time/date packets and timecode packets.

Is the sample exactly as captured or has in been created from a larger file? With most software, extracting a small clip destroys any time/date info. Also, if capturing live (instead of from tape), you won't have any timecode and, unless the clock has been set, the time and date will be missing, too.

fvisagie
11th August 2009, 14:21
Hi All,

I'm a scripting newbie, with a big project ;-). What I need to do is cut and splice a big DV AVI file, in the process creating a text file with the retained frames' DATECODEs to generate DVD subtitles with.

This thread seems to indicate that DVInfo might have the answer. I have a few questions, though:

1) I don't want permanent DATECODE inlays, but selectable DVD subtitles istead. DVInfo.htm suggests that timecode and recording date are printed on the clip, though. How do I avoid that in the clip output by AVS to the encoder?

2) DVInfo.htm's Trim example solution unfortunately contains the code from the splice example. I'll appreciate some guidance on the correct approach for using DVInfo with Trim, please.

3) For the permanent subtitle inlays which I do want, where in the script do I position the TextSub filter in relation to Trim and DVInfo?

Many thanks in advance,
Francois

Gavino
11th August 2009, 14:48
1) I don't want permanent DATECODE inlays, but selectable DVD subtitles istead. DVInfo.htm suggests that timecode and recording date are printed on the clip, though. How do I avoid that in the clip output by AVS to the encoder?
Using DVInfo(filename, """ "" """) will suppress writing on the clip, while still setting the run-time variables current_frame, tc_time and rec_time. These values (or any values derived from them) can be written to a text file with WriteFile (http://avisynth.org/mediawiki/WriteFile). (See WriteFile example at post#30 above.)
2) DVInfo.htm's Trim example solution unfortunately contains the code from the splice example. I'll appreciate some guidance on the correct approach for using DVInfo with Trim, please.
As long as you put DVInfo after the source filter and before the trim, it will work. Yes, the doc is wrong, the example should read:
LoadPlugin("c:\myprojects\dvinfo\release\dvinfo.dll")
file1 = "c:\myprojects\type2a.avi"
Avisource(file1)
DVInfo(file1, "rec_time")
Trim(1000,2000)
3) For the permanent subtitle inlays which I do want, where in the script do I position the TextSub filter in relation to Trim and DVInfo?
Can you explain this more, please? I thought you said were creating a text file to use in a separate script.

fvisagie
11th August 2009, 17:42
Can you explain this more, please? I thought you said were creating a text file to use in a separate script.

Hello Gavino,

Thanks for your help so far. What I wrote is indeed a little confusing, because two sets of subtitles are involved.

The first set is for selectable DVD DATECODE subtitles which I hope to create with DVInfo (as mentioned in my initial post).

The second set exists already and contains background information text which in this case I actually want to inlay into the video during serving.

I've tested TextSub with this in my usual little script and it inlays text exactly the way I want it. I'm just not sure how to construct a script that serves trimmed footage and renders the DATECODES of that to text and also correctly inlays these TextSub inlays into the trimmed video stream.

I hope this explains it better?

Gavino
11th August 2009, 18:20
I hope this explains it better?
Yes, indeed, sorry for not understanding first time.

Assuming the timecodes in your subtitle file are relative to the original clip, then TextSub should come before Trim.

It doesn't matter whether TextSub comes before DVInfo or after, since they will work independently (and because TextSub doesn't alter the frame numbers, like eg Trim does).

fvisagie
12th August 2009, 08:21
Assuming the timecodes in your subtitle file are relative to the original clip, then TextSub should come before Trim.

Wow, that's just clever!

I'm starting to get the hang of this, thanks very much for your help.

fvisagie
15th August 2009, 16:17
The DVInfo doc says:

With "threshold">0 the output is switched on if there is a difference of the recording date between current and last frame which is bigger than "threshold" seconds. After "autoframes" frames the output is switched off. That way you get the recording date only at scenechanges.

Similarly to tacman123 I'm trying to write a CSV file that logs current_frame and rec_time, once for each change in rec_time.

I'm using this statement:
DVInfo(input_file, "current_frame + chr(44) + chr(32) + rec_time", threshold=0.5, autoframes=1)

However, there's output on every frame, even when rec_time doesn't change. The output string in such cases effectively consists of an empty rec_time, e.g.:
32,

Gavino
15th August 2009, 17:49
In my view that's a bug, or at best you could say the documentation is highly misleading.

Instead of the output being 'switched off', it simply sets rec_time to an empty string. (I've checked the source code.)
That's fine in the default case (where the output consists solely of rec_time), but not in the general case.

Here's a potential workaround:

DVInfo(input_file, """rec_time != "" ? current_frame+chr(44)+chr(32)+rec_time : "" """, threshold=0.5, autoframes=1))

fvisagie
17th August 2009, 09:17
Ah, that's what I've been trying to get working (without ScriptClip), thanks :).

fvisagie
21st August 2009, 12:07
Hi All,

I've started setting up the following framework to track timecode changes across frames (note the assigment of tc_time to old_tc):

input_file = "Test with sub_type2.avi"

#
# Script execution section
#

# "Constant" declarations
output_suffix = ".timecodes.txt"
output_file = string(input_file + output_suffix)
field_separator = ", "


OpenDMLSource (input_file)

WriteFileStart (output_file, """ "current_frame" + field_separator + "tc_time" + field_separator + "old_tc" + field_separator + "next_tc" """)

# Top-level script scope variable declarations
debug = false
next_tc = "59:59:59.99"
old_tc = "59:59:59.99"

#
# Runtime execution section
#

WriteFile (output_file, "string(current_frame) + field_separator + string(tc_time) + field_separator + string(old_tc) + field_separator + string(next_tc)")
ScriptClip("""
next_tc = old_tc
# old_tc = LeftStr(tc_time, 6) + RightStr(tc_time, 5)
old_tc = tc_time
debug ? Subtitle(string(current_frame) + field_separator + string(tc_time) + field_separator + string(old_tc) + field_separator + string(next_tc)) : last
""")
DVInfo (input_file, """ "" """)

The text file output is:


current_frame, tc_time, old_tc, next_tc
0, 00:55:48-08, 00:55:48-08, 59:59:59.99
1, 00:55:48-09, 00:55:48-09, ŹD~°ŽB~˙˙˙˙«ŽB~ѬB~(Ź
2, 00:55:48-10, 00:55:48-10, 00:55:48-10
3, 00:55:48-11, 00:55:48-11, 00:55:48-11
4, 00:55:48-12, 00:55:48-12, 00:55:48-12
5, 00:55:48-13, 00:55:48-13, 00:55:48-13
6, 00:55:48-14, 00:55:48-14, 00:55:48-14
7, 00:55:48-15, 00:55:48-15, 00:55:48-15


old_tc (which is assigned to next_tc before the latter is printed) is ALWAYS corrupted on the second frame, and incorrectly overwritten to the value of the current timecode on subsequent ones. I thought an intermediate variable would help protect old_tc:


next_tc = old_tc
temp_tc = tc_time
old_tc = temp_tc

but it seems AVS assigns strings by reference and this doesn't help.

From the source it seems DVInfo assigns its runtime variables by reference. If I forcibly create a copy of tc_time in old_tc as follows:


old_tc = LeftStr(tc_time, 6) + RightStr(tc_time, 5)
# old_tc = tc_time


old_tc isn't corrupted, and in that case the text file output is:


current_frame, tc_time, old_tc, next_tc
0, 00:55:48-08, 00:55:48-08, 59:59:59.99
1, 00:55:48-09, 00:55:48-09, 00:55:48-08
2, 00:55:48-10, 00:55:48-10, 00:55:48-09
3, 00:55:48-11, 00:55:48-11, 00:55:48-10
4, 00:55:48-12, 00:55:48-12, 00:55:48-11
5, 00:55:48-13, 00:55:48-13, 00:55:48-12
6, 00:55:48-14, 00:55:48-14, 00:55:48-13
7, 00:55:48-15, 00:55:48-15, 00:55:48-14


as would be expected.

Is it correct to deduce that in the first code block DVInfo retains a pointer to old_tc and corrupts it between the first two frames and incorrectly overwrites it subsequently?
If so, is there someone willing and able to do a quick fix of DVInfo for me? In the meantime is there a computationally cheaper way of creating my own local copy of tc_time?

Many thanks,
Francois

Gavino
21st August 2009, 17:55
Is it correct to deduce that in the first code block DVInfo retains a pointer to old_tc and corrupts it between the first two frames and incorrectly overwrites it subsequently?
Not exactly, but something similar.
What is happening is that DVInfo (in its GetFrame function) uses local stack space for the strings, which is thus only in scope during the fetching of a single frame. When you save tc_time in old_tc, and then try to use it during the next frame, you end up with a reference that is no longer valid and has been potentially overwritten by something else.

Now, that something else will usually be the new tc_time, since the new GetFrame will end up with the same stack address if called in a loop by Avisynth's client application. That you only get 'garbage' on frame 1 is probably due to the very first GetFrame (for frame 0) being called differently by the application.

Is this a bug or is it a feature?
I would argue that DVInfo should not use local storage for its run-time variables. In nearly all cases, local storage will suffice but a problem arises in your case where you have a run-time script with side-effects (something which must be done carefully, but I believe is perfectly 'legal').
If so, is there someone willing and able to do a quick fix of DVInfo for me? In the meantime is there a computationally cheaper way of creating my own local copy of tc_time?
If necessary, I could have a go, but it would be better if the original author could address this (and the other bug you reported in post #42) - are you still out there, WarpEnterprises?

In the meantime your workaround is a valid one.
More efficient would be just old_tc = LeftStr(tc_time, 11).

fvisagie
22nd August 2009, 13:15
More efficient would be just old_tc = LeftStr(tc_time, 11).

Ah, excellent, thanks very much!

The script is basically complete (bar that improvement and some final testing), and I'm looking forward to posting the results soon!

Gavino
22nd August 2009, 14:11
If you're concerned about speed, and you are only interested in the file output, so don't need to see the video result, you could replace DVInfo(input_file, """ "" """) by

DVInfo (Crop(0,0,2,2), input_file, """ "" """)

DVinfo is quite slow, since it creates a new instance of Subtitle for every frame (even with an empty string!). Because of the way Subtitle works, it is substantially faster if given a smaller frame.
The speed-up will be much more significant than tweaking the expressions in your script (even in the run-time part).

fvisagie
22nd August 2009, 15:14
If you're concerned about speed, and you are only interested in the file output, so don't need to see the video result, you could replace DVInfo(input_file, """ "" """) by

DVInfo (Crop(0,0,2,2), input_file, """ "" """)


That makes sense, thanks - I couldn't get the previous similar suggestion to work without Subtitle(). This shows why..

Gavino
22nd August 2009, 15:39
I couldn't get the previous similar suggestion to work without Subtitle().
My previous suggestion of
StackVertical(Crop(0, 0, 0, 20).DVInfo(file, ...), Crop(0, 20, 0, 0))
should also work and speed things up when you want to get the video output too. Unless you are using additional options to position or size the text differently, in which case you would need to adjust the '20' accordingly.

fvisagie
22nd August 2009, 21:01
Hi All,

After much blood, sweat and tears, the timecode-based scene file generator script has been completed and so far it seems to work well.

What it's about:


# tc2Scenes loads the specified DV AVI (Type 1 or 2) file and generates a scene file from timecode discontinuities.
# tc2Scenes works for unedited DV files, or edited files where the editor used direct mode or similar to preserve original timecodes in unmodified frames.
# For tc2Scenes to work correctly, its output must be rendered linearly by playing, encoding, whatever is more convenient.
# The scene file is generated in ASS v4.00+ subtitle script format, with one subtitle per scene.
# Subtitles start with the corresponding scene, and the DATECODE and timecode of the scene's first frame are written to their text.
# tc2Scenes has been tested on 25fps PAL material, but hopefully it was written generally enough to work for other integer frame rates.
# Currently tc2Scenes does not validate timecode values.

# Possible usage restrictions:
# AvsP: To improve performance this script produces highly cropped video. Trying to Fill or Fit its preview to the AvsP window will likely result in an error.
# Instead, either do not Fill or Fit the preview, or reduce the Crop at the bottom of the script.


The current version is 1.2 and contains the following changes:

# 2009/08/28 1.2 Added output path command line option for batch file
# AVS script now receives full output filename from calling script instead of just suffix
# ASS style corrected from Default to SceneChange
# Shortened default subtitle duration to last frame below 0.5 s
# Some other minor changes


How to run it:
* As a stand-alone AVS script by editing it for the appropriate input and output file specifications; or
* via Import() from another script which sets the input and output file specifications for it; or
* From the attached batch file

The latter is quite convenient for launching the scene file generator via a Windows shell extension handler:

1. Copy the attached script and tc2Scenes batch file to somewhere on your system and make sure the LOCATION environment variable in the batch file correctly points to the _script's_ location
2. In Windows Explorer, open Tools.Folder Options.File Types, in the Registered file types list select AVI and click Advanced
3. Click New, in the Action text box fill in "Generate scene file", in the "Application used..." box fill in the full path and name of tc2Scenes.bat and click OK on all dialog boxes
4. In Windows Explorer, right-click your AVI file and select "Generate scene file" :)


What it produces where:
The batch file creates a stub AVS script called tc2Scenes_stub.avs which sets input and output file specifications and loads tc2Scenes.avs with Import(). The batch file then invokes ffmpeg with the stub AVS script as input. tc2Scenes.avs outputs scene changes to an ASS subtitle script format text file. The batch file also logs start and end times to a processing time logfile.

When no output path is provided, the stub script is created in the current directory, and the output file and processing time logfile are created in the same folder and with the same base filename as the input file. When a valid output path is provided, all files are created in the specified folder with the base filename tc2Scenes.

Writing to a separate output path is sometimes convenient, and also provides a modest performance gain when the destination is on a different disk.

If you prefer to use an alternative to ffmpeg for rendering the script, either modify the batch file, or terminate ffmpeg when/if it starts running and render the stub script with your preferred player or editor instead.

You're free to use this as you see fit (or as you do not! ;)). If you do use it and come up with suggestions for improvement, kindly implement and share them with me? ;). The main ones I can think of at this point are:
* Validating timecode values read (shouldn't be too hard, I just didn't have time now)
* Considering adding DATECODE-based scene detection. Depending on what's needed, adding detection of DATECODE discontinuities may be essential. As it stands, tc2Scenes detects timecode discontinuities. These are usually introduced by the editor. However, on-camera scene cuts created by stopping and resuming recording have continuous timecodes. Any such cuts retained as is in the final project can only be identified by DATECODE discontinuity.

Kind regards,
Francois

fvisagie
29th August 2009, 16:39
Hi WarpEnterprises,

Congratulations on and thanks for a great utility (DVInfo)! Unfortunately I'm having a problem with it on the file that matters, the output of my project.

Results so far:

* Works: Type 1 files I've tried
* Works: large (36GB) Type 2 files created by DVDate
* Works: small (0.5GB) Type 2 files created by VirtualDub
* Doesn't work: large (36GB) Type 2 file created by VirtualDub, for which DVInfo reports "error reading DV frame" on each frame.


Both small and large Type 2 VirtualDub files were created with version 1.9.6 in Direct stream copy mode (and the Cedocida v0.2.0 DV codec FWIW).

The only significant-looking difference I've discovered so far between the large Type 2 files created by DVDate and VirtualDub as reported by GSpot are:

~36GB Type 2 file created by DVDate:

Note: 31.3 GB unneeded bytes at end of file
DV Type 2 AVI
Multipart OpenDML AVI (5 parts)
(255491 frames in first part, 0 frames follow)


~36GB Type file created by VirtualDub:

Note: 30.0 GB unneeded bytes at end of file
DV Type 2 AVI
Multipart OpenDML AVI (3 parts)
(14044 frames in first part, 240558 frames follow)


There seem to be significant differences between the number of parts and between the number of frames in the first part, for roughly the same file size.

It seems a possible worst case work-around might be to convert the VirtualDub output to Type 1 and back with DVDate. Also I could play with different VirtualDub settings on larger and larger files to see if any work for DVInfo, although either of these this will take hours and I have very little time right now.

If you have any suggestion off the top of your head for configuring VirtualDub to create large Type 2 files in a format that DVInfo will understand, please, I would love to hear about it!

Many thanks,
Francois

fvisagie
29th August 2009, 20:12
It turns out this problem appears as soon as the VirtualDub Type 2 output file size exceeds 2GB, which is its default threshold for OpenDML indexing.

It also turns out that it is possible to process a VirtualDub file >2GB in DVInfo, if it is first converted to Type 1 by DVDate. If DVDate is used to convert that back to another Type 2 file again, that is also readable by DVInfo as expected - no DVDate files have caused problems yet.

So that creates a potentially useful comparison - the original >2GB Type 2 file created by VirtualDub which DVInfo can't read, and the DVDate Type 2 version which it can. I attach the RIFF headers of both as reported by DVDate.

I have played with the AVI output-related settings in VirtualDub, but so far haven't succeeded in producing a file that DVInfo can read directly. I also attach the available VirtualDub settings. If there are any changes you think may help things work, please let me know!

WarpEnterprises
2nd June 2010, 21:48
Maybe a little late - but here is a small update:
- really switching off the output
- fixed silly bug when working with some big type-2 AVIs
- moved the storage of the strings to class scope

http://avisynth.org/warpenterprises/files/dvinfo_20100602.zip

fvisagie
3rd June 2010, 08:34
Maybe a little late

Not at all, and still very useful. I hope to update the scene file generator some time and this will come in very nicely, thanks!

Boulder
13th July 2010, 20:48
With the new version, VirtualDub crashes every time the script containing DVInfo is closed, pointing to ntdll.dll. I cannot test the previous version as I don't have it on my HD anymore :(

It can be reproduced with a simple script like this (source is already bobbed):
AVISource("w:\dv\bobbed\nauha1.avi")
video="w:\dv\combined\nauha1.avi"
SeparateFields()
SelectEvery(4,0,3)
Weave()
DVInfo(video,"rec_time",rec_format="%d-%m-%y %H:%M:%S",fix_format="%d",threshold=999999,autoframes=250,font="Arial",x=500,y=500,text_color=$FFFFFF,size=24)

an_private
29th September 2015, 08:19
Error in source was found - space for indexes was limited to 4029 (line 125 in avi.h). Normally, size of one chunk for indexes is up to 65536 byte. One index record used 8 bytes -> up to 8192 indexes can be in one chunk.
Corrected, after correction all files is working correctly.
https://drive.google.com/open?id=0B4WG5OG778SzRGlwYXZTQWV1c1k