
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (40)
-
Les vidéos
21 avril 2011, parComme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Possibilité de déploiement en ferme
12 avril 2011, parMediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)
Sur d’autres sites (5132)
-
Skipping extractors execution since zero extractors were registered (Use `node —trace-warnings ...` to show where the warning was created)
28 septembre 2023, par Parkster00I'm following a Discord Music Bot tutorial that uses ffmpeg, here is index.js


require("dotenv").config();

const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const { Client, Collection, Intents } = require('discord.js');
const { Player } = require("discord-player");

const fs = require("node:fs");
const path = require("node:path");

const client = new Client({
 intents: ["Guilds", "GuildMessages", "GuildVoiceStates"]
});

// Set up our commands into an array
const commands = [];
client.commands = new Collection();

const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith(".js"));

for (const file of commandFiles) {
 console.log(`${file}`)
 console.log(`${commandsPath}`)
 const filePath = path.join(commandsPath, file);
 console.log(`${filePath}`)
 const command = require(filePath);

 client.commands.set(command.data.name, command);
 commands.push(command.data.toJSON());
}

// Create the player, highest quality audio
client.player = new Player(client, {
 ytdlOptions: {
 quality: "highestaudio",
 highWaterMark: 1 << 25
 }
});

// Commands are registered
client.on("ready", () => {
 const guild_ids = client.guilds.cache.map(guild => guild.id);

 const rest = new REST({ version: "9" }).setToken(process.env.TOKEN);
 for (const guildId of guild_ids) {
 rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID, guildId), {
 body: commands
 })
 .then(() => console.log(`Added commands to ${guildId}`))
 .catch(console.error);
 }

});

client.on("interactionCreate", async interaction => {
 if (!interaction.isCommand()) return;

 const command = client.commands.get(interaction.commandName);
 if (!command) return;

 try {
 await command.execute({ client, interaction });
 }
 catch (err) {
 console.error(err);
 await interaction.reply("An error occured while executing that command.");
 }
});

console.log(process.env.TOKEN);
client.login(process.env.TOKEN);



And here is play.js where I think the error originates :


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


module.exports = {
 data: new SlashCommandBuilder()
 .setName("play")
 .setDescription("Plays a song.")
 .addSubcommand(subcommand => {
 return subcommand
 .setName("search")
 .setDescription("Searches for a song.")
 .addStringOption(option => {
 return option
 .setName("searchterms")
 .setDescription("search keywords")
 .setRequired(true);
 })
 })
 .addSubcommand(subcommand => {
 return subcommand
 .setName("playlist")
 .setDescription("Plays playlist from YT")
 .addStringOption(option => {
 return option
 .setName("url")
 .setDescription("playlist url")
 .setRequired(true);

 })
 })
 .addSubcommand(subcommand => {
 return subcommand
 .setName("song")
 .setDescription("Plays song from YT")
 .addStringOption(option => {
 return option
 .setName("url")
 .setDescription("url of song")
 .setRequired(true);

 })
 }),
 execute: async ({ client, interaction }) => {

 if (!interaction.member.voice.channel) {
 await interaction.reply("You must be in a voice channel to use this command.");
 return;
 }

 const queue = await client.player.nodes.create(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
 });

 console.log(result.tracks);

 if (result.tracks.length === 0) {
 await interaction.reply("no results found");
 return
 }

 const song = result.tracks[0];
 await queue.addTrack(song);

 embed
 .setDescription(`Added **[${song.title}](${song.url})** to the queue.`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Duration: ${song.duration}` });
 }

 else if (interaction.options.getSubcommand() === "playlist") {
 let url = interaction.options.getString('url');

 const result = await client.player.search(url, {
 requestedBy: interaction.SlashCommandBuilder,
 searchEngine: QueryType.YOUTUBE_PLAYLIST,
 });

 if (result.tracks.length === 0) {
 await interaction.reply("no playlist found");
 return
 }

 const playlist = result.playlist;
 await queue.addTracks(playlist);

 embed
 .setDescription(`Added **[${playlist.title}](${playlist.url})** to the queue.`)
 .setThumbnail(playlist.thumbnail)
 .setFooter({ text: `Duration: ${playlist.duration}` });
 }

 else if (interaction.options.getSubcommand() === "search") {
 let url = interaction.options.getString('searchterms');

 const result = await client.player.search(url, {
 requestedBy: interaction.SlashCommandBuilder,
 searchEngine: QueryType.AUTO,
 });

 if (result.tracks.length === 0) {
 await interaction.reply("no results found");
 return
 }

 const song = result.tracks[0]
 await queue.addTrack(song);

 embed
 .setDescription(`Added **[${song.title}](${song.url})** to the queue.`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Duration: ${song.duration}` });
 }

 if (!queue.playing) await queue.play();

 await interaction.reply({
 embeds: [embed]
 })
 }
}



