
Recherche avancée
Médias (1)
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
Autres articles (31)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
Les statuts des instances de mutualisation
13 mars 2010, parPour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...) -
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
Sur d’autres sites (4643)
-
wMy media converter app crashes when handling file names with spaces
8 janvier 2013, par suffaI wrote an app that uses ffmpeg to convert media files (.wav, .avi, .mp3, ... etc.). It works only with file names that have no spaces. When a file name with spaces is encountered, the app immediately closes. Can someone tell me if the string I'm using to call ffmpeg is correct, or need some characters escaped ? Below is a fragment of the code :
...
...
...
#Select Media
os.chdir("c:\\d-Converter\\ffmpeg\\bin")
wrkdir = os.getcwd()
filelist = os.listdir(wrkdir)
self.formats1 = []
for filename in filelist:
(head, filename) = os.path.split(filename)
if filename.endswith(".avi") or filename.endswith(".mp4") or filename.endswith(".flv") or filename.endswith(".mov") or filename.endswith(".mpeg4") or filename.endswith(".mpeg") or filename.endswith(".mpg2") or filename.endswith(".wav") or filename.endswith(".mp3"):
self.formats1.append(filename)
self.format_combo1=wx.ComboBox(panel, size=(140, -1),value='Select Media', choices=self.formats1, style=wx.CB_DROPDOWN, pos=(300,50))
self.Bind(wx.EVT_COMBOBOX, self.fileFormats, self.format_combo1)
...
...
...
def fileFormats(self, e):
myFormats = {'audio': ('Select Format','.mp3', '.ogg', '.wav', '.wma'), 'video': ('Select Format','.flv','.mpg', '.mp4', '.mpeg')}
bad_file = ['Media not supported']
myFile = self.format_combo1.GetValue()
f_exten = (x for x in myFormats['audio'] + myFormats['video'] if myFile.endswith(x))
extension = f_exten.next()
if extension in myFormats['audio']:
self.format_combo2.SetItems(myFormats['audio'])
elif extension in myFormats['video']:
self.format_combo2.SetItems(myFormats['video'])
else:
self.format_combo2.SetItems(bad_file)
...
...
...
def convertButton(self, e):
unit1 = self.format_combo1.GetValue()
if unit1:
unit1 = self.repl_Wspace(unit1)
#Media Formats
unit2 = self.format_combo2.GetValue()
unit3 = self.format_combo3.GetValue()
unit4 = None
unit5 = self.format_combo5.GetValue()
bitRate = self.format_combo6.GetValue()
unit6 = bitRate
if unit3 == '-qmax':
unit4 = self.format_combo4.GetValue()
else:
pass
os.chdir("c:\\d-Converter\\ffmpeg\\bin")
wrkdir = os.getcwd()
newfile = unit1
stripped = newfile.strip('mpeg3aviovfl4w2c.') #Strips the extension from the original file name
progname='c:\\d-Converter\\ffmpeg\\bin\\ffmpeg.exe' + ' -i '
preset1_a='-vn -ar 44100 -ac 2 -ab'
preset1_b='-f mp3 '
preset_mp3='.mp3'
chck_unit1 = self.my_endswith(unit1)
while True:
if unit5 == 'video to mp3':
if unit6 == 'k/bs' or unit6 == '':
amsg = wx.MessageDialog(None, 'You must select a bit rate.', 'Media Converter', wx.ICON_INFORMATION)
amsg.ShowModal()
amsg.Destroy()
break
elif unit5 == 'video to mp3' and unit6 != 'k/bs' or unit6 != '':
self.button.Disable()
self.button2.Enable()
self.format_combo1.Disable()
self.format_combo2.Disable()
self.format_combo3.Disable()
self.format_combo4.Disable()
self.format_combo5.Disable()
self.format_combo6.Disable()
startWorker(self.LongTaskDone, self.LongTask3, wargs=(progname, wrkdir, unit1, preset1_a, unit6, preset1_b, stripped, preset_mp3))
break
elif unit1 != unit1.endswith(".mpg") or unit1.endswith(".mpeg") or unit1.endswith(".avi") or unit1.endswith(".mp4") or unit1.endswith(".flv"):
bmsg = wx.MessageDialog(None, 'You must select a valid format to convert to .mp3.', 'Media Converter', wx.ICON_INFORMATION)
bmsg.ShowModal()
bmsg.Destroy()
break
else:
pass
if unit1 == 'Select Media' or unit1 == '':
amsg = wx.MessageDialog(None, 'You must select a media file!', 'Media Converter', wx.ICON_INFORMATION)
amsg.ShowModal()
amsg.Destroy()
break
elif unit2 == 'Select Format' or unit2 == '' or unit2 == chck_unit1:
amsg = wx.MessageDialog(None, 'You must select a valid format', 'Media Converter', wx.ICON_INFORMATION)
amsg.ShowModal()
amsg.Destroy()
break
elif unit3 == 'Select Quality' or unit3 == '':
amsg = wx.MessageDialog(None, 'You must select quality', 'Media Converter', wx.ICON_INFORMATION)
amsg.ShowModal()
amsg.Destroy()
break
elif unit3 != 'Select Quality' or unit3 != '':
self.format_combo5.Disable()
if unit3 == '-qmax':
if unit4 == '0' or unit4 == '':
amsg = wx.MessageDialog(None, 'You must select number between 1-8.', 'Media Converter', wx.ICON_INFORMATION)
amsg.ShowModal()
amsg.Destroy()
break
else:
self.button.Disable()
self.button2.Enable()
self.format_combo1.Disable()
self.format_combo2.Disable()
self.format_combo3.Disable()
self.format_combo4.Disable()
self.format_combo5.Disable()
startWorker(self.LongTaskDone, self.LongTask2, wargs=(progname,wrkdir,unit1,unit3,unit4,stripped,unit2))
break
elif unit3 == '-sameq':
self.button.Disable()
self.button2.Enable()
self.format_combo1.Disable()
self.format_combo2.Disable()
self.format_combo3.Disable()
self.format_combo4.Disable()
self.format_combo5.Disable()
startWorker(self.LongTaskDone, self.LongTask, wargs=(progname,wrkdir,unit1,unit3,stripped,unit2))
break
def LongTask(self, progname, wrkdir, unit1, unit3, stripped, unit2):
convert_file1 = progname + wrkdir + '\\' + unit1 + ' ' + unit3 + ' ' + stripped + unit2
self.statusbar.SetStatusText("Converting: " + unit1 + "...")
os.system(convert_file1)
print convert_file1
def LongTask2(self, progname, wrkdir, unit1, unit3, unit4, stripped, unit2):
convert_file2 = progname + wrkdir + '\\' + unit1 + ' ' + unit3 + ' ' + unit4 + ' ' + stripped + unit2
self.statusbar.SetStatusText("Converting: " + unit1 + "...")
os.system(convert_file2)
...
...
... -
os.walk returns file names but when trying to modify the files it says directory not found
13 avril 2021, par epWILLIm trying to walk through music folder and find all sub folders in it and convert the mp4's in all folders to wav. It prints out the correct file name but when it trys to convert it says directory not found.


