Recherche avancée

Médias (0)

Mot : - Tags -/utilisateurs

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (82)

Sur d’autres sites (14343)

  • Python PyQT : How to call a GUI function from a worker thread ?

    18 juillet 2014, par rainer

    I have a pyqt gui and calling a long process (ffmpeg) which I put on a separate thread to not block the gui. I then want to update a progress bar when one command of a longer list of commands finishes. The problem is, that I can’t call a function in the gui thread out of the worker thread. So I let run a ticker in the worker thread, but when I update the progress bar with a while loop and reading the ticker value, the gui gets blocked again. How can I solve this. I used currently python threading and not Qthread.
    Thx for any help !

    import threading, pexpect

    self.cmd_list = ['ffmpeg -i file outfile','and so on']

    self.stop_proc = False
    self.executeCMD()

    def spawn_ffmpeg_cmd(self):
       for cmd in self.cmd_list:
           if self.stop_proc == False:
               thread = pexpect.spawn(cmd)
               print "\nstarted: %s" % cmd
               cpl = thread.compile_pattern_list([pexpect.EOF,"frame= *\d+ fps=*\d+",'(.+)'])

               while True:
                   i = thread.expect_list(cpl, timeout=None)
                   if i == 0: # EOF
                       print "the sub process exited"
                       self.pgticker += 1
                       break
                   elif i == 1:
                       frame_number_fps = thread.match.group(0)
                       print frame_number_fps
                       thread.close
                   elif i == 2:
                       pass
       self.startButton.setEnabled(True)


    def executeCMD(self):
       self.startButton.setEnabled(False)
       self.pgticker = 0
       threading.Thread(target=self.spawn_ffmpeg_cmd, name="_proc").start()


    def stopprocess(self):
       self.stop_proc = True
       self.cmd_list = []
       os.system('pkill ffmpeg')
       self.pgticker = len(self.cmd_list)
       self.startButton.setEnabled(True)


    def updateProgress(self):  
       pgfactor = 100 / len(self.cmd_list)
       progress = 0.0
       progress = pgfactor*int(self.pgticker)
       self.progressBar.setProperty("value", progress)
  • error converting .caf to .mp3 in mvc 4

    17 avril 2014, par Jennifer

    I used to convert caf to mp3 using Wscript.shell and ffmpeg.exe when i was using asp.net
    but now i'm using a web api restful method in mvc 4, so i don't have a .aspx page
    i'm getting the following error :

      Description:System.Web.HttpException (0x80004005): The component 'Wscript.Shell' cannot be created.  Apartment threaded components can only be created on pages with an <%@ Page aspcompat=true %> page directive.

    but i don't have an aspx page to add this tag...

    the code i was using in aspx is :

      Dim wshShell As Object
      wshShell = Server.CreateObject("Wscript.Shell")
      cmd = "cmd.exe /k """"" & szCAF_PATH & """ -i """ & szPhysicalPath & """ " & Arguments & " """ & szEncodedPath & """"""
      wshShell.Run(cmd)
      Dim strCommand As String = "taskkill /F /IM cmd.exe"
      wshShell.Run(strCommand, 0, True)
      szDownloadLink = szDownloadLink.Replace(".caf", ".mp3")

    and the code in mvc4 is :

      wshShell = HttpContext.Current.Server.CreateObject("Wscript.Shell")
      cmd = "cmd.exe /k """"" & File.CAF_PATH & """ -i """ & File.PhysicalPath & """ " & File.Arguments & " """ & File.EncodedPath & """"""
      wshShell.Run(File.cmd)
      strCommand = "taskkill /F /IM cmd.exe"
      wshShell.Run(strCommand, 0, True)
      File.DownloadLink = File.DownloadLink.Replace(".caf", ".mp3")

    does anyone know how can i fix this ?

  • Is it possible to use MediaTransportControls with FFmpegInterop in UWP ?

    1er janvier 2020, par Agredo

    Is it possible to use the MediaTransportControls ? Currently getting the error "Could not decode video" using any MediaTransportControl.

    XAML

    <mediaplayerelement source="{Binding VideoSource}" autoplay="True" aretransportcontrolsenabled="True"></mediaplayerelement>

    ViewModel

           FileOpenPicker picker = new FileOpenPicker();
           picker.FileTypeFilter.Add("*");

           var file = await picker.PickSingleFileAsync();

           var stream = await file.OpenReadAsync();

           var mediaStreamsource = FFmpegInteropMSS.CreateFFmpegInteropMSSFromStream(stream, false, false).GetMediaStreamSource();

           VideoSource = MediaSource.CreateFromMediaStreamSource(mediaStreamsource);

    Thanks
    Agredo