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. |
17th October 2019, 01:18 | #562 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
I use couple of methods , maybe there is something within vsedit to allow it, someone might add something, or you can do couple of workarounds:
First workaround, you name your script as *.py and instead of clip.set_output() (although you can leave it there in your script), you add: Code:
for frame in range(0, len(clip)): clip.get_frame(frame) So you do not use vsedit at all SECOND, you can use *.py and code your previewer, it is not that difficult as you'd think, you just need to pick up a modul - openCV, PIL (using with tkinter) or PyQt (Qt in python). I use openCV or PyQt. vsedit uses Qt. THIRD, you re-direct sys.stdout. I use openCV and this script: outputwindow.py. All you do is just import it in your vapoursynth scrip: import outputwindow and your print (sys.stdout) is automatically redirected to extra tkinter GUI window. I found it a while ago on web and adjusted some lines so it even works with vsedit. So this is most comfortable method I guess. Code:
#Python 3 """ named errorwindow originally Import this module into graphical Python apps to provide a sys.stderr. No functions to call, just import it. It uses only facilities in the Python standard distribution. If nothing is ever written to stderr, then the module just sits there and stays out of your face. Upon write to stderr, it launches a new process, piping it error stream. The new process throws up a window showing the error messages. Code derived from Bryan Olson's source posted in this related Usenet discussion: https://groups.google.com/d/msg/comp.lang.python/HWPhLhXKUos/TpFeWxEE9nsJ https://groups.google.com/d/msg/comp.lang.python/HWPhLhXKUos/eEHYAl4dH9YJ martineau - Modified to use subprocess.Popen instead of the os.popen which has been deprecated since Py 2.6. Changed so it redirects both stdout and stderr. Also inserted double quotes around paths in case they have embedded space characters in them, as they did on my Windows system. to use it with Preview() for openCV player: -changed subprocess.Popen command to list instead of string , so it works under linux -added exception to catch window canceled by user and deleting pipe, so new GUI is automatically constructed again if needed, -added st.ScrolledText instead of Text -made sure that subprocess.Popen executable is python executable (or pythonw under windows), under windows, running it from Mystery Keeper's vsedit, sys.executable returned 'vsedit', """ import subprocess import sys import _thread as thread import os ERROR_FILENAME_LOG = 'error_printing_to_gui.txt' if __name__ == '__main__': # When spawned as separate process. # create window in which to display output # then copy stdin to the window until EOF # will happen when output is sent to each OutputPipe created import tkinter as tk import tkinter.scrolledtext as st from tkinter import BOTH, END, Frame, TOP, YES import tkinter.font as tkFont import queue as Queue Q_EMPTY = Queue.Empty # An exception class. queue = Queue.Queue(1000) # FIFO, first put first get def read_stdin(app, bufsize=4096): while True: queue.put(os.read(sys.stdin.fileno(), bufsize)) class Application(Frame): def __init__(self, master, font_size=10, family='Courier', text_color='#0000AA', rows=25, cols=128): super().__init__(master) self.master = master if len(sys.argv) < 2: title = "Output stream from unknown source" elif len(sys.argv) < 3: title = "Output stream from {}".format(sys.argv[1]) else: # Assume it's a least 3. title = "Output stream '{}' from {}".format(sys.argv[2], sys.argv[1]) self.master.title(title) self.pack(fill=BOTH, expand=YES) font = tkFont.Font(family=family, size=font_size) width = font.measure(' ' * (cols+1)) height = font.metrics('linespace') * (rows+1) self.configure(width=width, height=height) self.pack_propagate(0) # Force frame to be configured size. self.logwidget = st.ScrolledText(self, font=font) self.logwidget.pack(side=TOP, fill=BOTH, expand=YES) self.logwidget.configure(foreground=text_color) self.after(200, self.start_thread, ()) # Start polling thread. def start_thread(self, _): thread.start_new_thread(read_stdin, (self,)) self.after(200, self.check_q, ()) def check_q(self, _): go = True while go: try: data = queue.get_nowait().decode() if not data: data = '[EOF]' go = False self.logwidget.insert(END, data) self.logwidget.see(END) except Q_EMPTY: self.after(200, self.check_q, ()) go = False root = tk.Tk(baseName='whatever_name') app = Application(master=root) app.mainloop() else: # when module is first imported import traceback class OutputPipe(object): def __init__(self, name=''): self.lock = thread.allocate_lock() self.name = name def flush(self): # NO-OP. pass def __getattr__(self, attr): if attr == 'pipe': # Attribute doesn't exist, so create it. # Launch this module as a separate process to display any output it receives executable = sys.executable try: basename = os.path.basename(executable) name, _ = os.path.splitext(basename) if not name.lower().startswith('python'): executable = self.get_executable() except: executable = self.get_executable() argv1 = __file__ try: argv2 = os.path.basename(sys.argv[0]) except: argv2 = '' argv3 = self.name command = [executable] for arg in [argv1, argv2, argv3]: if arg: command.append(arg) try: # Had to also make stdout and stderr PIPEs too, to work with pythonw.exe self.pipe = subprocess.Popen(command, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdin except Exception: # Output exception info to a file since this module isn't working. exc_type, exc_value, exc_traceback = sys.exc_info() msg = '{} exception in {}\n'.format(exc_type.__name__, os.path.basename(__file__)) with open(ERROR_FILENAME_LOG, 'wt') as info: info.write('fatal error occurred spawning output process') info.write('exeception info:' + msg) traceback.print_exc(file=info) sys.exit('fatal error occurred') return super(OutputPipe, self).__getattribute__(attr) def get_executable(self): #if running this within vsedit under windows sys.executable name is 'vsedit' return 'pythonw' def write(self, data): with self.lock: try: data = data.encode() self.pipe.write(data) # First reference to pipe attr will cause an # OutputPipe process for the stream to be created. except Exception: #gui was canceled by user, piping would cause error #pipe attr can be deleted so new is constructed with __getattr__() and therefore new GUI pops up if needed del self.pipe #pass try: os.remove(EXC_INFO_FILENAME) # Delete previous file, if any. except Exception: pass # Redirect standard output streams in the process that imported this module. sys.stderr = OutputPipe('stderr') sys.stdout = OutputPipe('stdout') |
17th October 2019, 16:02 | #563 | Link | |
Registered User
Join Date: Jul 2019
Posts: 73
|
Quote:
|
|
17th October 2019, 18:50 | #564 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
that outputwindow.py takes care of it all, there is only import of that script needed and then just using print(), no arguments needed
Code:
from vapoursynth import core import outputwindow clip = core.std.BlankClip() print('width for that blank clip is:', clip.width) |
21st October 2019, 12:40 | #565 | Link | |
Registered User
Join Date: Jul 2019
Posts: 73
|
Quote:
Im on KDE Plasma (Linux), perhaps there's something to do with that? |
|
21st October 2019, 16:11 | #566 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
Possible, I tested it on Win7 and Ubuntu 18.04 though.
If pipe is not created it should write error into "error_printing_to_gui.txt". I'd check it with just some simple *.py file first, like example above, not using vsedit. Then you can go further and try to write all variables into that error txt log as well thru out that outputwindow.py like for example for executable variable: Code:
with open(ERROR_FILENAME_LOG, 'a') as info: info.write('sys.executable:') info.write(executable) #executable should be 'python' or 'pythonw' for windows sys.stderr = OutputPipe('stderr') at the end of outputwindow script, it might start print errors into python consol, IDLE etc. edit: corrected 'wt' into 'a' so it just adds to log Last edited by _Al_; 21st October 2019 at 16:58. |
21st October 2019, 17:39 | #567 | Link | |
Registered User
Join Date: Jul 2019
Posts: 73
|
Quote:
Code:
sys.path.append(os.path.dirname(os.path.realpath(__file__))) import outputwindow Thanks a ton! Wish there was a built in way to do this. P.S. I was doing raise Exception("BlaBla") as a logger but of course it would end the script so it wasnt perfect. Is there perhaps a way we can figure out how raise Exception works and just pony up a similar thing except raise Log("Msg") that doesnt exit()? |
|
21st October 2019, 18:59 | #568 | Link |
Registered User
Join Date: May 2011
Posts: 321
|
I'm so sorry, I forgot about that already, adding that dir to sys.path, I'm not using vsedit now. vsedit needed that. If importing it just from some other *.py running script it was fine having that in site-packages dir.
That outputwindow.py works with any python app so it is usable elsewhere. Printing, sys.stdout.write(str(some value)) or just print(...), into tkinter gui, which is python standard library. And even that app crashes that windows stays on to report error. Last edited by _Al_; 21st October 2019 at 19:15. |
9th November 2019, 08:09 | #569 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
I'm trying to build the project in Qt Creator in Windows 10 and I'm getting the error "vapoursynth/VapourSynth.h file not found" from the #include lines. It worked without a problem the last time I ran it in Windows 7. Had the path changed?
|
9th November 2019, 14:53 | #571 | Link | |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Quote:
In the vsedit.pro file, I tried changing the INCLUDEPATH under the win32{}, but it still reporting file not found. |
|
10th November 2019, 00:10 | #573 | Link | |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Quote:
Here's what I did: - Opened the pro.pro file in Qt - Under "projects" tab, set the "Desktop Qt 5.13.1 MingGW 64-bit" compiler as default - Modified the "includepath" line in vsedit.pro to: Code:
win32 { QT += winextras INCLUDEPATH += 'C:/Program Files/VapourSynth/sdk/include/' - go build->rebuild all The problem still persist. It still complains about the vapoursynth.h file not found. |
|
14th November 2019, 17:45 | #575 | Link |
Registered User
Join Date: Jul 2019
Location: Russia
Posts: 87
|
When I use for preview:
Code:
haf.QTGMC(clip, Preset='Very Slow', Sharpness=0.8, FPSDivisor=1, TFF=True) clip = core.std.Crop(clip, 0, 0, 2, 0) But when I use: Code:
haf.QTGMC(clip, Preset='Very Slow', Sharpness=0.3, FPSDivisor=1, SourceMatch=3, Lossless=2, MatchEnhance=0.75, TFF=True) clip = core.std.Crop(clip, 0, 0, 2, 0) Code:
Error on frame 0 request: Resize error 1027: image dimensions must be divisible by subsampling factor Last edited by Jukus; 14th November 2019 at 18:06. |
23rd November 2019, 00:56 | #580 | Link | ||
Registered User
Join Date: Apr 2017
Posts: 6
|
Quote:
A better solution. https://bitbucket.org/mystery_keeper...apoursynth-r48 Quote:
Last edited by Tohno_Neil; 23rd November 2019 at 01:19. |
||
|
|