View Full Version : writefile not working?
wuziq
12th August 2006, 00:47
writefilestart works for me, but the other writefile functions do not work. By "do not work", I mean that a text file gets created but nothing gets written into the file. I have tried doing "Scan video for errors", playing the whole clip through, even compressing it.
Examples that do not work:
filename = "test.txt"
clip = blankclip()
writefile(clip, filename, "current_frame", append=true, flush=true)
filename = "test.txt"
clip = blankclip()
writefileend(clip, filename, """ "goodbye" """, append=true)
filename = "test.txt"
clip = blankclip()
writefileif(clip, filename, "I CAN PUT ANYTHING HERE AND I GET NO ERRORS OR COMPLAINTS AT ALL", "current_frame")
Do I need to do anything in particular to get them to work?
Example of what works:
filename = "test.txt"
clip = blankclip()
writefilestart(clip, filename, """ "hello" """)
I am using AviSynth v2.5.6, WinXP.. I tried both vdub and vdubmod.. any other info that I need to put here, let me know.
I sense I might be doing something fundamentally wrong.. but, even with the simplest case of writefileend, it doesn't work, while writefilestart does. Anyone experiencing these problems?
wuziq
14th August 2006, 06:28
bump.. any ideas, anyone? :confused:
Mug Funky
14th August 2006, 06:49
dunno, it seems to work for me with this script:
angle1=mpeg2source^("%~dpn1.d2v",idct=7,cpu=0^)
angle2=mpeg2source^("%~dpn2.d2v",idct=7,cpu=0^)
mt_lutxy^(angle1,angle2,expr="x y - abs",y=3^)
WriteFileIf^(last, "%~dp1\differences.txt", "yplanemax(.5) > 16", "current_frame", """ ":" """, "yplanemax(.5)"^)
perhaps there's some weird permissions going on in the folder you're writing to? probably not seeing as a file is being created.
wuziq
14th August 2006, 16:53
yeah it is really weird, and frustrating. originally i was doing it over a network folder, which didn't work.. but i did the same thing on a local drive, and still no go. and you're right, it's not a permissions thing because i have full access to the drives.. and yeah, the text file IS being created, it's just nothing is getting written into it (with the exception of when i use writefilestart). anyway, thanks for trying it out.. if anyone else has any ideas, i'd really appreciate it. thanks :)
wuziq
15th August 2006, 00:18
i think i figured out my problem.
it's not possible to use writefile on a clip that is not the final returned clip, correct? IS there a way for that to work?
foxyshadis
15th August 2006, 01:18
When it's outside the processing chain, as far as avisynth is concerned it doesn't exist (mostly...). Anything that inserts it will work. Something as simple as:
Avisource("...")
clip=Blankclip()
clip=clip.writefile(clip, filename, "current_frame", append=true, flush=true)
#this will still return avisource at this point and ignore clip
MergeChroma(clip).MergeChroma(last)
#now it will process clip
should do the trick.
(I never knew about the flush=true, I thought you always had to close first... I guess sometimes I need to rtfm too. ;))
Guest
12th September 2012, 15:53
Just to give some closure to this old thread... :)
I ran into this exact problem and it wasn't due to the clip not being rendered as described here. It was simply that WriteFile() and its variants do not work in Avisynth 2.57. Everything is fine in 2.58 and beyond. That, at least, is my experience.
Gavino
12th September 2012, 18:12
WriteFile() and its variants do not work in Avisynth 2.57.
I seem to recall there was a problem in 2.57 unless you used an absolute pathname for the file.
Guest
12th September 2012, 19:16
Ah, could very well be, as I didn't have a full path. I'll try again with 2.57 and full path just for grins when I get home and then finally close this thread out. :)
I'm a bit doubtful though as the WriteFileStart() works.
IanB
12th September 2012, 23:16
The problem was to do with the flush option, relative paths and changing CWD. The significant change was at line 332 in the diff of conditional_reader.cpp 1.9 to 1.10 (http://avisynth2.cvs.sourceforge.net/viewvc/avisynth2/avisynth/src/filters/conditional/conditional_reader.cpp?r1=1.9&r2=1.10). The other changes to show the "filename" in play made what was happening obvious.
Guest
13th September 2012, 00:41
I confirm that using a full path for the output file makes 2.57 work properly.
lisztfr9
25th November 2012, 23:04
Same problem here, using avisynth ver 2.58
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePan.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePanEstimate.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FluxSmooth.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\deflicker.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FFT3DFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Descratch.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Decomb.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ac3source.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\cnr2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\badframes.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\autolevels.dll")
# MASK DLLs
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\variableblur.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ChromaShift.dll")
video=AVISource("C:\Documents and Settings\main\My Documents\TC_sample.avi")
last = video
o = last
filename = "c:\myprojects\output.txt"
# WriteFile(o, filename, "current_frame", "AverageLuma")
oo = o
oo = info(oo)
oo
WriteFile(filename, "current_frame")
# this line is written when the script is opened
WriteFileStart(filename, """ "This is the header" """)
# and this when the script is closed
WriteFileEnd(filename, """ "Now the script was closed" """)
oo.ConvertToRGB()
it doesn't write anything but the headers.
The version() example works
Gavino
25th November 2012, 23:31
it doesn't write anything but the headers.
See http://avisynth.org/mediawiki/WriteFile
Note that since output is produced only for rendered frames, there will be no output at all if the result of the filter is not used in deriving the final result of the script.
In your script, the result of the Writefile() call (which is implicitly assigned to 'last') is not used, since the script returns oo.ConvertToRGB().
You need to change the Writefile() line to
oo = oo.WriteFile(filename, "current_frame")
lisztfr9
26th November 2012, 10:01
Ok.... i past only 2 hours on that.
However the headers are printed, which is leading to some confusion...
"oo = oo.WriteFile(filename, "current_frame") "
I didn't want to do that because the output in my mind was a log file, not a clip...
Ok the result is assigned to last... not to oo ! this is specific to avisynth syntax, that the result name can differ from the input name.
Edit :
Hurray ! this is the proof :
oo = o
info(oo)
oo = last
Gavino
26th November 2012, 10:21
However the headers are printed, which is leading to some confusion...
WriteFileStart and WriteFileEnd, which produce the headers/footers, operate differently from WriteFile.
They generate output only on script opening and closure respectively, not for each frame rendered. So they will produce output even if the filter itself does not deliver any frames to the final script result.
Ok the result is assigned to last... not to oo ! this is specific to avisynth syntax, that the result name can differ from the input name.
That's right.
SomeFilter(c)
does not change the value of c. Instead, it is equivalent to
last = SomeFilter(c)
If you want the result to be assigned to c, you need to do it explicitly:
c = SomeFilter(c)
See http://avisynth.org/mediawiki/Grammar.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.