Playing video read in as binary without writing to disk - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: Playing video read in as binary without writing to disk (/thread-9626.html) |
Playing video read in as binary without writing to disk - ashtona - Apr-19-2018 Hello my python program right now reads in binary data from an sql varbinary column, if it's a jpg file I convert it to BYTESIO and use PIL Image.Open to display the image. If it's a pdf or mp4 I write the binary data to disk and launch it using Popen. I am trying to find a way where I can launch the pdfs and mp4s without writing them locally to disk. Is there a way? here is the code for the part of my program I am referring, def QueryFiles(self): """ Queries the blob data from table based on filename. @param, self the App object. @return None. """ from io import BytesIO from PIL import Image for element in self.SectionList.curselection(): value = self.Query("SELECT Data FROM ShubertDocs WHERE Filename = '" + self.SectionList.get(element)[5:] + "';") if ".JPG" in self.SectionList.get(element)[5:] or ".jpg" in self.SectionList.get(element)[5:]: bio = BytesIO(value[0][0]) Image.open(bio).show() elif ".PDF" in self.SectionList.get(element)[5:] or ".pdf" in self.SectionList.get(element)[5:] or ".mp4" in self.SectionList.get(element)[5:]: #track files saved to disk try: with open('temp\\' + self.SectionList.get(element)[5:], 'wb') as f: f.write(value[0][0]) except: pass self.processes.append(Popen("start /WAIT " + 'temp\\' + self.SectionList.get(element)[5:], shell=True)) |