
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (65)
-
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
-
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 (...)
-
Le plugin : Podcasts.
14 juillet 2010, parLe problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
Types de fichiers supportés dans les flux
Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)
Sur d’autres sites (4175)
-
Discord bot stops playing music at a certain iteration
3 mai 2023, par denisnumbI'm using the following code to play music in a discord voice channel :


import discord
import asyncio
from yt_dlp import YoutubeDL

YDL_OPTIONS = {
 'format': 'bestaudio/best', 
}

FFMPEG_OPTIONS = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 
 'options': '-vn'
}

bot = discord.Client(intents=discord.Intents.all())

async def get_source_url(url: str) -> str:
 with YoutubeDL(YDL_OPTIONS) as ydl:
 return ydl.extract_info(url, download=False).get('url')

@bot.slash_command(name='play')
async def __play(ctx, url: str) -> None:
 source = await get_source_url(url)
 vc = await ctx.author.voice.channel.connect()
 vc.play(discord.FFmpegPCMAudio(source=source, **FFMPEG_OPTIONS))

 while vc.is_playing() or vc.is_paused():
 await asyncio.sleep(1)

 await vc.disconnect()

bot.run('TOKEN')



The principle of operation is as follows :


- 

-
The
/play
command handler receives aurl
argument, in the form of a link to a live stream from YouTube : https://youtu.be/jfKfPfyJRdk (or any other video)

-
The link is passed to the
get_source_url
function, which, using theyt-dlp
library, returns a direct link to the sound from the video

-
The direct link is passed via
discord.FFmpegPCMAudio
to theffmpeg
program, which then returns audio bytes for transmission to the discord voice channel via thevc.play
method










Problem :


Bot is hosted on the virtual hosting server aeza, OS -
Ubuntu Server 22.04
. I installed theffmpeg
version4.4.2
with the commandsudo apt install ffmpeg
.

On the first day everything worked fine, but the next day the bot began to steadily stop playing music at the same moment in different videos (this moment is different for each video). Restarting the bot or server did not help.


Only reinstalling the operating system helps, but also only for one day.


Specific problem :


I checked the execution of every single line of the
discord.VoiceClient.play
method, including all methods called internally. It turned out that the bot hangs every time on the same iteration of the cycle of receiving and sending bytes. Namely, on the first line of thediscord.FFmpegPCMAudio.read
method, that is does not receive data fromffmpeg
and waits indefinitely.


Source of the problem :


The problem is not with a specific
ffmpeg
:

- 

- I also installed
ffmpeg
on another version5.1.2
and the problem was repeated on it.




The problem is not
Ubuntu Server
:

- 

- I changed OS
Ubuntu Server
toDebian 11
and it's the same there




The problem is not in
Linux
:

- 

- When I put the same OS on my virtual machine, everything worked fine with any version of
ffmpeg
.





So the problem is on the hosting side ? I asked those. support to change the server itself and the location of the location. Changed from Sweden to Germany - the same result.


If the data does not come from
ffmpeg
, then you need to find out what is wrong in the program itself. When calling, I pass the-loglevel debug
argument, which shows the most detailed report on the program's operation - all debugging information is displayed, but there are no errors on the "hung" iteration.

What could be the problem ?



UPD 03.05.2023 : I reinstalled OS Ubuntu Server again and the bot works now. But obviously not for long. Maybe I need to clear some cache ?


-
-
The problem is that the music does not play Discord py bot [closed]
7 mai 2023, par ImFoxterWhen I write the command : !yt
Such a mistake :
enter image description here 

I also have FFMPEG, but I don't really understand what to do with it, I've already tried a lot of things and it doesn't work enter image description here

Please help to fix this

I have an operating system : Windows

And the file is created
enter image description here

import asyncio

import discord
import youtube_dl

from discord.ext import commands

youtube_dl.utils.bug_reports_message = lambda: ""

ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0'
}

ffmpeg_options = {"options": "-vn"}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

class YTDLSource(discord.PCMVolumeTransformer):
def __init__(self, source, \*, data, volume=0.5):
super().__init__(source, volume)

 self.data = data
 
 self.title = data.get("title")
 self.url = data.get("url")
 
 @classmethod
 async def from_url(cls, url, *, loop=None, stream=False):
 loop = loop or asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url=url, download=not stream))
 
 if "entries" in data:
 data = data["entries"][0]
 
 file_name = data["url"] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegAudio(file_name, **ffmpeg_options), data=data)

