Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (36)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

Sur d’autres sites (6933)

  • vlc python stream from other NAT

    7 octobre 2020, par xKedar

    I'm trying to stream, using FFmpeg, my webcam and audio from PC1 to PC2 in another LAN.

    


    PC1 : Public IP address with port forwarding so I can reach it

    


    PC2 : In a different NAT from PC1

    


    I basically run a server on PC1 in order to acquire IP and port from PC2 and reply on the same address

    


        import socket

    localPort   = 1234
    bufferSize  = 1024

    UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
    UDPServerSocket.bind(("", localPort)) # Bind to address and port

    while(True):
        bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
        message = bytesAddressPair[0].decode("utf-8")
        address = bytesAddressPair[1]
        # Sending a reply to client
        UDPServerSocket.sendto(str.encode("Hello"), address)
        break

    UDPServerSocket.close()


    


    Then I try to send the stream with the same port number both for the server(localPort) and the client(the one I acquired from address)

    


        import re
    from threading import Thread
    from subprocess import Popen, PIPE

    def detect_devices():
            list_cmd = 'ffmpeg -list_devices true -f dshow -i dummy'.split()
            p = Popen(list_cmd, stderr=PIPE)
            flagcam = flagmic = False
            for line in iter(p.stderr.readline,''):
                if flagcam:
                    cam = re.search('".*"',line.decode(encoding='UTF-8')).group(0)
                    cam = cam if cam else ''
                    flagcam = False
                if flagmic:
                    mic = re.search('".*"',line.decode(encoding='UTF-8')).group(0)
                    mic = mic if mic else ''
                    flagmic = False
                elif 'DirectShow video devices'.encode(encoding='UTF-8') in line:
                    flagcam = True
                elif 'DirectShow audio devices'.encode(encoding='UTF-8') in line:
                    flagmic = True
                elif 'Immediate exit requested'.encode(encoding='UTF-8') in line:
                    break
            return cam, mic   


    class ffmpegThread (Thread):
        def __init__(self, address):
            Thread.__init__(self)
            self.address = address

        def run(self):
            cam, mic = detect_devices()
            command = 'ffmpeg -f dshow -i video='+cam+':audio='+mic+' -profile:v high -pix_fmt yuvj420p -level:v 4.1 -preset ultrafast -tune zerolatency -vcodec libx264 -r 10 -b:v 512k -s 240x160 -acodec aac -ac 2 -ab 32k -ar 44100 -f mpegts -flush_packets 0 -t 40 udp://'+self.address+'?pkt_size=1316?localport='+str(localPort)
            p = Popen(command , stderr=PIPE)
            for line in iter(p.stderr.readline,''):
                if len(line) <5: break
            p.terminate()

    thread1 = ffmpegThread(address[0]+":"+str(address[1]))
    thread1.start()


    


    While on the other side(PC2) I have :

    


        from threading import Thread
    import tkinter as tk
    import vlc

    class myframe(tk.Frame):
        def __init__(self, width=240, height=160):
            self.root = tk.Tk()
            super(myframe, self).__init__(self.root)
            self.root.geometry("%dx%d" % (width, height))
            self.root.wm_attributes("-topmost", 1)
            self.grid()
            self.frame = tk.Frame(self, width=240, height=160)
            self.frame.configure(bg="black")
            self.frame.grid(row=0, column=0, columnspan=2)
            self.play()
            self.root.mainloop()

        def play(self):
            self.player = vlc.Instance().media_player_new()
            self.player.set_mrl('udp://@0.0.0.0:5000')
            self.player.set_hwnd(self.frame.winfo_id())
            self.player.play()

    class guiThread (Thread):
        def __init__(self, nome):
            Thread.__init__(self)
            self.nome = nome

        def run(self):
            app = myframe()


    


    and :

    


        import socket

    msgFromClient       = "Hello UDP Server"
    bytesToSend         = str.encode(msgFromClient)
    serverAddressPort   = ("MYglobal_IPaddress", 1234)
    bufferSize          = 1024
    localPort   = 5000

    # Create a UDP socket at client side
    UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) 
    UDPClientSocket.bind(("", localPort))

    UDPClientSocket.sendto(bytesToSend, serverAddressPort)

    msgFromServer = UDPClientSocket.recvfrom(bufferSize)
    msg = msgFromServer[0].decode("utf-8")
    print(msg)
    UDPClientSocket.close()
    gui = guiThread("ThreadGUI")
    gui.start()


    


    Where I basically try to reach the server both to send my IP:Port and to punch a hole in the NAT in order to be able to get the packages sent from PC1 despite being behind a NAT.

    


    I guess this is not working because I can not get the stream to work but I really can not figure out how to fix that

    


  • FFmpeg streaming UDP

    2 octobre 2020, par xKedar

    I'm trying to stream, using FFmpeg, my webcam and audio to a PC in another LAN that connects to mine.

    


    I basically wait for incoming connection in order to acquire IP and port of the other side

    


        import socket

    localPort   = 1234
    bufferSize  = 1024

    UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
    UDPServerSocket.bind(("", localPort)) # Bind to address and port

    while(True):
        bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
        message = bytesAddressPair[0].decode("utf-8")
        address = bytesAddressPair[1]
        # Sending a reply to client
        UDPServerSocket.sendto(str.encode("Hello"), address)
        break

    UDPServerSocket.close()


    


    Then I try to send the stream with FFmpeg using the same port number both for server(localPort) and client(the one I acquired from address)

    


        import re
    from threading import Thread
    from subprocess import Popen, PIPE

    def detect_devices():
            list_cmd = 'ffmpeg -list_devices true -f dshow -i dummy'.split()
            p = Popen(list_cmd, stderr=PIPE)
            flagcam = flagmic = False
            for line in iter(p.stderr.readline,''):
                if flagcam:
                    cam = re.search('".*"',line.decode(encoding='UTF-8')).group(0)
                    cam = cam if cam else ''
                    flagcam = False
                if flagmic:
                    mic = re.search('".*"',line.decode(encoding='UTF-8')).group(0)
                    mic = mic if mic else ''
                    flagmic = False
                elif 'DirectShow video devices'.encode(encoding='UTF-8') in line:
                    flagcam = True
                elif 'DirectShow audio devices'.encode(encoding='UTF-8') in line:
                    flagmic = True
                elif 'Immediate exit requested'.encode(encoding='UTF-8') in line:
                    break
            return cam, mic   


    class ffmpegThread (Thread):
        def __init__(self, address):
            Thread.__init__(self)
            self.address = address

        def run(self):
            cam, mic = detect_devices()
            command = 'ffmpeg -f dshow -i video='+cam+':audio='+mic+' -profile:v high -pix_fmt yuvj420p -level:v 4.1 -preset ultrafast -tune zerolatency -vcodec libx264 -r 10 -b:v 512k -s 240x160 -acodec aac -ac 2 -ab 32k -ar 44100 -f mpegts -flush_packets 0 -t 40 udp://'+self.address+'?pkt_size=1316?localport='+str(localPort)
            p = Popen(command , stderr=PIPE)
            for line in iter(p.stderr.readline,''):
                if len(line) <5: break
            p.terminate()

    thread1 = ffmpegThread(address[0]+":"+str(address[1]))
    thread1.start()


    


    While on the other side I have :

    


        from threading import Thread
    import tkinter as tk
    import vlc

    class myframe(tk.Frame):
        def __init__(self, width=240, height=160):
            self.root = tk.Tk()
            super(myframe, self).__init__(self.root)
            self.root.geometry("%dx%d" % (width, height))
            self.root.wm_attributes("-topmost", 1)
            self.grid()
            self.frame = tk.Frame(self, width=240, height=160)
            self.frame.configure(bg="black")
            self.frame.grid(row=0, column=0, columnspan=2)
            self.play()
            self.root.mainloop()

        def play(self):
            self.player = vlc.Instance().media_player_new()
            self.player.set_mrl('udp://@0.0.0.0:5000')
            self.player.set_hwnd(self.frame.winfo_id())
            self.player.play()

    class guiThread (Thread):
        def __init__(self, nome):
            Thread.__init__(self)
            self.nome = nome

        def run(self):
            app = myframe()


    


    and :

    


        import socket

    msgFromClient       = "Hello UDP Server"
    bytesToSend         = str.encode(msgFromClient)
    serverAddressPort   = ("MYglobal_IPaddress", 1234)
    bufferSize          = 1024
    localPort   = 5000

    # Create a UDP socket at client side
    UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) 
    UDPClientSocket.bind(("", localPort))

    UDPClientSocket.sendto(bytesToSend, serverAddressPort)

    msgFromServer = UDPClientSocket.recvfrom(bufferSize)
    msg = msgFromServer[0].decode("utf-8")
    print(msg)
    UDPClientSocket.close()
    gui = guiThread("ThreadGUI")
    gui.start()


    


    I'm not able to reach the client with the stream. I tested everything else so the problem should be in the way I try to reach the client

    


  • Capturing Screen with FFMPEG on RTP protocol

    23 septembre 2020, par mertakkartal

    I am struggling about capturing the screen of remote computer on the same network with ffmpeg on RTP protocol.

    


    On the remote computer I run these two parameter blocks in different bash scripts for making the server catches the stream.

    


    For video :

    


    ffmpeg -f x11grab -framerate 25 -video_size uhd2160 -i :0.0 -c:video h264_nvenc -preset fast -pix_fmt bgr0 -b:v 6M -g 25 -an -f rtp_mpegts rtp://multicastaddress:videoPort

    


    For Audio :

    


    ffmpeg -f alsa -i hw:0,0 -c:audio aac -b:a 48K -f rtp_mpegts rtp://multicastaddress:audioPort

    


    Then , I run my ffmpeg capturing screen parameter block from the server as root privilege like as below :

    


    ffmpeg -y -buffer_size 425984 -thread_queue_size 32 -i rtp://@multicastaddress:videoPort -buffer_size 5000 -thread_queue_size 32 -i rtp://@multicastaddress:audioPort -map 0:0 -map 1:0 -c:v copy -c:a copy output.mp4

    


    When I run it , it outputs those errors as below ,

    


    [rtp @ 0x2329380] RTP: missed 284 packets
