
Recherche avancée
Médias (91)
-
Spoon - Revenge !
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
My Morning Jacket - One Big Holiday
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Zap Mama - Wadidyusay ?
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
David Byrne - My Fair Lady
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Beastie Boys - Now Get Busy
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Granite de l’Aber Ildut
9 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
Autres articles (37)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
Configuration spécifique pour PHP5
4 février 2011, parPHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
Modules spécifiques
Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)
Sur d’autres sites (3397)
-
How to set output file while using subprocess.Popen and hide cmd window at the same time ?
2 mars 2021, par NandeI made a simple app that can convert video files using FFMpeg. I used Kivy for UI. I used
os.system()
to execute ffmpeg commands but while using this method, there is always a cmd window popping up. Therefore i am trying to usesubprocess.Popen()
to execute ffmpeg commands but i also want to save ffmpeg output to a text file.

I tried this but it didn't work :


subprocess.Popen(f"ffmpeg -i {path} -acodec {acodec} {output} > output.txt 2>&1", creationflags = 0x08000000, stdout="output.txt")



FFMpeg converts the video but there is no output.txt file. This code works with
os.system()


How can i hide cmd window while saving output to a text file ?


My full python code :


import os
from signal import SIGINT
import psutil
from time import sleep
from threading import Thread
from kivy.config import Config
Config.set('graphics', 'resizable', False)
Config.set('graphics', 'width', '400')
Config.set('graphics', 'height', '330')
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.core.window import Window
from kivy.uix.popup import Popup
from kivy.properties import ObjectProperty

Window.clearcolor = (1, 1, 1, 1)

desktop = os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop') + "\\"


def cmd(command):
 os.system(command)


def getpid(prcs):
 for proc in psutil.process_iter():
 try:
 pinf = proc.as_dict(attrs=["pid", "name"])
 if prcs.lower() in pinf["name"].lower():
 return pinf["pid"]
 except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
 return False
 return False


# noinspection PyGlobalUndefined
def progress(app, path):
 app.root.prgrss_bar.value = 0
 app.root.prgrss_lbl.text = "Progress: %0"

 if not os.getcwd().endswith("ffmpeg"):
 os.chdir("ffmpeg")

 inputpath = app.root.label.text
 if inputpath.startswith("Choose"):
 return
 audio = app.root.audio.state
 video = app.root.video.state
 both = app.root.both.state

 global line1
 global line2

 if video == "down" or both == "down":
 command = f"ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1 {inputpath} > output2.txt 2>&1"
 os.system(command)
 ffprobe = open("output2.txt", "r")
 frames = int(ffprobe.read())

 control = True
 while control:
 sleep(0.5)

 with open(path, "r") as f:
 for last_line in f:
 pass
 line1 = last_line
 sleep(0.5)

 with open(path, "r") as f:
 for last_line in f:
 pass
 line2 = last_line
 if line1 == line2:
 app.root.prgrss_bar.value = 100
 app.root.prgrss_lbl.text = "Progress: Finished"
 control = False
 else:
 try:
 current_frame = int(line2.split("=")[1].split()[0])
 percentage = int(current_frame / frames * 100)
 text = f"Progress: %{percentage}"
 app.root.prgrss_lbl.text = text
 app.root.prgrss_bar.value = percentage
 if percentage == 100:
 control = False
 except ValueError or TypeError:
 pass

 elif audio == "down":
 command = f"ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {app.root.label.text} > output2.txt 2>&1"
 os.system(command)
 ffprobe = open("output2.txt", "r")
 duration = round(float(ffprobe.read()), 2)
 control = True
 while control:
 sleep(0.5)
 with open(path, "r") as f:
 for last_line in f:
 pass
 line1 = last_line
 sleep(0.5)

 with open(path, "r") as f:
 for last_line in f:
 pass
 line2 = last_line
 if line1 == line2:
 app.root.prgrss_bar.value = 100
 app.root.prgrss_lbl.text = "Progress: Finished"
 control = False
 else:
 try:
 current = line2.split("=")[2].split()[0].split(":")
 seconds = round((int(current[0]) * 3600) + (int(current[1]) * 60) + float(current[2]), 2)
 percentage = int(seconds / duration * 100)
 text = f"Progress: %{percentage}"
 app.root.prgrss_lbl.text = text
 app.root.prgrss_bar.value = percentage
 if percentage == 100:
 control = False
 except ValueError or TypeError:
 pass