class PlayMusicVoiceChannel(commands.Cog):
def __init__(self, bot):
self.bot = bot

 @commands.command(name="j")
 async def joined(self, ifx, *, channel: discord.VoiceChannel):
 if ifx.voice_client is not None:
 return await ifx.voice_client.move_to(channel)
 await channel.connect()
 
 @commands.command(name="p")
 async def playing(self, ifx, *, query):
 source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
 ifx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)
 await ifx.send(content=f"New playing: {query}")
 
 @commands.command(name="yt")
 async def youtube(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="stream")
 async def stream(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop, stream=True)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="l")
 async def leave(self, ifx):
 await ifx.voice_client.move_to(None)
 
 @playing.before_invoke
 @youtube.before_invoke
 @stream.before_invoke
 async def ensure_voice(self, ifx: commands.Context):
 if ifx.voice_client is None:
 if ifx.author.voice:
 await ifx.author.voice.channel.connect()
 else:
 await ifx.send(content="You are not connected to a voice channel")
 raise commands.CommandError(message="Author not connected to a voice channel")
 elif ifx.voice_client.is_playing():
 ifx.voice_client.stop()

async def setup(bot: commands.Bot):
await bot.add_cog(PlayMusicVoiceChannel(bot))



-
Discord slash command music bot stops playing unexpectedly
29 juillet 2023, par ShelbyThis is a bot I am using to play music and it worked just fine for a while until it didn't. Simply loaded the bot and played for about a minute and quits. From what I see it destroys the entire queue of songs, no matter how many are there. And after that it won't respond to any command and it needs to be reloaded. I don't get any error in the terminal and all the other commands seem to work just fine. Also, this happens to whatever query I use, whether it's 'search', 'url' or 'playlist'.


const { SlashCommandBuilder } = require("@discordjs/builders")
const { EmbedBuilder } = require("discord.js")
const { QueryType } = require("discord-player")

module.exports = {
 data: new SlashCommandBuilder()
 .setName("play")
 .setDescription("Asculta muzica")
 .addSubcommand((subcommand)=>
 subcommand
 .setName("song")
 .setDescription("Incarca o singura melodie printr-un url")
 .addStringOption((option) => option.setName("url").setDescription("url-ul melodiei").setRequired(true)))
 .addSubcommand((subcommand) =>
 subcommand
 .setName("playlist")
 .setDescription("Incarca un playlist printr-un url")
 .addStringOption((option) => option.setName("url").setDescription("url-ul playlist-ului").setRequired(true)))
 .addSubcommand((subcommand) =>
 subcommand
 .setName("search")
 .setDescription("Cauta o melodie pe baza cuvintelor-cheie")
 .addStringOption((option) => 
 option.setName("cautare").setDescription("cauta dupa titlu si autor").setRequired(true))),
 
 run: async ({ client, interaction }) => {
 if (!interaction.member.voice.channel)
 return interaction.editReply("Trebuie sa fii pe un voice channel pentru a folosi aceasta comanda!")

 const queue = await client.player.createQueue(interaction.guild)
 if (!queue.connection) await queue.connect(interaction.member.voice.channel)

 let embed = new EmbedBuilder()

 if (interaction.options.getSubcommand() === "song"){
 let url = interaction.options.getString("url")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.YOUTUBE_VIDEO
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const song = result.tracks[0]
 await queue.addTrack(song)
 embed
 .setColor(0xF07459)
 .setDescription(`**[${song.title}](${song.url})** a fost adaugata`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Durata: ${song.duration}`})

 } else if (interaction.options.getSubcommand() === "playlist"){
 let url = interaction.options.getString("url")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.YOUTUBE_PLAYLIST
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const playlist = result.playlist
 await queue.addTracks(result.tracks)
 embed
 .setColor(0xF07459)
 .setDescription(`**${result.tracks.length} melodii din [${playlist.title}](${playlist.url})** au fost adaugate`)

 } else if (interaction.options.getSubcommand() === "search"){
 let url = interaction.options.getString("cautare")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.AUTO
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const song = result.tracks[0]
 await queue.addTrack(song)
 embed
 .setColor(0xF07459)
 .setDescription(`**[${song.title}](${song.url})** a fost adaugata`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Durata: ${song.duration}`})
 }
 if (!queue.playing) await queue.play()
 await interaction.editReply({
 embeds: [embed]
 })
 
 }
}



This is the code for the [play] command. No change was done since it worked perfectly.


After some research I found out that there might be a problem with the ffmpeg or the ytdl. I tried updating or reinstalling them, but the problem still remains. I would like to know if I'll need to rework the bot to find an alternative to these two.