[rtp @ 0x2329380] RTP: missed 487 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1320.4kbits/s speed=1.27x    
[rtp @ 0x2329380] RTP: missed 2204 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1308.9kbits/s speed=1.24x    
[rtp @ 0x2329380] RTP: missed 300 packets
[rtp @ 0x2329380] max delay reached. need to consume packet
[rtp @ 0x2329380] RTP: missed 468 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1155.6kbits/s speed= 1.2x    
[rtp @ 0x2329380] RTP: missed 2222 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1197.0kbits/s speed=1.19x    
[rtp @ 0x2329380] RTP: missed 278 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1156.1kbits/s speed=1.18x    
[rtp @ 0x2329380] RTP: missed 303 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1064.8kbits/s speed=1.32x    
[rtp @ 0x2329380] RTP: missed 3 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1064.8kbits/s speed=1.17x    
[rtp @ 0x2329380] RTP: missed 280 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1095.4kbits/s speed=1.16x    
[rtp @ 0x2329380] RTP: missed 1737 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1084.1kbits/s speed=1.15x    
[rtp @ 0x2329380] RTP: missed 485 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1142.9kbits/s speed=1.14x    
[rtp @ 0x2329380] RTP: missed 767 packets
[rtp @ 0x2329380] max delay reached. need to consume packet
[rtp @ 0x2329380] RTP: missed 3 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1080.6kbits/s speed=1.14x    
[rtp @ 0x2329380] RTP: missed 1562 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1063.9kbits/s speed=1.13x    
[rtp @ 0x2329380] RTP: missed 282 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1065.8kbits/s speed=1.12x    
[rtp @ 0x2329380] RTP: missed 1 packets
[rtp @ 0x2329380] max delay reached. need to consume packet
[rtp @ 0x2329380] RTP: missed 771 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1024.3kbits/s speed=1.11x    
[rtp @ 0x2329380] RTP: missed 1731 packets
[rtp @ 0x2329380] max delay reached. need to consume packet bitrate=1019.1kbits/s speed=1.11x    
[rtp @ 0x2329380] RTP: missed 298 packets

frame=  453 fps=8.9 q=-1.0 Lsize= 7397kB time=00:00:56.60 bitrate=1070.6kbits/s speed=1.11x


    


    After checking the video output with mpv player or ffplay ,I can observe that parameters from server caught the stream but mostly with lost packets so there are distortions in the video output file.

    


    I tried protocol_whitelist "file,rtp,udp" for preventing packet loss but it did not work out unfortunately.

    


    Any other parameter for solving this issue ?