Is ffmpeg called differently now ? Am I doing something wrong ?


I've tried different installs of Ffmpeg and none seem to work, so I'd imagine it originates somewhere in my code.


-
Audio not playing in discord bot(discord.js)
25 juin 2021, par Manas PrakashI have created a discord bot using discord.js that plays music.
But it is not playing any music...
I tried this but it didn't work, also tried installing multiple ffmpeg libraries.
Here is my Code :


const Discord = require("discord.js");
const dotenv = require("dotenv");
const ytdl = require("ytdl-core");
const ytSearch = require("yt-search");

dotenv.config();

const prefix = "#";
const queue = new Map();

let loop = false;
let count = 1;

const bot = new Discord.Client();

bot.on("ready", () => {
 bot.user.setActivity("Doomer", { type: "LISTENING" });
 console.log("Boomer Online");
});

bot.on("message", async (message) => {
 const args = message.content.slice(prefix.length + 4).split(" ");
 const voice_channel = message.member.voice.channel;
 if (!voice_channel) return;

 const server_queue = queue.get(message.guild.id);

 if (message.content.toLowerCase().startsWith(`${prefix}play`)) {
 if (message.content === `${prefix}play`)
 return message.channel.send("Pls Enter the second srgument");
 let song = {};

 if (ytdl.validateURL(args[1])) {
 const song_info = await ytdl.getInfo(args[1]);
 song = {
 title: song_info.videoDetails.title,
 url: song_info.videoDetails.video_url
 };
 } else {
 const video_finder = async (query) => {
 const video_result = await ytSearch(query);
 return video_result.videos.length > 1 ? video_result.videos[0] : null;
 };

 const video = await video_finder(args.join(" "));
 if (video) {
 song = { title: video.title, url: video.url };
 } else {
 message.channel.send("Error finding video.");
 }
 }

 if (!server_queue) {
 const queue_constructor = {
 voice_channel: voice_channel,
 text_channel: message.channel,
 connection: null,
 songs: []
 };

 queue.set(message.guild.id, queue_constructor);
 queue_constructor.songs.push(song);

 try {
 const connection = await message.member.voice.channel.join();
 queue_constructor.connection = connection;
 video_player(message.guild, queue_constructor.songs[0]);
 } catch (err) {
 queue.delete(message.guild.id);
 message.channel.send("There was an error connecting!");
 throw err;
 }
 } else {
 server_queue.songs.push(song);
 return message.channel.send(`-
-
How to retrieve, process and display frames from a capture device with minimal latency
14 mars 2024, par valleI'm currently working on a project where I need to retrieve frames from a capture device, process them, and display them with minimal latency and compression. Initially, my goal is to maintain the video stream as close to the source signal as possible, ensuring no noticeable compression or latency. However, as the project progresses, I also want to adjust framerate and apply image compression.


I have experimented using FFmpeg, since that was the first thing that came to my mind when thinking about capturing video(frames) and processing them.


However I am not satisfied yet, since I am experiencing delay in the stream. (No huge delay but definately noticable)
The command that worked best so far for me :


ffmpeg -rtbufsize 512M -f dshow -i video="Blackmagic WDM Capture (4)" -vf format=yuv420p -c:v libx264 -preset ultrafast -qp 0 -an -tune zerolatency -f h264 - | ffplay -fflags nobuffer -flags low_delay -probesize 32 -sync ext -


I also used OBS to capture the video stream from the capture device and when looking into the preview there was no noticable delay. I then tried to simulate the exact same settings using ffmpeg :


ffmpeg -rtbufsize 512M -f dshow -i video="Blackmagic WDM Capture (4)" -vf format=yuv420p -r 60 -c:v libx264 -preset veryfast -b:v 2500K -an -tune zerolatency -f h264 - | ffplay -fflags nobuffer -flags low_delay -probesize 32 -sync ext -


But the delay was kind of similar to the one of the command above.
I know that OBS probably has a lot complexer stuff going on (Hardware optimization etc.) but atleast I know this way that it´s somehow possible to display the stream from the capture device without any noticable latency (On my setup).


The approach that so far worked best for me (In terms of delay) was to use Python and OpenCV to read frames of the capture device and display them. I also implemented my own framerate (Not perfect I know) but when it comes to compression I am rather limited compared to FFmpeg and the frame processing is also too slow when reaching framerates about 20 fps and more.


import cv2
import time

# Set desired parameters
FRAME_RATE = 15 # Framerate in frames per second
COMPRESSION_QUALITY = 25 # Compression quality for JPEG format (0-100)
COMPRESSION_FLAG = True # Enable / Disable compression

# Set capture device index (replace 0 with the index of your capture card)
cap = cv2.VideoCapture(4, cv2.CAP_DSHOW)

# Check if the capture device is opened successfully
if not cap.isOpened():
 print("Error: Could not open capture device")
 exit()

# Create an OpenCV window
# TODO: The window is scaled to fullscreen here (The source video is 1920x1080, the display is 1920x1200)
# I don´t know the scaling algorithm behind this, but it seems to be a simple stretch / nearest neighbor
cv2.namedWindow('Frame', cv2.WINDOW_NORMAL)
cv2.setWindowProperty('Frame', cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

# Loop to capture and display frames
while True:
 # Start timer for each frame processing cycle
 start_time = time.time()

 # Capture frame-by-frame
 ret, frame = cap.read()

 # If frame is read correctly, proceed
 if ret:
 if COMPRESSION_FLAG:
 # Perform compression
 _, compressed_frame = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), COMPRESSION_QUALITY])
 # Decode the compressed frame
 frame = cv2.imdecode(compressed_frame, cv2.IMREAD_COLOR)

 # Display the frame
 cv2.imshow('Frame', frame)

 # Calculate elapsed time since the start of this frame processing cycle
 elapsed_time = time.time() - start_time

 # Calculate available time for next frame
 available_time = 1.0 / FRAME_RATE

 # Check if processing time exceeds available time
 if elapsed_time > available_time:
 print("Warning: Frame processing time exceeds available time.")

 # Calculate time to sleep to achieve desired frame rate -> maintain a consistent frame rate
 sleep_time = 1.0 / FRAME_RATE - elapsed_time

 # If sleep time is positive, sleep to control frame rate
 if sleep_time > 0:
 time.sleep(sleep_time)

 # Break the loop if 'q' is pressed
 if cv2.waitKey(1) & 0xFF == ord('q'):
 break

# Release the capture object and close the display window
cap.release()
cv2.destroyAllWindows()



I also thought about getting the SDK of the capture device in order to upgrade the my performance.
But Since I am not used to low level programming but rather to scripting languages, I thought I would reach out to the StackOverflow community at first, and see if anybody has some hints to better approaches or any tips how I could increase my performance.


Any Help is appreciated !