Recherche avancée

Médias (1)

Mot : - Tags -/publishing

Autres articles (52)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • 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 (...)

Sur d’autres sites (11485)

  • Discord FFMPEG audio wont play from yt-dlp

    19 mars 2023, par user21236822

    My question is this : Why isn't my bot playing audio ?

    


    I want the bot to join, play audio from queue, then disconnect without downloading an mp3 file.

    


    I tried using youtube-dl, but I switched to the yt-dlp library after getting errors I couldn't fix.
I am running on Windows 10 locally. All my libraries are up to date.

    


    Here are my ydl_opts and FFMPEG_OPTS :

    


    ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }],
}

FFMPEG_OPTIONS = {
    'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
    'options': '-vn'
} 


    


    Here is where I believe the problem is.

    


    async def play():
    print("Play Called")
    musicPlay()
    # Get message object from initial request
    message = ytLinkQue.get()
    print(f"Message object recieved: {message}")
    voiceChannel = message.author.voice.channel
    vc = await voiceChannel.connect()
    songsPlayed = 0
    
    while not ytLinkQue.empty():
        # Get current song
        currentSong = ytLinkQue.get()[0]
        print(f"Current song: {currentSong}")

        # Get song from Youtube
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            # song = ydl.download(currentSong)
            info = ydl.extract_info(currentSong, download=False)
            song = info['formats'][0]['url']

        # Play Song
        vc.play(discord.FFmpegPCMAudio(song, **FFMPEG_OPTIONS), after=lambda e: print('Song done'))

        # Wait until the song has finished playing
        while vc.is_playing():
            print("playing rn")
            await asyncio.sleep(1)
    
    await vc.disconnect()
    musicStop()


    


    When play() is called, here is the output in terminal with my annotations as **** text **** :

    


    >python main.py&#xA;2023-02-17 15:21:09 INFO     discord.client logging in using static token&#xA;2023-02-17 15:21:10 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 60b9fce14faa5daa4aed9eb6db01a74d).&#xA;Max que: 50&#xA;Text Channel: 828698708123451434&#xA;Testing Bot#4591 is ready.&#xA;Passing message object&#xA;**** play() funciton is called ****&#xA;Play Called&#xA;Message object recieved: <message channel="<TextChannel" position="7" nsfw="False" news="False"> type= author=<member discriminator="&#x27;0199&#x27;" bot="False" nick="&#x27;Fragnk7?&#x27;" guild="<Guild" chunked="True">> flags=<messageflags value="0">>&#xA;2023-02-17 15:21:16 INFO     discord.voice_client Connecting to voice...&#xA;2023-02-17 15:21:16 INFO     discord.voice_client Starting voice handshake... (connection attempt 1)&#xA;2023-02-17 15:21:17 INFO     discord.voice_client Voice handshake complete. Endpoint found seattle2004.discord.media&#xA;Current song: https://www.youtube.com/watch?v=vcAp4nmTZCA&#xA;[youtube] Extracting URL: https://www.youtube.com/watch?v=vcAp4nmTZCA &#xA;[youtube] vcAp4nmTZCA: Downloading webpage &#xA;[youtube] vcAp4nmTZCA: Downloading android player API JSON &#xA;**** Does not play any audio ****&#xA;Playing rn&#xA;Song done&#xA;2023-02-17 15:21:18 INFO     discord.player ffmpeg process 20700 successfully terminated with return code of 1.&#xA;2023-02-17 15:21:19 INFO     discord.voice_client The voice handshake is being terminated for Channel ID 400178308467392513 (Guild ID 261601676941721602)&#xA;2023-02-17 15:21:19 INFO     discord.voice_client Disconnecting from voice normally, close code 1000.&#xA;</messageflags></member></message>

    &#xA;

    On Discord's end, the bot successfully connects then disconnects after 2 second.

    &#xA;

    Note : I've only included code I think is relevant. Please let me know if I should add anything else to the post, otherwise, here is the github for the project. Code is in main.py.&#xA;https://github.com/LukeLeimbach/wallMomentMusic

    &#xA;

    Thank you in advance !

    &#xA;

    I've applied the advice from these posts but it still will not play audio :

    &#xA;

    -https://stackoverflow.com/questions/45770016/how-do-i-make-my-discord-bot-play-audio-from-youtube

    &#xA;

    -https://stackoverflow.com/questions/66070749/how-to-fix-discord-music-bot-that-stops-playing-before-the-song-is-actually-over?newreg=c70dd786cf5844e490045494223c0381

    &#xA;

    -https://stackoverflow.com/questions/57688808/playing-music-with-a-bot-from-youtube-without-downloading-the-file

    &#xA;

  • raw images to mp4 video with ffmpeg or cv2 fails with most codecs

    21 février 2023, par Hi_its_me

    I have a couple of numpy image frames (np.uint8, 4 in total) and want to create a mp4 file. So far so easy, it works fine with the mpv4 codec. But that codec compresses the files too much so that a lot of visual quality gets lost. So I tried a thousand of different codecs (h264, h265, av1, vp9 and others) and also other data formats (.mkv, .avi). I tried it with cv2.VideoWriter, skvideo.io.FFmpegWriter and ffmpeg-python. but no matter what I do, the video is either completely or only partially corrupted (approx the last quater of frames).&#xA;I use VLC media player to check the files. I don't understand what's going on here. I don't get any error messages. Strangely, sometimes, windows standard video player is able to read the video. So the frames are not always completely corrupted.

    &#xA;

    The skvideo code :

    &#xA;

    def to_lossless_mp4(img_list: np.array, target_path):&#xA;    height, width, _ = img_list[0].shape&#xA;    writer = skvideo.io.FFmpegWriter(target_path,&#xA;                                     inputdict={&#xA;                                         &#x27;-framerate&#x27;: str(FPS),&#xA;                                         &#x27;-f&#x27;: &#x27;rawvideo&#x27;,&#xA;                                         &#x27;-s&#x27;: &#x27;{}x{}&#x27;.format(width, height)&#xA;                                     },&#xA;                                     outputdict={&#xA;                                         &#x27;-vcodec&#x27;: &#x27;libx265&#x27;,  # h.264 codec&#xA;                                         &#x27;-crf&#x27;: &#x27;0&#x27;,  &#xA;                                         &#x27;-preset&#x27;: &#x27;veryslow&#x27;,  # the slower the better compression&#xA;                                         &#x27;-framerate&#x27;: str(FPS),&#xA;                                     })&#xA;    for i, image in enumerate(img_list):&#xA;        # some images are grayscale, since all frames need to be same size I do this:&#xA;        if len(image.shape) &lt; 3:&#xA;            image = np.stack([image] * 3, axis=2)&#xA;&#xA;        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)&#xA;        writer.writeFrame(image)&#xA;    writer.close()&#xA;

    &#xA;

    the cv2 code :

    &#xA;

    def to_mp4(img_list: np.array, target_path):&#xA;    height, width, _ = img_list[0].shape&#xA;    if OVERRIDE or not os.path.exists(target_path):&#xA;        out = cv2.VideoWriter(target_path, cv2.VideoWriter_fourcc(*&#x27;x265&#x27;), FPS, (width, height))&#xA;&#xA;        for image in img_list:&#xA;            if len(image.shape) &lt; 3:&#xA;                image = np.stack([image] * 3, axis=2)&#xA;            image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)&#xA;            out.write(image)&#xA;        out.release()&#xA;

    &#xA;

    the ffmpeg-python code :

    &#xA;

    def to_mp4(fn, images, framerate=1, vcodec=&#x27;libx264&#x27;):&#xA;    if not isinstance(images, np.ndarray):&#xA;        images = np.asarray(images)&#xA;    n, height, width, channels = images.shape&#xA;    process = (&#xA;        ffmpeg&#xA;        .input(&#x27;pipe:&#x27;, format=&#x27;rawvideo&#x27;, pix_fmt=&#x27;rgb24&#x27;, s=&#x27;{}x{}&#x27;.format(width, height))&#xA;        .output(fn, pix_fmt=&#x27;yuv420p&#x27;, vcodec=vcodec, r=framerate)&#xA;        .run_async(pipe_stdin=True)&#xA;        .overwrite_output()&#xA;        )&#xA;    for frame in images:&#xA;        if len(frame.shape) &lt; 3:&#xA;            frame = np.stack([frame] * 3, axis=2)&#xA;        process.write(&#xA;            frame&#xA;            .astype(np.uint8)&#xA;            .tobytes()&#xA;        )&#xA;    process.stdin.close()&#xA;    process.wait()&#xA;

    &#xA;

    edit : this is the output when I use the code proposed by Rotem :

    &#xA;

    [00:00&lt;?, ?it/s]ffmpeg version 2.7 Copyright (c) 2000-2015 the FFmpeg developers&#xA;  built with gcc 4.9.2 (GCC)&#xA;  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib&#xA;  libavutil      54. 27.100 / 54. 27.100&#xA;  libavcodec     56. 41.100 / 56. 41.100&#xA;  libavformat    56. 36.100 / 56. 36.100&#xA;  libavdevice    56.  4.100 / 56.  4.100&#xA;  libavfilter     5. 16.101 /  5. 16.101&#xA;  libswscale      3.  1.101 /  3.  1.101&#xA;  libswresample   1.  2.100 /  1.  2.100&#xA;  libpostproc    53.  3.100 / 53.  3.100&#xA;[rawvideo @ 00000000051767c0] Stream #0: not enough frames to estimate rate; consider increasing probesize&#xA;Input #0, rawvideo, from &#x27;pipe:&#x27;:&#xA;  Duration: N/A, start: 0.000000, bitrate: 75497 kb/s&#xA;    Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 2048x1536, 75497 kb/s, 1 tbr, 1 tbn, 1 tbc&#xA;x265 [info]: HEVC encoder version 1.7&#xA;x265 [info]: build info [Windows][GCC 4.9.2][64 bit] 8bpp&#xA;x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2&#xA;x265 [info]: Main profile, Level-5 (Main tier)&#xA;x265 [info]: Thread pool created using 16 threads&#xA;x265 [info]: frame threads / pool features       : 5 / wpp(24 rows)&#xA;x265 [info]: Coding QT: max CU size, min CU size : 64 / 8&#xA;x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra&#xA;x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2&#xA;x265 [info]: Keyframe min / max / scenecut       : 1 / 250 / 40&#xA;x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2&#xA;x265 [info]: b-pyramid / weightp / weightb / refs: 1 / 1 / 0 / 3&#xA;x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 64 / 1&#xA;x265 [info]: Rate Control / qCompress            : CRF-24.0 / 0.60&#xA;x265 [info]: tools: rd=3 psy-rd=0.30 signhide tmvp strong-intra-smoothing&#xA;x265 [info]: tools: deblock sao&#xA;Output #0, mp4, to &#x27;C:datamerged_datatestsubsubsub2022-10-12_11-03-44_3583968045500ns_io.mp4&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf56.36.100&#xA;    Stream #0:0: Video: hevc (libx265) ([35][0][0][0] / 0x0023), yuv420p, 2048x1536, q=2-31, 1 fps, 16384 tbn, 1 tbc&#xA;    Metadata:&#xA;      encoder         : Lavc56.41.100 libx265&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))&#xA;frame=    4 fps=0.0 q=0.0 Lsize=     761kB time=00:00:02.00 bitrate=3117.4kbits/s    &#xA;video:759kB audio:0kB subtitle:0kB other streams:0kB global headers:1kB muxing overhead: 0.236524%&#xA;x265 [info]: frame I:      2, Avg QP:13.55  kb/s: 2078.50 &#xA;x265 [info]: frame P:      1, Avg QP:15.08  kb/s: 1560.14 &#xA;x265 [info]: frame B:      1, Avg QP:18.28  kb/s: 502.67  &#xA;x265 [info]: global :      4, Avg QP:15.11  kb/s: 1554.95 &#xA;x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%&#xA;x265 [info]: consecutive B-frames: 66.7% 33.3% 0.0% 0.0% 0.0% &#xA;

    &#xA;

  • How to change `yuv420p(progressive)` to `yuv420p(tv, progressive)` ?

    8 mars 2023, par Roy

    I have a video in.mp4 :

    &#xA;

    Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 375 kb/s, 30 fps, 30 tbr, 15360 tbn (default)&#xA;

    &#xA;

    I want to convert it into the following spec (need to change the time-base and also add an empty audio) :

    &#xA;

    Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 20744 kb/s, 30 fps, 30 tbr, 30k tbn (default)&#xA;Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)&#xA;

    &#xA;

    Currently I'm using this ffmpeg command :

    &#xA;

    ffmpeg -f lavfi -i anullsrc -i in.mp4 -c:v libx264 -pix_fmt yuv420p -profile:v main -video_track_timescale 30k -c:a aac -map 0:a -map 1:v -shortest out.mp4&#xA;

    &#xA;

    The output out.mp4

    &#xA;

    Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)&#xA;Stream #0:1[0x2](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 27 kb/s, 30 fps, 30 tbr, 30k tbn (default)&#xA;

    &#xA;

    As you can see, the output audio stream matches what I wanted. But the output video stream is missing the "tv" part in the "yuv420p(tv, progressive)" spec.

    &#xA;

    How do I add back the "tv" part in the "yuv420p(tv, progressive)" spec ?

    &#xA;

    My misc assumptions :

    &#xA;

      &#xA;
    • In the output, the order of audio and video stream are changed. I assume that doesn't matter.
    • &#xA;

    • In the input and the output, the bit-rate for both audio and video are change, but I assume it's okay because h264 and aac are not fixed bit-rate (I hope ?).
    • &#xA;

    &#xA;