
Recherche avancée
Médias (2)
-
Granite de l’Aber Ildut
9 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
Autres articles (111)
-
Librairies et logiciels spécifiques aux médias
10 décembre 2010, parPour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Les notifications de la ferme
1er décembre 2010, parAfin d’assurer une gestion correcte de la ferme, il est nécessaire de notifier plusieurs choses lors d’actions spécifiques à la fois à l’utilisateur mais également à l’ensemble des administrateurs de la ferme.
Les notifications de changement de statut
Lors d’un changement de statut d’une instance, l’ensemble des administrateurs de la ferme doivent être notifiés de cette modification ainsi que l’utilisateur administrateur de l’instance.
À la demande d’un canal
Passage au statut "publie"
Passage au (...)
Sur d’autres sites (7410)
-
using mediamtx to stream video to browser [closed]
18 octobre 2024, par MaximilianI am using rtsp to feed a video stream to mediamtx.


I want to display the feed in a browser but always get some errors.


I use the following to start mediamtx


podman run --rm -it -e MTX_PROTOCOLS=tcp -e MTX_WEBRTCADDITIONALHOSTS=192.168.x.x -p 8554:8554 -p 1935:1935 -p 8888:8888 -p 8889:8889 -p 8890:8890/udp -p 8189:8189/udp docker.io/bluenviron/mediamtx



I use this ffmpeg line to feed mediamtx :


ffmpeg -i "rtsp://127.0.0.1:10000/test" -f rtsp rtsp://127.0.0.1:8554/feed



I can view the feed with


ffplay rtsp://localhost:8554/feed



ffplay says some things about my stream


the mediamtx stream


Input #0, rtsp, from 'rtsp://localhost:8554/feed':
 Metadata:
 title : Session streamed with GStreamer
 Duration: N/A, start: 0.000000, bitrate: N/A
 Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 30 tbr, 90k tbn, 30 tbc



the source stream


Input #0, rtsp, from 'rtsp://localhost:10000/test':
 Metadata:
 title : Session streamed with GStreamer
 comment : rtsp-server
 Duration: N/A, start: 0.199989, bitrate: N/A
 Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(tv, smpte170m, progressive), 320x240 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr, 90k tbn, 60 tbc



I use this html code try to display the video :



 




mediamtx gives the following output when the browser tries to connect :


2024/10/18 07:52:51 INF [RTSP] [session 7fe6a91a] created by 10.0.2.100:57542
2024/10/18 07:52:51 INF [RTSP] [session 7fe6a91a] is publishing to path 'feed', 1 track (MPEG-4 Video)
2024/10/18 07:52:52 INF [WebRTC] [session 9d4fb884] created by 10.0.2.100:55070
2024/10/18 07:52:52 INF [WebRTC] [session 9d4fb884] closed: the stream doesn't contain any supported codec, which are currently AV1, VP9, VP8, H264, Opus, G722, G711, LPCM



The stream is clearly h264... why is it complaining ?


-
Dynamically created QImage frames to ffmpeg stdin using QThread
11 mai 2021, par musicamanteI am trying to create video files with ffmpeg using frames dynamically created on a separate thread.


While I can create those frames and store them on disk/memory, I'd like to avoid that passage since the amount/size of the frames can be high and many "jobs" could be created with different format or options. But, also importantly, I'd like to better understand the logic behind this, as I admit I've not a very deep knowledge on how thread/processing actually works.


Right now I'm trying to create the QProcess in the QThread object, and then run the image creation thread as soon as the process is started, but it doesn't seem to work : no file is created, and I don't even get any output from standard error (but I know I should, since I can get it if I don't use the thread).


Unfortunately, due to my little knowledge on how QProcess deals with threads and piping (and, obviously, all possible ffmpeg options), I really don't understand how can achieve this.


Besides obviously getting the output file created, the expected result is to be able to launch the encoding (and possibly queue more encodings in the meantime) while keeping the UI responding and get notifications of the current processing state.


import re
from PyQt5 import QtCore, QtGui, QtWidgets

logRegExp = r'(?:(n:\s+)(?P\d+)\s).*(?:(pts_time:\s*)(?P<time>\d+.\d*))'

class Encoder(QtCore.QThread):
 completed = QtCore.pyqtSignal()
 frameDone = QtCore.pyqtSignal(object)
 def __init__(self, width=1280, height=720, frameCount=100):
 super().__init__()
 self.width = width
 self.height = height
 self.frameCount = frameCount

 def start(self):
 self.currentLog = ''
 self.currentData = bytes()
 self.process = QtCore.QProcess()
 self.process.setReadChannel(self.process.StandardError)
 self.process.finished.connect(self.completed)
 self.process.readyReadStandardError.connect(self.stderr)
 self.process.started.connect(super().start)
 self.process.start('ffmpeg', [
 '-y', 
 '-f', 'png_pipe', 
 '-i', '-', 
 '-c:v', 'libx264', 
 '-b:v', '800k', 
 '-an', 
 '-vf', 'showinfo',
 '/tmp/test.h264', 
 ])

 def stderr(self):
 self.currentLog += str(self.process.readAllStandardError(), 'utf-8')
 *lines, self.currentLog = self.currentLog.split('\n')
 for line in lines:
 print('STDERR: {}'.format(line))
 match = re.search(logRegExp, line)
 if match:
 data = match.groupdict()
 self.frameDone.emit(int(data['frame']))

 def run(self):
 font = QtGui.QFont()
 font.setPointSize(80)
 rect = QtCore.QRect(0, 0, self.width, self.height)
 for frame in range(1, self.frameCount + 1):
 img = QtGui.QImage(QtCore.QSize(self.width, self.height), QtGui.QImage.Format_ARGB32)
 img.fill(QtCore.Qt.white)
 qp = QtGui.QPainter(img)
 qp.setFont(font)
 qp.setPen(QtCore.Qt.black)
 qp.drawText(rect, QtCore.Qt.AlignCenter, 'Frame {}'.format(frame))
 qp.end()
 img.save(self.process, 'PNG')
 print('frame creation complete')


class Test(QtWidgets.QWidget):
 def __init__(self):
 super().__init__()
 layout = QtWidgets.QVBoxLayout(self)
 self.startButton = QtWidgets.QPushButton('Start')
 layout.addWidget(self.startButton)

 self.frameLabel = QtWidgets.QLabel()
 layout.addWidget(self.frameLabel)

 self.process = Encoder()
 self.process.completed.connect(lambda: self.startButton.setEnabled(True))
 self.process.frameDone.connect(self.frameLabel.setNum)
 self.startButton.clicked.connect(self.create)

 def create(self):
 self.startButton.setEnabled(False)
 self.process.start()


import sys
app = QtWidgets.QApplication(sys.argv)
test = Test()
test.show()
sys.exit(app.exec_())
</time>


If I add the following lines at the end of
run()
, then the file is actually created and I get the stderr output, but I can see that it's processed after the completion of the for cycle, which obviously is not the expected result :

self.process.closeWriteChannel()
 self.process.waitForFinished()
 self.process.terminate()



Bonus : I'm on Linux, I don't know if it works differently on Windows (and I suppose it would work similarly on MacOS), but in any case I'd like to know if there are differences and how to possibly deal with them.


-
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 ?


-