
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (32)
-
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...) -
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation" -
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 (...)
Sur d’autres sites (5974)
-
"FFmpeg : Error not transitioning to the next song in Discord Bot's queue."
1er avril 2024, par nooberI have 3 modules, but I'm sure the error occurs within this module, and here is the entire code within that module :


import asyncio
import discord
from discord import FFmpegOpusAudio, Embed
import os

async def handle_help(message):
 embed = discord.Embed(
 title="Danh sách lệnh cho Bé Mèo",
 description="Dưới đây là các lệnh mà chủ nhân có thể bắt Bé Mèo phục vụ:",
 color=discord.Color.blue()
 )
 embed.add_field(name="!play", value="Phát một bài hát từ YouTube.", inline=False)
 embed.add_field(name="!pause", value="Tạm dừng bài hát đang phát.", inline=False)
 embed.add_field(name="!resume", value="Tiếp tục bài hát đang bị tạm dừng.", inline=False)
 embed.add_field(name="!skip", value="Chuyển đến bài hát tiếp theo trong danh sách chờ.", inline=False)
 embed.add_field(name="!stop", value="Dừng phát nhạc và cho phép Bé Mèo đi ngủ tiếp.", inline=False)
 # Thêm các lệnh khác theo cùng mẫu trên
 await message.channel.send(embed=embed)

class Song:
 def __init__(self, title, player):
 self.title = title # Lưu trữ tiêu đề bài hát ở đây
 self.player = player

# Thêm đối tượng Song vào hàng đợi
def add_song_to_queue(guild_id, queues, song):
 queues.setdefault(guild_id, []).append(song)

async def handle_list(message, queues):
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 if os.path.exists(log_file_path):
 with open(log_file_path, "r", encoding="utf-8") as f:
 song_list = f.readlines()

 if song_list:
 embed = discord.Embed(
 title="Danh sách bài hát",
 description="Danh sách các bài hát đã phát:",
 color=discord.Color.blue()
 )

 for i, song in enumerate(song_list, start=1):
 if i == 1:
 song = "- Đang phát: " + song.strip()
 embed.add_field(name=f"Bài hát {i}", value=song, inline=False)

 await message.channel.send(embed=embed)
 else:
 await message.channel.send("Hiện không có dữ liệu trong file log.")
 else:
 await message.channel.send("File log không tồn tại.")

async def handle_commands(message, client, queues, voice_clients, yt_dl_options, ytdl, ffmpeg_options=None, guild_id=None, data=None):
 # Nếu không có ffmpeg_options, sử dụng các thiết lập mặc định
 if ffmpeg_options is None:
 ffmpeg_options = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
 'options': '-vn -filter:a "volume=0.25"'
 }
 
 # Khởi tạo voice_client
 if guild_id is None:
 guild_id = message.guild.id

 if guild_id in voice_clients:
 voice_client = voice_clients[guild_id]
 else:
 voice_client = None

 # Xử lý lệnh !play
 if message.content.startswith("!play"):
 try:
 # Kiểm tra xem người gửi tin nhắn có đang ở trong kênh voice không
 voice_channel = message.author.voice.channel
 # Kiểm tra xem bot có đang ở trong kênh voice của guild không
 if voice_client and voice_client.is_connected():
 await voice_client.move_to(voice_channel)
 else:
 voice_client = await voice_channel.connect()
 voice_clients[guild_id] = voice_client
 except Exception as e:
 print(e)

 try:
 query = ' '.join(message.content.split()[1:])
 if query.startswith('http'):
 url = query
 else:
 query = 'ytsearch:' + query
 loop = asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(query, download=False))
 if not data:
 raise ValueError("Không có dữ liệu trả về từ YouTube.")
 url = data['entries'][0]['url']

 player = FFmpegOpusAudio(url, **ffmpeg_options)
 # Lấy thông tin của bài hát mới đang được yêu cầu
 title = data['entries'][0]['title']
 duration = data['entries'][0]['duration']
 creator = data['entries'][0]['creator'] if 'creator' in data['entries'][0] else "Unknown"
 requester = message.author.nick if message.author.nick else message.author.name
 
 # Tạo embed để thông báo thông tin bài hát mới
 embed = discord.Embed(
 title="Thông tin bài hát mới",
 description=f"**Bài hát:** *{title}*\n**Thời lượng:** *{duration}*\n**Tác giả:** *{creator}*\n**Người yêu cầu:** *{requester}*",
 color=discord.Color.green()
 )
 await message.channel.send(embed=embed)
 
 # Sau khi lấy thông tin của bài hát diễn ra, gọi hàm log_song_title với title của bài hát
 # Ví dụ:
 title = data['entries'][0]['title']
 await log_song_title(title)

 # Thêm vào danh sách chờ nếu có bài hát đang phát
 if voice_client.is_playing():
 queues.setdefault(guild_id, []).append(player)
 else:
 voice_client.play(player)
 
 except Exception as e:
 print(e)
 
 if message.content.startswith("!link"):
 try:
 voice_client = await message.author.voice.channel.connect()
 voice_clients[voice_client.guild.id] = voice_client
 except Exception as e:
 print(e)

 try:
 url = message.content.split()[1]

 loop = asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

 song = data['url']
 player = discord.FFmpegOpusAudio(song, **ffmpeg_options)

 voice_clients[message.guild.id].play(player)
 except Exception as e:
 print(e)

 # Xử lý lệnh !queue
 elif message.content.startswith("!queue"):
 queue = queues.get(guild_id, [])
 if queue:
 await message.channel.send("Danh sách chờ:")
 for index, item in enumerate(queue, 1):
 await message.channel.send(f"{index}. {item.title}")
 else:
 await message.channel.send("Không có bài hát nào trong danh sách chờ.")

 # Xử lý lệnh !skip
 elif message.content.startswith("!skip"):
 try:
 if voice_client and voice_client.is_playing():
 voice_client.stop()
 await play_next_song(guild_id, queues, voice_client, skip=True)
 await remove_first_line_from_log()
 except Exception as e:
 print(e)

 # Xử lý các lệnh như !pause, !resume, !stop
 elif message.content.startswith("!pause"):
 try:
 if voice_client and voice_client.is_playing():
 voice_client.pause()
 except Exception as e:
 print(e)

 elif message.content.startswith("!resume"):
 try:
 if voice_client and not voice_client.is_playing():
 voice_client.resume()
 except Exception as e:
 print(e)

 elif message.content.startswith("!stop"):
 try:
 if voice_client:
 voice_client.stop()
 await voice_client.disconnect()
 del voice_clients[guild_id] # Xóa voice_client sau khi dừng
 except Exception as e:
 print(e)

