Recherche avancée

Médias (2)

Mot : - Tags -/kml

Autres articles (111)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour 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, par

    Afin 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, par

    Afin 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 Maximilian

    I 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 musicamante

    I 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&#xA;from PyQt5 import QtCore, QtGui, QtWidgets&#xA;&#xA;logRegExp = r&#x27;(?:(n:\s&#x2B;)(?P\d&#x2B;)\s).*(?:(pts_time:\s*)(?P<time>\d&#x2B;.\d*))&#x27;&#xA;&#xA;class Encoder(QtCore.QThread):&#xA;    completed = QtCore.pyqtSignal()&#xA;    frameDone = QtCore.pyqtSignal(object)&#xA;    def __init__(self, width=1280, height=720, frameCount=100):&#xA;        super().__init__()&#xA;        self.width = width&#xA;        self.height = height&#xA;        self.frameCount = frameCount&#xA;&#xA;    def start(self):&#xA;        self.currentLog = &#x27;&#x27;&#xA;        self.currentData = bytes()&#xA;        self.process = QtCore.QProcess()&#xA;        self.process.setReadChannel(self.process.StandardError)&#xA;        self.process.finished.connect(self.completed)&#xA;        self.process.readyReadStandardError.connect(self.stderr)&#xA;        self.process.started.connect(super().start)&#xA;        self.process.start(&#x27;ffmpeg&#x27;, [&#xA;            &#x27;-y&#x27;, &#xA;            &#x27;-f&#x27;, &#x27;png_pipe&#x27;, &#xA;            &#x27;-i&#x27;, &#x27;-&#x27;, &#xA;            &#x27;-c:v&#x27;, &#x27;libx264&#x27;, &#xA;            &#x27;-b:v&#x27;, &#x27;800k&#x27;, &#xA;            &#x27;-an&#x27;, &#xA;            &#x27;-vf&#x27;, &#x27;showinfo&#x27;,&#xA;            &#x27;/tmp/test.h264&#x27;, &#xA;        ])&#xA;&#xA;    def stderr(self):&#xA;        self.currentLog &#x2B;= str(self.process.readAllStandardError(), &#x27;utf-8&#x27;)&#xA;        *lines, self.currentLog = self.currentLog.split(&#x27;\n&#x27;)&#xA;        for line in lines:&#xA;            print(&#x27;STDERR: {}&#x27;.format(line))&#xA;            match = re.search(logRegExp, line)&#xA;            if match:&#xA;                data = match.groupdict()&#xA;                self.frameDone.emit(int(data[&#x27;frame&#x27;]))&#xA;&#xA;    def run(self):&#xA;        font = QtGui.QFont()&#xA;        font.setPointSize(80)&#xA;        rect = QtCore.QRect(0, 0, self.width, self.height)&#xA;        for frame in range(1, self.frameCount &#x2B; 1):&#xA;            img = QtGui.QImage(QtCore.QSize(self.width, self.height), QtGui.QImage.Format_ARGB32)&#xA;            img.fill(QtCore.Qt.white)&#xA;            qp = QtGui.QPainter(img)&#xA;            qp.setFont(font)&#xA;            qp.setPen(QtCore.Qt.black)&#xA;            qp.drawText(rect, QtCore.Qt.AlignCenter, &#x27;Frame {}&#x27;.format(frame))&#xA;            qp.end()&#xA;            img.save(self.process, &#x27;PNG&#x27;)&#xA;        print(&#x27;frame creation complete&#x27;)&#xA;&#xA;&#xA;class Test(QtWidgets.QWidget):&#xA;    def __init__(self):&#xA;        super().__init__()&#xA;        layout = QtWidgets.QVBoxLayout(self)&#xA;        self.startButton = QtWidgets.QPushButton(&#x27;Start&#x27;)&#xA;        layout.addWidget(self.startButton)&#xA;&#xA;        self.frameLabel = QtWidgets.QLabel()&#xA;        layout.addWidget(self.frameLabel)&#xA;&#xA;        self.process = Encoder()&#xA;        self.process.completed.connect(lambda: self.startButton.setEnabled(True))&#xA;        self.process.frameDone.connect(self.frameLabel.setNum)&#xA;        self.startButton.clicked.connect(self.create)&#xA;&#xA;    def create(self):&#xA;        self.startButton.setEnabled(False)&#xA;        self.process.start()&#xA;&#xA;&#xA;import sys&#xA;app = QtWidgets.QApplication(sys.argv)&#xA;test = Test()&#xA;test.show()&#xA;sys.exit(app.exec_())&#xA;</time>

    &#xA;

    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 :

    &#xA;

        self.process.closeWriteChannel()&#xA;    self.process.waitForFinished()&#xA;    self.process.terminate()&#xA;

    &#xA;

    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.

    &#xA;

  • Discord bot stops playing music at a certain iteration

    3 mai 2023, par denisnumb

    I'm using the following code to play music in a discord voice channel :

    &#xA;

    import discord&#xA;import asyncio&#xA;from yt_dlp import YoutubeDL&#xA;&#xA;YDL_OPTIONS = {&#xA;    &#x27;format&#x27;: &#x27;bestaudio/best&#x27;, &#xA;}&#xA;&#xA;FFMPEG_OPTIONS = {&#xA;    &#x27;before_options&#x27;: &#x27;-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5&#x27;, &#xA;    &#x27;options&#x27;: &#x27;-vn&#x27;&#xA;}&#xA;&#xA;bot = discord.Client(intents=discord.Intents.all())&#xA;&#xA;async def get_source_url(url: str) -> str:&#xA;    with YoutubeDL(YDL_OPTIONS) as ydl:&#xA;        return ydl.extract_info(url, download=False).get(&#x27;url&#x27;)&#xA;&#xA;@bot.slash_command(name=&#x27;play&#x27;)&#xA;async def __play(ctx, url: str) -> None:&#xA;    source = await get_source_url(url)&#xA;    vc = await ctx.author.voice.channel.connect()&#xA;    vc.play(discord.FFmpegPCMAudio(source=source, **FFMPEG_OPTIONS))&#xA;&#xA;    while vc.is_playing() or vc.is_paused():&#xA;        await asyncio.sleep(1)&#xA;&#xA;    await vc.disconnect()&#xA;&#xA;bot.run(&#x27;TOKEN&#x27;)&#xA;

    &#xA;

    The principle of operation is as follows :

    &#xA;

      &#xA;
    1. The /play command handler receives a url argument, in the form of a link to a live stream from YouTube : https://youtu.be/jfKfPfyJRdk (or any other video)

      &#xA;

    2. &#xA;

    3. The link is passed to the get_source_url function, which, using the yt-dlp library, returns a direct link to the sound from the video

      &#xA;

    4. &#xA;

    5. The direct link is passed via discord.FFmpegPCMAudio to the ffmpeg program, which then returns audio bytes for transmission to the discord voice channel via the vc.play method

      &#xA;

    6. &#xA;

    &#xA;


    &#xA;

    Problem :

    &#xA;

    Bot is hosted on the virtual hosting server aeza, OS - Ubuntu Server 22.04. I installed the ffmpeg version 4.4.2 with the command sudo apt install ffmpeg.

    &#xA;

    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.

    &#xA;

    Only reinstalling the operating system helps, but also only for one day.

    &#xA;

    Specific problem :

    &#xA;

    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 the discord.FFmpegPCMAudio.read method, that is does not receive data from ffmpeg and waits indefinitely.

    &#xA;


    &#xA;

    Source of the problem :

    &#xA;

    The problem is not with a specific ffmpeg :

    &#xA;

      &#xA;
    • I also installed ffmpeg on another version 5.1.2 and the problem was repeated on it.
    • &#xA;

    &#xA;

    The problem is not Ubuntu Server :

    &#xA;

      &#xA;
    • I changed OS Ubuntu Server to Debian 11 and it's the same there
    • &#xA;

    &#xA;

    The problem is not in Linux :

    &#xA;

      &#xA;
    • When I put the same OS on my virtual machine, everything worked fine with any version of ffmpeg.
    • &#xA;

    &#xA;


    &#xA;

    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.

    &#xA;

    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.

    &#xA;

    What could be the problem ?

    &#xA;


    &#xA;

    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 ?

    &#xA;