Recherche avancée

Médias (91)

Autres articles (27)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (3863)

  • Discord music bot doesn't play songs

    9 octobre 2023, par Gam3rsCZ

    I have made myself a discord bot that also plays music(it's only for my server so strings with messages are in Czech, but code is in English).
Bot worked a while ago but now it stopped, and I don't know where the problem is

    


    I'm getting these errors : HTTP error 403 Forbidden Server returned 403 Forbidden (access denied) and
C :\Users\Me\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\player.py:711 : RuntimeWarning : coroutine 'music_cog.play_next' was never awaited
self.after(error)
RuntimeWarning : Enable tracemalloc to get the object allocation traceback
[2023-10-09 16:23:47] [INFO ] discord.player : ffmpeg process 17496 successfully terminated with return code of 1.
INFO : ffmpeg process 17496 successfully terminated with return code of 1.

    


    My code is :

    


    import discord
from discord.ext import commands
from yt_dlp import YoutubeDL

class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

        self.is_playing = False
        self.is_paused = False
        self.current = ""

        self.music_queue = []
        self.YDL_OPTIONS = {"format": "m4a/bestaudio/best", "noplaylist": "True"}
        self.FFMPEG_OPTIONS = {"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", "options": "-vn"}

        self.vc = None

    def search_yt(self, item):
        with YoutubeDL(self.YDL_OPTIONS) as ydl:
            try:
                info = ydl.extract_info("ytsearch:%s" % item, download=False)["entries"][0]
            except Exception:
                return False
        info = ydl.sanitize_info(info)
        url = info['url']
        title = info['title']
        return {'title': title, 'source': url}

    async def play_next(self):
        if len(self.music_queue) > 0:
            self.is_playing = True
            self.current = self.music_queue[0][0]["title"]
            m_url = self.music_queue[0][0]["source"]

            self.music_queue.pop(0)

            await self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e:  self.play_next())
        else:
            self.is_playing = False

    async def play_music(self, ctx):
        try:
            if len(self.music_queue) > 0:
                self.is_playing = True
                m_url = self.music_queue[0][0]["source"]

                if self.vc == None or not self.vc.is_connected():
                    self.vc =  await self.music_queue[0][1].connect()

                    if self.vc == None:
                        await ctx.send("Nepodařilo se připojit do hlasového kanálu.")
                        return
                else:
                    await self.vc.move_to(self.music_queue[0][1])

                self.current = self.music_queue[0][0]["title"]
                self.music_queue.pop(0)

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

        except:
            print("Something went wrong")
            await ctx.send(content="Něco se pokazilo")

    @commands.command(name="play", help="Plays selected song from YouTube")
    async def play(self, ctx, *args):
        query = " ".join(args)

        voice_channel = ctx.author.voice.channel
        if voice_channel is None:
            await ctx.send("Připojte se do hlasového kanálu!")
        elif self.is_paused:
            self.vc.resume()
        else:
            song = self.search_yt(query)
            if type(song) == type(True):
                await ctx.send("Písničku se nepodařilo stáhnout. Špatný formát, možná jste se pokusili zadat playlist nebo livestream.")
            else:
                await ctx.send("Písnička přidána do řady.")
                self.music_queue.append([song, voice_channel])

                if self.is_playing == False:
                    await self.play_music(ctx)
                    self.is_playing = True

    @commands.command(name="pause", aliases=["p"], help="Pauses the BOT")
    async def pause(self, ctx, *args):
        if self.is_playing:
            self.is_playing = False
            self.is_paused = True
            self.vc.pause()
            await ctx.send(content="Písnička byla pozastavena.")
            
        elif self.is_paused:
            self.is_playing = True
            self.is_paused = False
            self.vc.resume()
            await ctx.send(content="Písnička byla obnovena.")

    @commands.command(name="resume", aliases=["r"], help="Resumes playing")
    async def resume(self, ctx, *args):
        if self.is_paused:
            self.is_paused = False
            self.is_playing = True
            self.vc.resume()
            await ctx.send(content="Písnička byla obnovena.")

    @commands.command(name="skip", aliases=["s"], help="Skips current song")
    async def skip(self, ctx, *args):
        if self.vc != None and self.vc:
            self.vc.stop()
        await self.play_next()
        await ctx.send(content="Písnička byla přeskočena.")

    @commands.command(name="queue", aliases=["q"], help="Displays song queue")
    async def queue(self, ctx, songs=5):
        retval = ""

        for i in range(0, len(self.music_queue)):
            if i > songs: break
            retval += "    " + self.music_queue[i][0]["title"] + "\n"

        if retval != "":
            retval += "```"
            await ctx.send(content=("```Aktuální fronta:\n" + retval))
        else:
            await ctx.send("Řada je prázdná.")

    @commands.command(name="clear", help="Clears the queue")
    async def clear(self, ctx):
        if self.vc != None and self.is_playing:
            self.vc.stop()
        self.music_queue = []
        await ctx.send("Řada byla vymazána.")

    @commands.command(name="leave", aliases=["dc", "disconnect"], help="Disconnects the BOT")
    async def leave(self, ctx):
        self.is_playing = False
        self.is_paused = False

        if self.vc != None:
            return await self.vc.disconnect(), await ctx.send(content="BOT byl odpojen.")

        else:
            return await ctx.send("BOT není nikde připojen.")
   
    @commands.command(name="current", help="Displays the current song")
    async def current(self, ctx):
        current = self.current
        retval = f"```Právě hraje:\n    {current}```"
        if current != "":
            await ctx.send(retval)
        else:
            await ctx.send("Aktuálně nic nehraje.")


    


    I already tried everything I can think of(which isn't a lot because I suck at programming), and also tried searching for some solution on the internet, but nothing worked.

    


  • After merge videos, the duration is too long - ffmpeg

    20 février 2017, par Thanh Dao

    I have file txt with content

    file intro.mp4
    file video.mp4
    file outtro.mp4

    with duration by 10s, 178s, 13s.

    I use ffmpeg to merge 3 files into one with below command :

    ffmpeg -f concat -i "file.txt" -vcodec copy -acodec copy "endfile.mp4"

    The duration of endfile.mp4 is longer 11 mins (660s).

    I have a question that which params of video affect to merge? And which common params to merge another videos?

    My English really too bad. Sorry for it :)
    Good working this week !

    P/S Details infor of files :

    intro.mp4 :

    ffprobe version N-82885-g6d09d6e Copyright (c) 2007-2016 the FFmpeg developers<br />
       built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)<br />
       configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --<br />bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame<br /> --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265<br />
       libavutil      55. 43.100 / 55. 43.100<br />
       libavcodec     57. 68.100 / 57. 68.100<br />
       libavformat    57. 61.100 / 57. 61.100<br />
       libavdevice    57.  2.100 / 57.  2.100<br />
       libavfilter     6. 68.100 /  6. 68.100<br />
       libswscale      4.  3.101 /  4.  3.101<br />
       libswresample   2.  4.100 /  2.  4.100<br />
       libpostproc    54.  2.100 / 54.  2.100<br />
     Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/intro.mp4':<br />
       Metadata:<br />
       major_brand     : isom<br />
       minor_version   : 512<br />
       compatible_brands: isomiso2avc1mp41<br />
       encoder         : Lavf56.23.100<br />
     Duration: 00:00:10.08, start: -0.013061, bitrate: 701 kb/s<br />
       Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)<br />
       Metadata:<br />
       handler_name    : SoundHandler<br />
       Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 853 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)<br />
     Metadata:<br />
       handler_name    : VideoHandler<br />

    outtro.mp4 :

    ffprobe version N-82885-g6d09d6e Copyright (c) 2007-2016 the FFmpeg developers<br />
       built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)<br />
       configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --<br />bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame<br /> --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265<br />
       libavutil      55. 43.100 / 55. 43.100<br />
       libavcodec     57. 68.100 / 57. 68.100<br />
       libavformat    57. 61.100 / 57. 61.100<br />
       libavdevice    57.  2.100 / 57.  2.100<br />
       libavfilter     6. 68.100 /  6. 68.100<br />
       libswscale      4.  3.101 /  4.  3.101<br />
       libswresample   2.  4.100 /  2.  4.100<br />
       libpostproc    54.  2.100 / 54.  2.100<br />
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/outtro.mp4':<br />
    Metadata:<br />
       major_brand     : isom<br />
       minor_version   : 512<br />
       compatible_brands: isomiso2avc1mp41<br />
       encoder         : Lavf56.23.100<br />
    Duration: 00:00:13.08, start: -0.013061, bitrate: 481 kb/s<br />
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)<br />
    Metadata:<br />
       handler_name    : SoundHandler<br />
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 392 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)<br />
    Metadata:<br />
       handler_name    : VideoHandler<br />

    video.mp4

    ffprobe version N-82885-g6d09d6e Copyright (c) 2007-2016 the FFmpeg developers<br />
       built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)<br />
       configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --<br />bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame<br /> --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265<br />
       libavutil      55. 43.100 / 55. 43.100<br /><br />
       libavcodec     57. 68.100 / 57. 68.100<br /><br />
       libavformat    57. 61.100 / 57. 61.100<br /><br />
       libavdevice    57.  2.100 / 57.  2.100<br /><br />
       libavfilter     6. 68.100 /  6. 68.100<br /><br />
       libswscale      4.  3.101 /  4.  3.101<br /><br />
       libswresample   2.  4.100 /  2.  4.100<br /><br />
       libpostproc    54.  2.100 / 54.  2.100<br /><br />
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'path/to/video.mp4':<br />
       Metadata:<br />
           major_brand     : isom<br />
           minor_version   : 512<br />
           compatible_brands: isomiso2avc1mp41<br />
           encoder         : Lavf57.61.100<br />
       Duration: 00:02:58.38, start: 0.000000, bitrate: 922 kb/s<br />
           Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 782 kb/s, 29.97 fps, 29.97 tbr, 30k <br />tbn, 59.94 tbc (default)<br />
           Metadata:<br />
               handler_name    : VideoHandler<br />
           Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s (default)<br />
           Metadata:<br />
               handler_name    : SoundHandler<br />
  • MPEG-DASH - Multiplexed Representations Issue

    26 avril 2017, par Mike

    I’m trying to learn ffmpeg, MP4Box, and MPEG-DASH, but I’m running into an issue with the .mp4 I’m using. I’m using ffmpeg to demux the mp4 with this command :

    ffmpeg -i test.mp4 -c:v copy -g 72 -an video.mp4 -c:a copy audio.mp4

    Once the two files are created, I use MP4Box to segment the files for the dash player using this command :

    MP4Box -dash 4000 -frag 1000 -rap -segment-name segment_ output.mp4

    Which does create all the files I think I need. Then I point the player to the output_dash.mpd and nothing happens except a ton of messages in the console :

    [8] EME detected on this user agent! (ProtectionModel_21Jan2015)
    [11] Playback Initialized
    [21] [dash.js 2.3.0] MediaPlayer has been initialized
    [64] Parsing complete: ( xml2json: 3.42ms, objectiron: 2.61ms, total: 0.00603s)
    [65] Manifest has been refreshed at Wed Apr 12 2017 12:16:52 GMT-0600 (MDT)[1492021012.196]  
    [72] MediaSource attached to element.  Waiting on open...
    [77] MediaSource is open!
    [77] Duration successfully set to: 148.34
    [78] Added 0 inline events
    [78] No video data.
    [79] No audio data.
    [79] No text data.
    [79] No fragmentedText data.
    [79] No embeddedText data.
    [80] Multiplexed representations are intentionally not supported, as they are not compliant with the DASH-AVC/264 guidelines
    [81] No streams to play.

    Here is the MP4Box -info on the video I’m using :

    * Movie Info *
       Timescale 1000 - Duration 00:02:28.336
       Fragmented File no - 2 track(s)
       File suitable for progressive download (moov before mdat)
       File Brand mp42 - version 512
       Created: GMT Wed Feb  6 06:28:16 2036

    File has root IOD (9 bytes)
    Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
    Visual PL: Not part of MPEG-4 Visual profiles (0xfe)
    Audio PL: Not part of MPEG-4 audio profiles (0xfe)
    No streams included in root OD

    iTunes Info:
       Name: Rogue One - A Star Wars Story
       Artist: Lucasfilm
       Genre: Trailer
       Created: 2016
       Encoder Software: HandBrake 0.10.2 2015060900
       Cover Art: JPEG File

    Track # 1 Info - TrackID 1 - TimeScale 90000 - Duration 00:02:28.335
    Media Info: Language "Undetermined" - Type "vide:avc1" - 3552 samples
    Visual Track layout: x=0 y=0 width=1920 height=816
    MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
    AVC/H264 Video - Visual Size 1920 x 816
       AVC Info: 1 SPS - 1 PPS - Profile High @ Level 4.1
       NAL Unit length bits: 32
       Pixel Aspect Ratio 1:1 - Indicated track size 1920 x 816
    Self-synchronized

    Track # 2 Info - TrackID 2 - TimeScale 44100 - Duration 00:02:28.305
    Media Info: Language "English" - Type "soun:mp4a" - 6387 samples
    MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
    MPEG-4 Audio MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
    Synchronized on stream 1
    Alternate Group ID 1

    I know I need to separate the video and audio and I think that’s where my issue is. The command I’m using probably isn’t doing the right thing.

    Is there a better command to demux my mp4 ?
    Is the MP4Box command I’m using best for segmenting the files ?
    If I use different files, will they always need to be demuxed ?

    One thing to mention, if I use the following commands everything works fine, but there is no audio because of the -an which means it’s only video :

    ffmpeg -i test.mp4 -c:v copy -g 72 -an output.mp4

    MP4Box -dash 4000 -frag 1000 -rap -segment-name segment_ output.mp4

    UPDATE

    I noticed that the video had no audio stream, but the audio had the video stream which is why I got the mux error. I thought that might be an issue so I ran this command to keep the unwanted streams out of the outputs :

    ffmpeg -i test.mp4 -c:v copy -g 72 -an video.mp4 -c:a copy -vn audio.mp4

    then I run :

    MP4Box -dash 4000 -frag 1000 -rap -segment-name segment_ video.mp4 audio.mp4

    now I no longer get the Multiplexed representations are intentionally not supported... message, but now I get :

    [122] Video Element Error: MEDIA_ERR_SRC_NOT_SUPPORTED
    [123] [object MediaError]
    [125] Schedule controller stopping for audio
    [126] Caught pending play exception - continuing (NotSupportedError: Failed to load because no supported source was found.)

    I tried playing the video and audio independently through Chrome and they both work, just not through the dash player. Ugh, this is painful to learn, but I feel like I’m making progress.