
Recherche avancée
Autres articles (8)
-
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...) -
Sélection de projets utilisant MediaSPIP
29 avril 2011, parLes exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
Ferme MediaSPIP @ Infini
L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...) -
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.
Sur d’autres sites (1775)
-
Creating a continuous stream for RTMP in Node.js
9 mars 2023, par hankthetank27I'm working on an app that downloads audio from youtube that will be streamed sequentially, similar to radio broadcast. I'm having trouble getting the individual tracks to stream continuously. My idea was to write the tracks sequentially into a readable stream that then is read by FFMPEG. Here is the code I'm having trouble with...


import ytdl from "ytdl-core";
import ffmpeg from 'fluent-ffmpeg';
import { Readable } from "node:stream"

export async function startAudioStream(): Promise<void>{

 const mainStream = await createStreamedQueue()

 ffmpeg(mainStream)
 .inputOptions([
 '-re'
 ])
 .outputOption([
 // '-c:v libx264',
 // '-preset veryfast',
 // '-tune zerolatency',
 '-c:a aac',
 '-ar 44100',
 ])
 .save('rtmp://localhost/live/main.flv');
};

async function createStreamedQueue(): Promise<readable>{

 function createStream(): Readable{
 const stream = new Readable({
 read(){},
 highWaterMark: 1024 * 512,
 });
 stream._destroy = () => { stream.destroyed = true };
 return stream;
 }

 const mainStream = createStream();

 const ref1 = 'https://youtu.be/lLCEUpIg8rE'
 const ref2 = 'https://youtu.be/bRdyzdXJ0KA';

 function queueSong(src: string, stream: Readable): Promise<void>{
 return new Promise<void>((resolve, reject) => {
 ytdl(src, {
 filter: 'audioonly',
 quality: 'highestaudio'
 })
 .on('data', (data) => {
 stream.push(data);
 })
 .on('end', () => {
 resolve();
 })
 .on('error', (err) => {
 console.error('Error downloading file from YouTube.', err);
 reject(err);
 })
 })
 }
 
 await queueSong(ref1, mainStream);
 // console.log('after firsrt: ', mainStream)
 await queueSong(ref2, mainStream);
 // console.log('after second: ', mainStream)
 return mainStream;
};
</void></void></readable></void>


To start,
startAudioStream
is called to initiate a readable stream of audio to an RTMP server via FFMPEG. That is working fine. The part I'm having trouble with is "queuing" the tracks into the stream that's being fed into FFMPEG. Right now, I have a "main" stream that each songs data is being pushed into, as you can see inqueueSong
. At the end of ytdl stream, the promise is resolved, allowing for the next song to be queued and its data to be pushed intomainStream
. The issue that I'm experiencing is that the audio fromref1
is only every played.

I can see in the logs that
mainStream
does grow in length after each call toqueueSong
, but still will only stream the audio from the first track. My initial thought was that there is a terminating character at the of the last data chunk thats being written to the steam for each song ? But maybe im getting screwed up on how streams work...

-
nodejs ffmpeg child-process stdio stream stops
10 mars 2023, par BleedFeedI've been trying to make an internet radio stream using ffmpeg to encode the audio data in mp3


function getAudioStream(url){

 return new Promise(async(resolve,reject)=>{

 const ytdlStream = await ytdl(url,{filter:'audioonly',quality:'highestaudio'});

 const ffmpegProcess = spawn('ffmpeg',[
 '-i','pipe:3',
 '-f','mp3',
 '-ar','44100',
 '-ac','2',
 '-b:a','128k',
 '-codec:a','libmp3lame',
 '-flush_packets', '1',
 'pipe:4'],{stdio:['ignore','ignore','pipe','pipe','pipe']});
 ytdlStream.pipe(ffmpegProcess.stdio[3]);
 ffmpegProcess.stderr.on('data',(chunk)=>{
 console.log('FFMPEG ERROR: ' + chunk.toString());
 })
 resolve(ffmpegProcess.stdio[4].pipe(new PassThrough({highWaterMark:4096})));
 });
}

async function setUpStream(fromQueue,client,shout){

 let readable;
 let videoDetails;

 if(fromQueue){
 readable = await getAudioStream(queue[0]);
 videoDetails = (await ytdl.getBasicInfo(queue[0])).videoDetails;
 queue.shift();
 }
 else{
 let song = songs[Math.floor(Math.random() * songs.length)];
 readable = await getAudioStream(song);
 videoDetails = (await ytdl.getBasicInfo(song)).videoDetails;
 }


 readable.on('data',async (chunk)=>{
 readable.pause();
 shout.send(chunk,chunk.length);
 await new Promise((resolve)=>{setTimeout(resolve,shout.delay())});
 readable.resume();
 });

 readable.on('end',()=>{
 readable.destroy();
 setUpStream(queue.length !==0,client,shout);
 });


 readable.on('error',(err)=>{
 console.log(err);
 });

}



