
Recherche avancée
Autres articles (38)
-
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 (...) -
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 -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...)
Sur d’autres sites (5642)
-
FFMPEG(?) Error : [out#0/s16le @ 000002452f906a00] Output file does not contain any stream
11 mars 2024, par OndoshFFMPEG_OPTIONS = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
 'options': '-vn'}
YDL_OPTIONS = {
 'format': 'bestaudio/best',
 'extractaudio': True,
 'noplaylist': True,
 'simulate': 'True',
 'preferredquality': '192',
 'preferredcodec': 'mp3',
 'key': 'FFmpegExtractAudio'}
@bot.command(aliases=['Ping', 'PING', 'Пинг', 'ПИНГ', 'зштп', 'ЗШТП', 'Зштп',
 'пинг'])
async def ping(ctx):
 await ctx.message.reply(f'Ping: {round(bot.latency * 1000)}ms')
#########################[PLAY MUSIC BLOCK]#########################
@bot.command()
async def add(ctx, *url):
 url = ' '.join(url)
 with yt_dlp.YoutubeDL(YDL_OPTIONS) as ydl:
 try:
 info = ydl.extract_info(url, download=False)
 except:
 info = ydl.extract_info(f"ytsearch:{url}",
 download=False)['entries'][0]

 URL = info['formats'][0]['url']
 name = info['title']
 time = str(datetime.timedelta(seconds=info['duration']))
 songs_queue.q_add([name, time, URL])
 embed = nextcord.Embed(description=f'Записываю [{name}]({url}) в очередь 📝',
 colour=nextcord.Colour.red())
 await ctx.message.reply(embed=embed)
def step_and_remove(voice_client):
 if loop_flag:
 songs_queue.q_add(songs_queue.get_value()[0])
 songs_queue.q_remove()
 audio_player_task(voice_client)
def audio_player_task(voice_client):
 if not voice_client.is_playing() and songs_queue.get_value():
 voice_client.play(nextcord.FFmpegPCMAudio(
 executable="ffmpeg\\bin\\ffmpeg.exe",
 source=songs_queue.get_value()[0][2],
 **FFMPEG_OPTIONS),
 after=lambda e: step_and_remove(voice_client))
@bot.command(aliases=['Play', 'PLAY', 'играй', 'ИГРАЙ', 'Играй', 'сыграй',
 'Сыграй', 'СЫГРАЙ', 'здфн', 'Здфн', 'ЗДФН', 'p', 'P',
 'pl', 'PL', 'Pl', 'Плей',
 'ПЛЕЙ', 'плей'])
async def play(ctx, *url):
 await join(ctx)
 await add(ctx, ' '.join(url))
 await ctx.message.add_reaction(emoji='🎸')
 voice_client = ctx.guild.voice_client
 audio_player_task(voice_client)
@bot.command(aliases=['Queue', 'QUEUE', 'йгугу', 'Йгугу', 'ЙГУГУ', 'очередь',
 'Очередь', 'ОЧЕРЕДЬ', 'список', 'Список', 'СПИСОК',
 'list', 'List', 'LIST', 'дшые', 'Дшые', 'ДШЫЕ', 'Лист',
 'лист', 'ЛИСТ', 'песни', 'Песни', 'ПЕСНИ', 'songs',
 'Songs', 'SONGS', 'ыщтпы', 'ЫЩТПЫ', 'Ыщтпы', 'q'])
async def queue(ctx):
 if len(songs_queue.get_value()) > 0:
 only_names_and_time_queue = []
 for i in songs_queue.get_value():
 name = i[0]
 if len(i[0]) > 30:
 name = i[0][:30] + '...'
 only_names_and_time_queue.append(f'📀 `{name:<33} {i[1]:>20}`\n')
 c = 0
 queue_of_queues = []
 while c < len(only_names_and_time_queue):
 queue_of_queues.append(only_names_and_time_queue[c:c + 10])
 c += 10

 embed = nextcord.Embed(title=f'ОЧЕРЕДЬ [LOOP: {loop_flag}]',
 description=''.join(queue_of_queues[0]),
 colour=nextcord.Colour.red())
 await ctx.send(embed=embed)

 for i in range(1, len(queue_of_queues)):
 embed = nextcord.Embed(description=''.join(queue_of_queues[i]),
 colour=nextcord.Colour.red())
 await ctx.send(embed=embed)
 else:
 await ctx.send('Очередь пуста')