I would like to us os.walk to go through all folders instead going through 1 folder and changing the name in the code for the other folders


This code works for one folder


import os
import ffmpeg
import time

path = './musicTest/'


os.chdir(path)
aud_files = os.listdir()
count = 0
count2 = 0


 ##convert mp4 to wav
for file in aud_files:
 os.system('ffmpeg -i "{}" -acodec pcm_s16le -ac 1 -ar 16000 output-{}.wav'.format(file, count))
 count = count + 1
 os.remove(file)



this is the code that gives me no directory found when using os.walk but it prints the file name


import os
from pydub import AudioSegment
import ffmpeg

path = "./musicTest/"
count = 0

for i, (root, dirs, files) in enumerate(os.walk(path)):
 if root is not path:
 for file in files:
 print(file)
 os.system('ffmpeg -i "{}" -acodec pcm_s16le -ac 1 -ar 16000 output-{}.wav'.format(file, count))
 count = count + 1



-
ffmpeg select subclips from large video bash and create outputfile names
29 juin 2018, par martinsI am using bash command on a Mac Terminal. For each of the 250 .mp4 files in a directory I need to create a new outputfile which extracts 4 subclips from each inputfile : 1st subclip (from second 10 to 20), 2nd subclip (10 seconds at a 33% stage of the inputfile), 3rd subclip (10 seconds at a 66% of the inputfile), and a 4th subclip (10 seconds starting 30seconds before the end of the inputfile). Each inputfile has a different length of about 10-15minutes.
I tried with one inputfile and the following bash script works :
#!/bin/bash
for file in *.mp4; do ffmpeg -i "$file" -vf "select='between(t, 10, 20) + between(t, 197, 207) + between(t, 393, 403) + between(t, 570,580)',
setpts=N/FRAME_RATE/TB" -qscale 0 -af "aselect='between(t, 10, 20) +
between(t, 197, 207) + between(t, 393, 403) + between(t, 570, 580)',
asetpts=N/SR/TB" outputfile.mp4; doneHowever, I don’t know how to loop it over the 250 mp4 files. Specifically, I have 2 issues :
- The above code shows specific seconds I manually checked from the inputfile I used to test the code. I need to automatize the code according to the timings above.
- Name the outputfile the same as the inputfile but adding "_1" suffix
In sum, I have a directory with inputfiles between 10-15minutes long :
inputfile1.mp4
inputfile2.mp4
inputfile3.mp4
.......
inputfile250.mp4And I want the same directory with inputfiles and outputfiles together :
inputfile1.mp4
inputfile1_1.mp4 #this is 40 seconds long
inputfile2.mp4
inputfile2_1.mp4 #this is 40 seconds long
inputfile3.mp4
inputfile3_1.mp4 #this is 40 seconds long
.......
inputfile250.mp4
inputfile250_1.mp4 #this is 40 seconds longThank you very much in advance.