shout.send is from npm nodeshout library and it delivers the audio data to icecast server.
I get another ffmpeg audio stream once the current one ends. After 20 or 30 minutes ffmpeg logs stop and no further data comes from ffmpegStream


FFMPEG ERROR: size= 2952kB time=00:03:08.89 bitrate= 128.0kbits/s speed=1.07x
FFMPEG ERROR: size= 3016kB time=00:03:13.00 bitrate= 128.0kbits/s speed=1.07x
FFMPEG ERROR: size= 3080kB time=00:03:17.10 bitrate= 128.0kbits/s speed=1.07x
FFMPEG ERROR: size= 3144kB time=00:03:21.17 bitrate= 128.0kbits/s speed=1.07x
FFMPEG ERROR: size= 3208kB time=00:03:25.27 bitrate= 128.0kbits/s speed=1.07x 



these are the last lines printed at console. Maybe some sort of memory management problem with child process ? How can i find what causes this problem ?


-
FFmpegPCMAudio not playing in discord no error
9 mars 2023, par Anton AbboudOkey, it might be something obvious that ive missed but i really can't find the issue. I am currently making a discord-music-bot which has worked fine before. However as soon as i moved over to yt-dlp from youtube-dl (due to an error with youtube-dl) FFmpegPCMAudio doesn't play the music. It read through the code like normal but it simply doesn't play the sound. It even downloads the music from youtube so I am a bit confused. Here is what my code looks like :


class music_cog(commands.Cog):
 
 #Searching the keyword on youtube
 def search_yt(self, item):
 with yt_dlp.YoutubeDL(self.YDL_OPTIONS) as ydl:
 try: 
 info = ydl.extract_info("ytsearch:%s" % item, download=False)['entries'][0]
 except Exception: 
 return False

 return {'source': info['formats'][0]['url'], 'title': info['title']}

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

 
 #Get the first url
 my_url = self.music_queue[0][0]['source']

 global current_song_title
 current_song_title = self.music_queue[0][0]['title']

 #Remove the first song in queue as you are currently playing it
 self.music_queue.pop(0)

 self.vc.play(nextcord.FFmpegPCMAudio(my_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
 else:
 self.is_playing = False

 # Infinite loop checking if there is a song in queue
 async def play_music(self, ctx):
 if len(self.music_queue) > 0:
 self.is_playing = True
 my_url = self.music_queue[0][0]['source']
 
 global current_song_title
 current_song_title = self.music_queue[0][0]['title']
 
 #Try to connect to voice channel if bot is not already connected
 if self.vc == None or not self.vc.is_connected():
 self.vc = await self.music_queue[0][1].connect()

 #In case the bot fails 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])
 
 self.music_queue.pop(0)
 print("hello")
 self.vc.play(nextcord.FFmpegPCMAudio(my_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
 
 else:
 self.is_playing = False

 @commands.command(name="play", aliases=["p"], help="Plays a selected song from youtube")
 async def play(self, ctx, *args):
 query = " ".join(args)
 
 if ctx.author.voice is None:
 #User needs to be connected so that the bot knows where to go
 await ctx.send("Connect to a voice channel!")
 
 elif self.is_paused:
 self.vc.resume()
 
 else:
 global song
 song = self.search_yt(query)
 if type(song) == type(True):
 #In case the song is not able to download
 await ctx.send("Could not download the song. Incorrect format try another keyword. This could be due to playlist or a livestream format.")
 else:
 await ctx.send(f"{song['title']} added to the queue, and gets played if nothing else is in the queue or currently playing")
 voice_channel = ctx.author.voice.channel
 self.music_queue.append([song, voice_channel])
 
 if self.is_playing == False:
 await self.play_music(ctx)



I have tried searching on how to use FFmpeg even though I have made it work before. but I haven't found anything of use. I wanted to convert back to youtube-dl but realized that it still won't work because of an issue in thier code. I can't really try anything else since im not getting an error. The terminal displays :


[youtube:search] Extracting URL: ytsearch:heh 
[download] Downloading playlist: heh 
[youtube:search] query "heh": Downloading web client config
[youtube:search] query "heh" page 1: Downloading API JSON 
[youtube:search] Playlist heh: Downloading 1 items of 1 
[download] Downloading item 1 of 1
[youtube] Extracting URL: https://www.youtube.com/watch?v=8EhaZG7i9Bk
[youtube] 8EhaZG7i9Bk: Downloading webpage
[youtube] 8EhaZG7i9Bk: Downloading android player API JSON 
[download] Finished downloading playlist: heh 
hello



I used "heh" as an example searchword and "hello" to check if the code actually read what it where it is supposed to play the audio.


Please help !