There is the part of my music bot in Discord, I don't really know why it doesn't work. Actually, I tried to use someone's old code, so it needs to be fixed. I have cut out the most important parts of the code, which most likely had an error.
I found other questions, but there was another errors.
After trying to start the video, I get the following errors :
[out#0/s16le @ 000002452f906a00] Output file does not contain any stream
Error opening output file pipe:1.
Error opening output files : Invalid argument


-
React Native (Android) : Download mp3 file
21 février 2024, par Batuhan FındıkI get the youtube video link from the ui. I download the video from this link and convert it to mp3. I download it to my phone as mp3. The song opens on WhatsApp on the phone. but it doesn't open on the mp3 player. The song is not broken because it opens on WhatsApp too. Why do you think the mp3 player doesn't open ? Could it be from the file information ? I tried to enter some file information but it still won't open. For example, there is from information in songs played on an mp3 player. There is no from information in my song file. I tried to add it but it wasn't added.


.net 8 api return :


[HttpPost("ConvertVideoToMp3")]
public async Task<iactionresult> ConvertVideoToMp3(Mp3 data)
{
 try
 {
 string videoId = GetYoutubeVideoId(data.VideoUrl);

 var streamInfoSet = await _youtubeClient.Videos.Streams.GetManifestAsync(videoId);
 var videoStreamInfo = streamInfoSet.GetAudioOnlyStreams().GetWithHighestBitrate();

 if (videoStreamInfo != null)
 {
 var videoStream = await _youtubeClient.Videos.Streams.GetAsync(videoStreamInfo);
 var memoryStream = new MemoryStream();

 await videoStream.CopyToAsync(memoryStream);
 memoryStream.Seek(0, SeekOrigin.Begin);

 var videoFilePath = $"{videoId}.mp4";
 await System.IO.File.WriteAllBytesAsync(videoFilePath, memoryStream.ToArray());

 var mp3FilePath = $"{videoId}.mp3";
 var ffmpegProcess = Process.Start(new ProcessStartInfo
 {
 FileName = "ffmpeg",
 Arguments = $"-i \"{videoFilePath}\" -vn -acodec libmp3lame -ab 128k -id3v2_version 3 -metadata artist=\"YourArtistName\" -metadata title=\"YourTitle\" -metadata from=\"youtube\" \"{mp3FilePath}\"",
 RedirectStandardError = true,
 UseShellExecute = false,
 CreateNoWindow = true
 });

 await ffmpegProcess.WaitForExitAsync();

 var file = TagLib.File.Create(mp3FilePath);

 
 file.Tag.Artists = new string [] { "YourArtistName"};
 file.Tag.Title = "YourTitle";
 file.Tag.Album = "YourAlbumName"; 
 file.Tag.Comment = "Source: youtube";
 

 file.Save();

 var mp3Bytes = await System.IO.File.ReadAllBytesAsync(mp3FilePath);

 System.IO.File.Delete(videoFilePath);
 System.IO.File.Delete(mp3FilePath);

 return File(mp3Bytes, "audio/mpeg", $"{videoId}.mp3");
 }
 else
 {
 return NotFound("Video stream not found");
 }
 }
 catch (Exception ex)
 {
 return StatusCode(500, $"An error occurred: {ex.Message}");
 }
}
</iactionresult>


React Native :


const handleConvertAndDownload = async () => {
 try {
 const url = 'http://192.168.1.5:8080/api/Mp3/ConvertVideoToMp3';
 const fileName = 'example';
 const newFileName = generateUniqueSongName(fileName);
 const filePath = RNFS.DownloadDirectoryPath + '/'+newFileName;

 fetch(url, {
 method: 'POST',
 headers: {
 'Content-Type': 'application/json',
 },
 body: JSON.stringify({videoUrl:videoUrl}),
 })
 .then((response) => {
 if (!response.ok) {
 Alert.alert('Error', 'Network');
 throw new Error('Network response was not ok');
 }
 return response.blob();
 })
 .then((blob) => {
 return new Promise((resolve, reject) => {
 const reader = new FileReader();
 reader.onloadend = () => {
 resolve(reader.result.split(',')[1]); 
 };
 reader.onerror = reject;
 reader.readAsDataURL(blob);
 });
 })
 .then((base64Data) => {
 // Dosyanın varlığını kontrol et
 return RNFS.exists(filePath)
 .then((exists) => {
 if (exists) {
 console.log('File already exists');
 return RNFS.writeFile(filePath, base64Data, 'base64', 'append');
 } else {
 console.log('File does not exist');
 return RNFS.writeFile(filePath, base64Data, 'base64');
 }
 })
 .catch((error) => {
 console.error('Error checking file existence:', error);
 throw error;
 });
 })
 .then(() => {
 Alert.alert('Success', 'MP3 file downloaded successfully.');
 console.log('File downloaded successfully!');
 })
 .catch((error) => {
 Alert.alert('Error', error.message);
 console.error('Error downloading file:', error);
 });
 } catch (error) {
 Alert.alert('Error', error.message);
 console.error(error);
 }
 };



-
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