class Window(Widget):

 @staticmethod
 def popup_open():
 popup = FolderPopup()
 popup.open()

 @staticmethod
 def exists_open():
 popup = Exists()
 popup.open()

 @staticmethod
 def choose_open():
 popup = ChooseFormat()
 popup.open()

 @staticmethod
 def path_popup():
 popup = ChoosePath()
 popup.open()

 @staticmethod
 def unsupported_audio():
 popup = UnsupportedAudio()
 popup.open()

 @staticmethod
 def no_video_format():
 popup = NoVideoFormat()
 popup.open()

 @staticmethod
 def no_process():
 popup = NoFFMPEGProcess()
 popup.open()

 def start(self, app):
 path = app.root.label.text
 if path.startswith("Choose"):
 self.path_popup()
 return

 outname = app.root.outname.text
 video_f = app.root.spinner.text
 audio_f = app.root.spinner2.text
 video = app.root.video.state
 audio = app.root.audio.state
 both = app.root.both.state

 audio_supported = {"MP4": ["AAC", "MP3", "Opus"],
 "MKV": ["AAC", "MP3", "Opus"],
 "MOV": ["AAC", "MP3"],
 "AVI": ["AAC", "MP3"],
 "WMV": ["AAC", "MP3"]}

 audio_ce = {"AAC": ["aac", ".m4a"],
 "MP3": ["libmp3lame", ".mp3"],
 "Opus": ["libopus", ".opus"],
 "WAV": ["pcm_u8", ".wav"],
 "Choose": ["Choose", "Choose"]}

 if not os.getcwd().endswith("ffmpeg"):
 os.chdir("ffmpeg")

 video_ext = video_f.lower()
 acodec = audio_ce[audio_f][0]
 audio_ext = audio_ce[audio_f][1]
 command = ""

 if (video == "normal" and audio == "normal" and both == "normal") or (
 video_f == "Choose" and audio_f == "Choose"):
 self.choose_open()
 return
 elif video == "down":
 if video_f == "Choose":
 self.no_video_format()
 return
 output = f"{desktop}{outname}.{video_ext}"
 if not os.path.exists(output):
 command += f"ffmpeg -i {path} -an {output} > output.txt 2>&1"
 else:
 self.exists_open()
 return
 elif audio == "down":
 output = f"{desktop}{outname}{audio_ext}"
 if not os.path.exists(output):
 command += f"ffmpeg -i {path} -vn -acodec {acodec} {output} > output.txt 2>&1"
 else:
 self.exists_open()
 return
 elif both == "down":
 if video_f == "Choose":
 self.no_video_format()
 return
 elif audio_f == "Choose":
 output = f"{desktop}{outname}.{video_ext}"
 if not os.path.exists(output):
 command += f"ffmpeg -i {path} {output} > output.txt 2>&1"
 else:
 self.exists_open()
 return
 else:
 if audio_f not in audio_supported[video_f]:
 self.unsupported_audio()
 return
 else:
 output = f"{desktop}{outname}.{video_ext}"
 if not os.path.exists(output):
 command += f"ffmpeg -i {path} -acodec {acodec} {output} > output.txt 2>&1"
 else:
 self.exists_open()
 return

 thrd = Thread(target=cmd, args=(command,))
 thrd.start()
 print("Thread started.")

 def stop(self):
 pid = getpid("ffmpeg")
 if not pid:
 self.no_process()
 else:
 os.kill(pid, SIGINT)

 def test_open(self, app):
 if not os.getcwd().endswith("ffmpeg"):
 os.chdir("ffmpeg")

 video = app.root.label.text
 if video.startswith("Choose"):
 return self.path_popup()

 command = f"ffplay {video}"
 os.system(command)

 @staticmethod
 def check_progress(app):
 path = os.getcwd() + r"\output.txt"
 chkprgrss = Thread(target=progress, args=(app, path,))
 chkprgrss.start()


class FolderPopup(Popup):
 dosya = ObjectProperty(None)
 desktop = desktop

 @staticmethod
 def no_path_submit():
 popup = NoPathSubmit()
 popup.open()

 def buton(self, app):

 try:
 app.root.label.text = self.dosya.selection[0]
 self.dismiss()
 except:
 self.no_path_submit()


class Exists(Popup):
 def buton(self):
 self.dismiss()


class ChooseFormat(Popup):
 def buton(self):
 self.dismiss()


class ChoosePath(Popup):
 def buton(self):
 self.dismiss()


class UnsupportedAudio(Popup):
 def buton(self):
 self.dismiss()


class NoVideoFormat(Popup):
 def buton(self):
 self.dismiss()


class NoPathSubmit(Popup):
 def buton(self):
 self.dismiss()


class NoFFMPEGProcess(Popup):
 def buton(self):
 self.dismiss()


class GUI(App):
 def build(self):
 return Window()


if __name__ == "__main__":
 GUI().run()



