Recherche avancée

Médias (17)

Mot : - Tags -/wired

Autres articles (46)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (6684)

  • Moviepy write_videofile changes number of video and audio frames even after using 'rawvideo' as the codec parameter

    14 mars 2019, par Jaideep Sagar

    I am using moviepy (Python) to read video and audio frames of a video and after making some changes I am writing them back to a videofile, say new.avi, to preserve the changes, or to avoid compression, I am using codec= ’rawvideo’ in write_videofile function. But when I read the video and audio frames back, the number of video and audio frames are different than when they were when written, they are usually increased.
    Can anybody tell me the reason, ? is it because of the ffmpeg used or some other reason ? Does it happen always or there is some problem in my machine ? Thank you :-)

  • Use Static Library Build Shared Library Undefined Reference

    26 mai 2020, par Leo

    I want to use AndroidStudio ndk-build to build Shared Library on Window with ffmpeg lib but i got Undefined Reference Error,Please tell me what I do wrong

    



    ndkVersion = 21.0.6113669
compileSdkVersion 29

    



    I also try to build By GCC , the same error happen
I also try to build By CMake with ffmpeg SourceCode , the same error happen

    



    I try to build .a file with some simple C Code on gcc and use another C Code to use it,it work,but not with ffmpeg .a file i dont know why

    



    this is my Android.mk

    



    `LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_MODULE := avcodec
 LOCAL_SRC_FILES := lib/libavcodec.dll.a
 include $(PREBUILT_STATIC_LIBRARY)

 include $(CLEAR_VARS)
 LOCAL_MODULE := avformat
 LOCAL_SRC_FILES := lib/libavformat.dll.a
 include $(PREBUILT_STATIC_LIBRARY)

 ...

 include $(CLEAR_VARS)
 LOCAL_MODULE := avutil
 LOCAL_SRC_FILES := lib/libavutil.dll.a
 include $(PREBUILT_STATIC_LIBRARY)

 include $(CLEAR_VARS)
 LOCAL_MODULE := libTestDll
 LOCAL_SRC_FILES := TestDll.cpp
 LOCAL_C_MODULE := avcodec avformat swscale avutil avfilter avdevice

 include $(BUILD_SHARED_LIBRARY)`


    



    this is my main cpp

    



    #include &#xA;#include &#xA;&#xA;#define __STDC_CONSTANT_MACROS&#xA;&#xA;#include <string>&#xA;&#xA;extern"C"&#xA;{&#xA;#include "libavformat/avformat.h"&#xA;#include "libavutil/mathematics.h"&#xA;#include "libavutil/time.h"&#xA;#include "libavutil/pixfmt.h"&#xA;#include "libavcodec/avcodec.h"&#xA;#include "libavformat/avformat.h"&#xA;#include "libswscale/swscale.h"&#xA;#include "libavutil/imgutils.h"&#xA;}&#xA;&#xA;using namespace std;&#xA;&#xA;char output[99999];&#xA;int frameCount = 0;&#xA;uint8_t* buf;&#xA;int bufLength;&#xA;uint8_t* p_global_bgr_buffer;&#xA;int num_bytes;&#xA;int wrap;&#xA;bool EndReceFrame = false;&#xA;SwsContext* swsContext;&#xA;AVFrame* pFrame = av_frame_alloc();&#xA;AVCodecContext* pCodecContext;&#xA;AVPixelFormat dstFmt = AV_PIX_FMT_RGB24;&#xA;&#xA;static void BGRpgm_save(AVFrame* frame)&#xA;{&#xA;    int linesize[8] = { frame->linesize[0] * 3 };&#xA;&#xA;    uint8_t* bgr_buffer[8] = { p_global_bgr_buffer };&#xA;&#xA;    sws_scale(swsContext, frame->data, frame->linesize, 0, frame->height, bgr_buffer, linesize);&#xA;&#xA;    memcpy(buf, bgr_buffer[0], linesize[0] * frame->height);&#xA;&#xA;    bufLength = linesize[0] * frame->height;&#xA;&#xA;    frameCount&#x2B;&#x2B;;&#xA;&#xA;}&#xA;...&#xA;&#xA;</string>

    &#xA;&#xA;

    Error Message

    &#xA;&#xA;

    [x86] SharedLibrary  : libTestDll.so&#xA;jni/TestDll.cpp:123: error: undefined reference to &#x27;avformat_open_input&#x27;&#xA;jni/TestDll.cpp:127: error: undefined reference to &#x27;avformat_find_stream_info&#x27;&#xA;jni/TestDll.cpp:138: error: undefined reference to &#x27;av_dump_format&#x27;&#xA;jni/TestDll.cpp:144: error: undefined reference to &#x27;avcodec_find_decoder&#x27;&#xA;jni/TestDll.cpp:146: error: undefined reference to &#x27;avcodec_alloc_context3&#x27;&#xA;

    &#xA;

  • discord.py music bot slowing down for longer audio queries

    1er janvier 2023, par Bobluge

    So I'm trying to make a music bot with discord.py. Shown below is a minimum working example of the bot with the problematic functions :

    &#xA;

    import os&#xA;&#xA;import discord&#xA;from discord.ext import commands&#xA;from discord import player as p&#xA;&#xA;import yt_dlp as youtube_dl&#xA;&#xA;intents = discord.Intents.default()&#xA;intents.members = True&#xA;&#xA;bot = commands.Bot(command_prefix=&#x27;;&#x27;)&#xA;&#xA;class Music(commands.Cog):&#xA;    def __init__(self, bot):&#xA;        self.bot = bot&#xA;        self.yt-dlp_opts = {&#xA;            &#x27;format&#x27;: &#x27;bestaudio/best&#x27;,&#xA;            &#x27;outtmpl&#x27;: &#x27;%(extractor)s-%(id)s-%(title)s.%(ext)s&#x27;,&#xA;            &#x27;restrictfilenames&#x27;: True,&#xA;            &#x27;noplaylist&#x27;: True,&#xA;            &#x27;playlistend&#x27;: 1,&#xA;            &#x27;nocheckcertificate&#x27;: True,&#xA;            &#x27;ignoreerrors&#x27;: False,&#xA;            &#x27;logtostderr&#x27;: False,&#xA;            &#x27;quiet&#x27;: True,&#xA;            &#x27;no_warnings&#x27;: True,&#xA;            &#x27;default_search&#x27;: &#x27;auto&#x27;,&#xA;            &#x27;source_address&#x27;: &#x27;0.0.0.0&#x27;, # bind to ipv4 since ipv6 addresses cause issues sometimes&#xA;        }&#xA;        self.ffmpeg_opts = {&#xA;            &#x27;options&#x27;: &#x27;-vn&#x27;,&#xA;            # Source: https://stackoverflow.com/questions/66070749/&#xA;            "before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",&#xA;        }&#xA;        self.cur_stream = None&#xA;        self.cur_link = None&#xA;&#xA;    @commands.command(aliases=["p"])&#xA;    async def play(self, ctx, url):&#xA;        yt-dlp = youtube_dl.YoutubeDL(self.ytdl_opts)&#xA;        data = yt-dlp.extract_info(url, download=False)&#xA;        filename = data[&#x27;url&#x27;]  # So far only works with links&#xA;        print(filename)&#xA;        audio = p.FFmpegPCMAudio(filename, **self.ffmpeg_opts)&#xA;        self.cur_stream = audio&#xA;        self.cur_link = filename&#xA;&#xA;        # You must be connected to a voice channel first&#xA;        await ctx.author.voice.channel.connect()&#xA;        ctx.voice_client.play(audio)&#xA;        await ctx.send(f"now playing")&#xA;&#xA;    @commands.command(aliases=["ff"])&#xA;    async def seek(self, ctx):&#xA;        """&#xA;        Fast forwards 10 seconds&#xA;        """&#xA;        ctx.voice_client.pause()&#xA;        for _ in range(500):&#xA;            self.cur_stream.read()  # 500*20ms of audio = 10000ms = 10s&#xA;        ctx.voice_client.resume()&#xA;&#xA;        await ctx.send(f"fast forwarded 10 seconds")&#xA;&#xA;    @commands.command(aliases=["j"])&#xA;    async def jump(self, ctx, time):&#xA;        """&#xA;        Jumps to a time in the song, input in the format of HH:MM:SS&#xA;        """&#xA;        ctx.voice_client.stop()&#xA;        temp_ffempg = {&#xA;            &#x27;options&#x27;: &#x27;-vn&#x27;,&#xA;            # Keyframe skipping when passed as an input option (fast)&#xA;            "before_options": f"-ss {time} -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",&#xA;        }&#xA;        new_audio = p.FFmpegPCMAudio(self.cur_link, **temp_ffempg)&#xA;        self.cur_stream = new_audio&#xA;        ctx.voice_client.play(new_audio)&#xA;        await ctx.send(f"skipped to {time}")&#xA;&#xA;&#xA;bot.add_cog(Music(bot))&#xA;bot.run(os.environ["BOT_TOKEN"])&#xA;

    &#xA;

    My requirements.txt file :

    &#xA;

    discord.py[voice]==1.7.3&#xA;yt-dlp==2021.9.2&#xA;

    &#xA;

    To play a song in Discord the following format is used :

    &#xA;

    ;p &#xA;

    &#xA;

    Where is any link that yt-dlp supports. Under normal circumstances, the ;p command is used with songs that are relatively short, to which seek() and jump() work extremely quickly to do what they are supposed to do. For example if I execute these sequence of commands in Discord :

    &#xA;

    ;p https://www.youtube.com/watch?v=n8X9_MgEdCg  &lt;- 4 min song&#xA;

    &#xA;

    And when the bot starts playing, spam the following :

    &#xA;

    ;ff&#xA;;ff&#xA;;ff&#xA;;ff&#xA;;ff&#xA;

    &#xA;

    The bot is able to almost instantly seek five 10-second increments of the song. Additionally, I can jump to the three minute mark very quickly with :

    &#xA;

    ;j 00:03:00&#xA;

    &#xA;

    From some experimentation, the seek() and jump() functions seem to work quickly for songs that are under 10 minutes. If I try the exact same sequence of commands but with a 15 minute song like https://www.youtube.com/watch?v=Ks9Ck5LfGWE or longer https://www.youtube.com/watch?v=VThrx5MRJXA (10 hours classical music), there is an evident slowdown when running the ;ff command. However, when I include a few seconds of delay between firings of the ;ff command, the seeking is just as fast as previously mentioned. I'm not exactly sure what is going on with yt-dlp/FFmpeg behind the scenes when streaming, but I speculate that there is some sort of internal buffer, and songs that pass a certain length threshold are processed differently.

    &#xA;

    For longer songs, the seek() command takes longer to get to the desired position, which makes sense since this site specifies that -ss used as an input option loops through keyframes (as there must be more keyframes in longer songs). However, if the following commands are run in Discord :

    &#xA;

    ;p https://www.youtube.com/watch?v=VThrx5MRJXA  &lt;- 10 hour classical music&#xA;;j 09:00:00                                     &lt;- jump to 9 hour mark&#xA;;j 00:03:00                                     &lt;- jump to 3 minute mark&#xA;

    &#xA;

    The first seek command takes around 5 to 10 seconds to perform a successful seek, which isn't bad, but it could be better. The second seek command takes around the same time as the first command, which doesn't make sense to me, because I thought less keyframes were skipped in order to reach the 3 minute mark.

    &#xA;

    So I'm wondering what's going on, and how to potentially solve the following :

    &#xA;

      &#xA;
    • What is actually going on with the seek() command ? My implementation of seek() uses discord.py's discord.player.FFmpegPCMAudio.read() method, which apparently runs slower if the song's length is longer ? Why ?
    • &#xA;

    • Why does input seeking for long YouTube videos take almost the same time no matter where I seek to ?
    • &#xA;

    • How the yt-dlp and FFmpeg commands work behind the scenes to stream a video from YouTube (or any other website that YTDL supports). Does yt-dlp and FFmpeg behave differently for audio streams above a certain length threshold ?
    • &#xA;

    • Potential ways to speed up seek() and jump() for long songs. I recall some well-known discord music bots were able to do this very quickly.
    • &#xA;

    &#xA;