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. |
|
|
Thread Tools | Search this Thread | Display Modes |
8th September 2015, 17:08 | #1 | Link | |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
WriteFile[If](append=false) overwrites only on first call
Spooling through
Code:
file = "current_frame.txt" BlankClip(length=10) WriteFileStart(file, """"Start of file"""", append=false) WriteFileIf(file, "true", "current_frame", append=false, flush=true) Quote:
Is there any way of getting WriteFile[If]() to overwrite the output file at each call? |
|
8th September 2015, 22:29 | #2 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
WriteFile[If](..., append=false) overwrites any existing file, but data is written for each rendered frame. Normally, that is what one wants.
If for some reason you only want to see the data for the last rendered frame, you can use: ScriptClip("""WriteFile[If](..., append=false)""") With this, a separate instance of WriteFile[If] is created for every frame, each one overwriting the data written by previous one. |
9th September 2015, 07:47 | #4 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Yes, that would work.
When writing the script, you would have to take into account that the last frame rendered is not necessarily the final frame of the source clip (eg if there are following trims). In a complex script, it may not be obvious what frame number to check for. |
9th September 2015, 09:06 | #5 | Link | |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
Quote:
I'm afraid I don't follow you here as well as Gavino did. Please elaborate on the sequence of per-frame events you foresee here? In case it makes any difference, I was looking for a way to over-write the output file at each rendered frame, which Gavino addressed above. |
|
10th September 2015, 08:24 | #6 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
What he meant was instead of repeatedly overwriting the file, you could add an extra condition so that the file was written only for the last frame.
WritefileIf(..., "... && current_frame == frameCount-1", append=false) That works fine for simple cases, but as I pointed out, the last frame rendered is not always the final source frame and it may not be obvious what frame number to use instead of 'frameCount-1'. |
10th September 2015, 14:45 | #8 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
If I am reading the source correctly, WriteFileIf seems to append always, regardless of the script argument...
Code:
(conditional_reader.cpp) PVideoFrame __stdcall Write::GetFrame(int n, IScriptEnvironment* env) { ... if (Write::DoEval(env)) { Write::FileOut(env, AplusT); } ... |
10th September 2015, 17:56 | #9 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
However the initial opening of the file is done in the constructor and the mode depends on the 'append' argument: Code:
fout = fopen(filename, append ? AplusT : WplusT); //append or purge file |
|
11th September 2015, 05:44 | #10 | Link | |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|