
Recherche avancée
Autres articles (73)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
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 (10914)
-
Code returns AttributeError : 'VoiceChannel' object has no attribute 'play' when running on Discloud
18 septembre 2023, par Sc4rl3ttfir3So, my code works fine when I run it locally, but even after adapting it to run on Discloud, it returns an error I can't solve.


Code :


@bot.command(name='play', help='To play song')
async def play(ctx, url):
 voice_channel = ctx.author.voice.channel

 if voice_channel is None:
 return await ctx.send('You are not connected to a voice channel.')

 async with ctx.typing():
 filename = await YTDLSource.from_url(url, loop=bot.loop)
 
 if ctx.voice_client is not None:
 ctx.voice_client.stop()

 source = discord.FFmpegPCMAudio(
 executable="ffmpeg",
 source=filename
 )
 
 voice_channel.play(source)

 await ctx.send('**Now playing:** {}'.format(filename))



When it runs on the Discloud server, it returns the following error/traceback message :


Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user_686208406444572830/Sc4rl3ttb0t.py", line 357, in play 
voice_channel.play(source)
^^^^^^^^^^^^^^^^^^
AttributeError: 'VoiceChannel' object has no attribute 'play'



Anybody with any idea of what is going wrong would be greatly appreciated for helping out


-
how to fix Error 'FFmpegPCMAudio' object has no attribute '_process'
30 novembre 2023, par Ma Mefrom ast import alias
import discord
from discord.ext import commands
from youtubesearchpython import VideosSearch
from yt_dlp import YoutubeDL
import asyncio

class music_cog(commands.Cog):
 def __init__(self, bot):
 self.bot = bot
 
 #all the music related stuff
 self.is_playing = False
 self.is_paused = False

 # 2d array containing [song, channel]
 self.music_queue = []
 self.YDL_OPTIONS = {'format': 'bestaudio/best'}
 self.FFMPEG_OPTIONS = {'options': '-vn'}

 self.vc = None
 self.ytdl = YoutubeDL(self.YDL_OPTIONS)

 #searching the item on youtube
 def search_yt(self, item):
 if item.startswith("https://"):
 title = self.ytdl.extract_info(item, download=False)["title"]
 return{'source':item, 'title':title}
 search = VideosSearch(item, limit=1)
 return{'source':search.result()["result"][0]["link"], 'title':search.result()["result"][0]["title"]}

 async def play_next(self):
 if len(self.music_queue) > 0:
 self.is_playing = True

 #get the first url
 m_url = self.music_queue[0][0]['source']

 #remove the first element as you are currently playing it
 self.music_queue.pop(0)
 loop = asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: self.ytdl.extract_info(m_url, download=False))
 song = data['url']
 self.vc.play(discord.FFmpegPCMAudio(song, executable= "ffmpeg.exe", **self.FFMPEG_OPTIONS), after=lambda e: asyncio.run_coroutine_threadsafe(self.play_next(), self.bot.loop))
 
 else:
 self.is_playing = False

 # infinite loop checking 
 async def play_music(self, ctx):
 if len(self.music_queue) > 0:
 self.is_playing = True

 m_url = self.music_queue[0][0]['source']
 #try to connect to voice channel if you are not already connected
 if self.vc == None or not self.vc.is_connected():
 self.vc = await self.music_queue[0][1].connect()

 #in case we fail to connect
 if self.vc == None:
 await ctx.send("```Could not connect to the voice channel```")
 return
 else:
 await self.vc.move_to(self.music_queue[0][1])
 #remove the first element as you are currently playing it
 self.music_queue.pop(0)
 loop = asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: self.ytdl.extract_info(m_url, download=False))
 song = data['url']
 self.vc.play(discord.FFmpegPCMAudio(song, executable= "ffmpeg.exe", **self.FFMPEG_OPTIONS), after=lambda e: asyncio.run_coroutine_threadsafe(self.play_next(), self.bot.loop,))
 else:
 self.is_playing = False

 @commands.command(name="play", aliases=["p","playing"], help="Plays a selected song from youtube")
 async def play(self, ctx, *args):
 query = " ".join(args)
 try:
 voice_channel = ctx.author.voice.channel
 except:
 await ctx.send("```You need to connect to a voice channel first!```")
 return
 if self.is_paused:
 self.vc.resume()
 else:
 song = self.search_yt(query)
 if type(song) == type(True):
 await ctx.send("```Could not download the song. Incorrect format try another keyword. This could be due to playlist or a livestream format.```")
 else:
 if self.is_playing:
 await ctx.send(f"**#{len(self.music_queue)+2} -'{song['title']}'** added to the queue") 
 else:
 await ctx.send(f"**'{song['title']}'** added to the queue") 
 self.music_queue.append([song, voice_channel])
 if self.is_playing == False:
 await self.play_music(ctx)


 @commands.command(name="pause", help="Pauses the current song being played")
 async def pause(self, ctx, *args):
 if self.is_playing:
 self.is_playing = False
 self.is_paused = True
 self.vc.pause()
 if self.is_paused:
 self.vc.resume()
 self.is_playing = True
 self.is_paused = False

 @commands.command(name = "resume", aliases=["r"], help="Resumes playing with the discord bot")
 async def resume(self, ctx, *args):
 if self.is_paused:
 self.is_paused = False
 self.is_playing = True
 self.vc.resume()

 @commands.command(name="skip", aliases=["s"], help="Skips the current song being played")
 async def skip(self, ctx):
 if self.vc != None and self.vc:
 self.vc.stop()
 #try to play next in the queue if it exists
 await self.play_music(ctx)


 @commands.command(name="queue", aliases=["q"], help="Displays the current songs in queue")
 async def queue(self, ctx):
 retval = ""
 for i in range(0, len(self.music_queue)):
 retval += f"#{i+1} -" + self.music_queue[i][0]['title'] + "\n"

 if retval != "":
 await ctx.send(f"```queue:\n{retval}```")
 else:
 await ctx.send("```No music in queue```")

 @commands.command(name="clear", aliases=["c", "bin"], help="Stops the music and clears the queue")
 async def clear(self, ctx):
 if self.vc != None and self.is_playing:
 self.vc.stop()
 self.music_queue = []
 await ctx.send("```Music queue cleared```")

 @commands.command(name="stop", aliases=["disconnect", "l", "d"], help="Kick the bot from VC")
 async def dc(self, ctx):
 self.is_playing = False
 self.is_paused = False
 await self.vc.disconnect()
 
 @commands.command(name="remove", help="Removes last song added to queue")
 async def re(self, ctx):
 self.music_queue.pop()
 await ctx.send("```last song removed```")