-
Help us Reset The Net today on June 5th
This blog post explains why the Piwik project is joining ResetTheNet online protest and how you can help make a difference against mass surveillance. It also includes an infographic and links to useful resources which may be of interest to you.
Snowden revelations, a year ago today
On June 5, 2013 the Guardian newspaper published the first of Edward Snowden’s astounding revelations. It was the first of a continuous stream of stories that pointed out what we’ve suspected for a long time : that the world’s digital communications are being continuously spied upon by nation states with precious little oversight.
Unfortunately, mass surveillance is affecting the internet heavily. The Internet is a powerful force that can promote democracy, innovation, and creativity, but it’s being subverted as a tool for government spying. That is why Piwik has decided to join Reset The Net.
June 5, 2014 marks a new year : a year that will not just be about listening to the inside story of mass surveillance, but a new year of fighting back !
How do I protect myself and others ?
Reset the Net is asking everyone to help by installing free software tools that are designed to protect your privacy on a computer or a mobile device.
Reset the Net is also calling on websites and developers to add surveillance resistant features such as HTTPS and forward secrecy.
Participate in ResetTheNet online protest
Have you got your own website, blog or tumblr ? Maybe you can show the Internet Defense League’s “Cat Signal !” on your website.Get the code now to run the Reset the Net splash screen or banner to help make privacy viral on June 5th.
Message from Edward Snowden
Evan from FFTF sent us this message from Edward Snowden and we thought we would share it with you :
One year ago, we learned that the internet is under surveillance, and our activities are being monitored to create permanent records of our private lives — no matter how innocent or ordinary those lives might be.
Today, we can begin the work of effectively shutting down the collection of our online communications, even if the US Congress fails to do the same. That’s why I’m asking you to join me on June 5th for Reset the Net, when people and companies all over the world will come together to implement the technological solutions that can put an end to the mass surveillance programs of any government. This is the beginning of a moment where we the people begin to protect our universal human rights with the laws of nature rather than the laws of nations.
We have the technology, and adopting encryption is the first effective step that everyone can take to end mass surveillance. That’s why I am excited for Reset the Net — it will mark the moment when we turn political expression into practical action, and protect ourselves on a large scale.
Join us on June 5th, and don’t ask for your privacy. Take it back.
– Message by Edward Snowden
ResetTheNet privacy pack infographic
Additional Resources
Configure Piwik for Security and Privacy
- Turn on automatic SSL redirection in your Piwik.
- Configure Piwik for advanced Privacy.
- Best security practises for Piwik.
More info
- Learn why this matters (EFF)
- Data Privacy Day – Why is privacy important ? (Piwik)
- Web Analytics Privacy (Piwik)
-
Help us Reset The Net today on June 5th
This blog post explains why the Piwik project is joining ResetTheNet online protest and how you can help make a difference against mass surveillance. It also includes an infographic and links to useful resources which may be of interest to you.
Snowden revelations, a year ago today
On June 5, 2013 the Guardian newspaper published the first of Edward Snowden’s astounding revelations. It was the first of a continuous stream of stories that pointed out what we’ve suspected for a long time : that the world’s digital communications are being continuously spied upon by nation states with precious little oversight.
Unfortunately, mass surveillance is affecting the internet heavily. The Internet is a powerful force that can promote democracy, innovation, and creativity, but it’s being subverted as a tool for government spying. That is why Piwik has decided to join Reset The Net.
June 5, 2014 marks a new year : a year that will not just be about listening to the inside story of mass surveillance, but a new year of fighting back !
How do I protect myself and others ?
Reset the Net is asking everyone to help by installing free software tools that are designed to protect your privacy on a computer or a mobile device.
Reset the Net is also calling on websites and developers to add surveillance resistant features such as HTTPS and forward secrecy.
Participate in ResetTheNet online protest
Have you got your own website, blog or tumblr ? Maybe you can show the Internet Defense League’s “Cat Signal !” on your website.Get the code now to run the Reset the Net splash screen or banner to help make privacy viral on June 5th.
Message from Edward Snowden
Evan from FFTF sent us this message from Edward Snowden and we thought we would share it with you :
One year ago, we learned that the internet is under surveillance, and our activities are being monitored to create permanent records of our private lives — no matter how innocent or ordinary those lives might be.
Today, we can begin the work of effectively shutting down the collection of our online communications, even if the US Congress fails to do the same. That’s why I’m asking you to join me on June 5th for Reset the Net, when people and companies all over the world will come together to implement the technological solutions that can put an end to the mass surveillance programs of any government. This is the beginning of a moment where we the people begin to protect our universal human rights with the laws of nature rather than the laws of nations.
We have the technology, and adopting encryption is the first effective step that everyone can take to end mass surveillance. That’s why I am excited for Reset the Net — it will mark the moment when we turn political expression into practical action, and protect ourselves on a large scale.
Join us on June 5th, and don’t ask for your privacy. Take it back.
– Message by Edward Snowden
ResetTheNet privacy pack infographic
Additional Resources
Configure Piwik for Security and Privacy
- Turn on automatic SSL redirection in your Piwik.
- Configure Piwik for advanced Privacy.
- Best security practises for Piwik.
More info
- Learn why this matters (EFF)
- Data Privacy Day – Why is privacy important ? (Piwik)
- Web Analytics Privacy (Piwik)