async def log_song_title(title):
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 try:
 # Kiểm tra xem tệp tin log đã tồn tại chưa
 if not os.path.exists(log_file_path):
 # Nếu chưa tồn tại, tạo tệp tin mới và ghi title vào tệp tin đó
 with open(log_file_path, 'w', encoding='utf-8') as file:
 file.write(title + '\n')
 else:
 # Nếu tệp tin log đã tồn tại, mở tệp tin và chèn title vào cuối tệp tin
 with open(log_file_path, 'a', encoding='utf-8') as file:
 file.write(title + '\n')
 except Exception as e:
 print(f"Error logging song title: {e}")

async def remove_first_line_from_log():
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 try:
 with open(log_file_path, "r", encoding="utf-8") as f:
 lines = f.readlines()
 # Xóa dòng đầu tiên trong list lines
 lines = lines[1:]
 with open(log_file_path, "w", encoding="utf-8") as f:
 for line in lines:
 f.write(line)
 except Exception as e:
 print(f"Error removing first line from log: {e}")
 
async def clear_log_file():
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 try:
 with open(log_file_path, "w", encoding="utf-8") as f:
 f.truncate(0)
 except Exception as e:
 print(f"Error clearing log file: {e}")


async def play_next_song(guild_id, queues, voice_client, skip=False):
 queue = queues.get(guild_id, [])
 if queue:
 player = queue.pop(0)
 voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next_song(guild_id, queues, voice_client, skip=False), voice_client.loop))
 if skip:
 return
 else:
 await remove_first_line_from_log() # Xóa dòng đầu tiên trong file log
 elif skip:
 await remove_first_line_from_log() # Xóa dòng đầu tiên trong file log
 await voice_client.disconnect()
 del voice_client[guild_id] # Xóa voice_client sau khi dừng
 else:
 await clear_log_file() # Xóa dòng đầu tiên trong file log
 await voice_client.disconnect()
 del voice_client[guild_id] # Xóa voice_client sau khi dừng



I have tried asking ChatGPT, Gemini, or Bing, and they always lead me into a loop of errors that cannot be resolved. This error only occurs when the song naturally finishes playing due to its duration. If the song is playing and I use the command !skip, the next song in the queue will play and function normally. I noticed that it seems like if a song ends naturally, the song queue is also cleared immediately. I hope someone can help me with this


-
How do I concat two video mp4 files, each of which has an audio of different sample rates with ffmpeg
14 août 2020, par GeoI have two videos : video1.mp4 and video2.mp4 in the configured txt file, both videos have mp3 audios :
video1.mp4 has : Audio : mp3, 32000 Hz, mono, fltp, 48 kb/s
video2.mp4 has : Audio : mp3, 24000 Hz, mono, fltp, 32 kb/s
I need to keep the different sample rates since I need to change the pitch to make it sound different from the real voice of the person, now I tried to merge the two videos by concatenating them :


ffmpeg -safe 0 -f concat -segment_time_metadata 1 -i videoconf.txt -vf select=concatdec_select -af aselect=concatdec_select,aresample=async=1 -y videoout.mp4


but I got a lot of errors like these :


[aac @ 0x730e491e00] channel element 2.12 is not allocated


index.js:81 Error while decoding stream #0:1 : Invalid data found when processing input


index.js:81 [aac @ 0x730e491e00] TYPE_FIL : Input buffer exhausted before END element found


index.js:81 Error while decoding stream #0:1 : Invalid data found when processing input


......


So how can I concatenate multiple videos with different audio sample rates inside each video ?
By the way, when the sample rates are the same for all the audios inside each video, the concat works like a charm.


Thanks


-
Run Windows command through Java Tomcat Server
6 mai 2016, par chellapandi kI am using FFMPEG library files on my windows machine to convert media files from one format to another, so i try to call FFMPEG windows command through java. It works by calling
Process p = Runtime.getRuntime().exec("ffmpeg -i " + xxx.mp4 + " " + yyy.wav + "");
in normal java program. but when i launch my project into TOMCAT server it throws exception likejava.io.IOException: cannot run program : "ffmpeg" CreateProcess error=2, the system cannot find the file specified
. I have attached my code below..String sVideo = "C:\\Users\\Administrator\\Desktop\\voice.amr";
String dVideo2 = "C:\\Users\\Administrator\\Desktop\\sVideo.wav";
try {
Process p = Runtime.getRuntime().exec("ffmpeg -i " + sVideo + " " + dVideo2 + "");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}above code works, when runs this class file separately but when i use this code in my project, it throws exception when run my project in TOMCAT Server. Thanks in advance.