Python Forum
Playing video read in as binary without writing to disk
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playing video read in as binary without writing to disk
#1
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))
        
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020