I think everything is good but there is no sound Can you give me some advice ?

it python code

-
AttributeError : 'FilterableStream' object has no attribute 'input' - ffmpeg-python
26 septembre 2024, par KarolekI am a fresh programmer and I am learning the Python language.
I have been trying to design a graphical application (using tkinter and ffmpeg-python libraries) that converts an image file along with audio into a video of audio length displaying the image. Unfortunately whenever I try run program I keep encountering errors


At first it was due to installing the ffmpeg library in pip package manager instead of ffmpeg-python. I uninstalled the previous one, installing the correct one making sure no other package causes problems. Using a short script like this, the library functioned smoothly :


'''
The Error causing Statement
import ffmpeg 
(
 ffmpeg.input("something.mp3")
 .output("output.wav")
 .run()
)
'''
# When I tried to use the ffmpeg library in a graphics program within a function, unfortunately I was not able to get it to work

import tkinter as tk
from tkinter import filedialog
from tkinter import ttk

def select_image():
 file_path = filedialog.askopenfilename(title="Select a file", filetypes=[("image files","*.jpg;*.png;*.gif;*.jfif;")])
 print("Selected file:", file_path)

def select_audio():
 file_path = filedialog.askopenfilename(title="Select a file", filetypes=[("audio files","*.mp3;*.wav;*.ogg;*.flac;*.m4a;*.acc;")])
 print("Selected file:", file_path)

def create_video(image_file, audio_file, output_format):
 import ffmpeg
 (
 ffmpeg.input(image_file, loop=1)
 .input(audio_file)
 .output("output" + output_format)
 .run()
 ) 

def choose_directory():
 directory_path = filedialog.askdirectory(title="Select directory")
 print("Selected directory:", directory_path)


root = tk.Tk()

root.title("Audio To Video Converter")
root.geometry("500x700")

title = tk.Label(root, text="Audio To Video Converter", font=('Arial', 28))
title.pack(padx=20, pady=20)

selectImage_button = tk.Button(root, text="Select image", command=select_image, height=3, width=50)
selectImage_button.pack(pady=10, padx=20)
selectAudio_button = tk.Button(root, text="Select audio", command=select_audio, height=3, width=50)
selectAudio_button.pack(pady=10, padx=20)

label1 = tk.Label(root, text="Output video format", font=('Arial', 16))
label1.pack(padx=20, pady=10)

outputFormat = ttk.Combobox(root, width=55)
outputFormat['values'] = ('.avi', '.mkv', '.mp4', '.webm')
outputFormat['state'] = 'readonly'
outputFormat.pack(pady=5, padx=20)

label2 = tk.Label(root, text="Output directory", font=('Arial', 16))
label2.pack(padx=20, pady=10)

outputDirectory_button = tk.Button(root, text="Select directory", command=choose_directory, height=3, width=50)
outputDirectory_button.pack(pady=5, padx=60)


convert_button = tk.Button(root, text="Convert", height=3, width=50, command=create_video(selectImage_button, selectAudio_button, outputFormat['values'] ))

root.mainloop()



This is the only thing the console displayed after attempting to run


Traceback (most recent call last):
 File "c:\Users\Admin\Documents\konwerter\konwerter.py", line 56, in <module>
 convert_button = tk.Button(root, text="Convert", height=3, width=50, command=create_video(selectImage_button, selectAudio_button, outputFormat['values'] ))
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "c:\Users\Admin\Documents\konwerter\konwerter.py", line 17, in create_video
 .input(audio_file)
 ^^^^^
AttributeError: 'FilterableStream' object has no attribute 'input'
</module>


I did some research and did not find any information about this error except that it may be due to installing the wrong libraries. This is my list of installed libraries in pip package manager :


colored 2.2.4 customtkinter 5.2.2 darkdetect 0.8.0 ffmpeg-python 0.2.0 future 1.0.0 Gooey 1.0.8.1 packaging 24.1 pillow 10.4.0 pip 24.2 psutil 6.0.0 pyee 12.0.0 pygtrie 2.5.0 six 1.16.0 tkinterdnd2 0.4.2 typing_extensions 4.12.2 wxPython 4.2.2



Perhaps the solution to the problem is simple, but I am new and don't understand many things. I will be very grateful for your answer !