Recherche avancée

Médias (0)

Mot : - Tags -/acrobat

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (82)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (5469)

  • Can not get frames from youtube video using FFmpegMediaMetadataRetriever

    27 juin 2019, par Ahasan Ratul

    I have been trying to extract a frame from a youtube video using FFmpegMediaMetadataRetriever in my android studio project. whenever I use the youtube url inside setDataSource, the app crashes. I am totally new in android studio and haven’t worked with FFmpeg before. I would appreciate if anyone can help me out. Also, I am sorry if I have asked a really silly/easy question.

    import wseemann.media.FFmpegMediaMetadataRetriever;
    .....

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
       @Override
       public void onManagerConnected(int status) {
           switch (status) {
               case LoaderCallbackInterface.SUCCESS: {
                   Log.i(TAG, "OpenCV loaded successfully");
                   mOpenCvCameraView.enableView();
                   try {
                       initializeOpenCVDependencies();
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
               }
               break;
               default: {
                   super.onManagerConnected(status);
               }
               break;
           }
       }
    };


    private void initializeOpenCVDependencies() throws IOException {

       tick =0;
      //extract frame at 2 second using FFmpegMediaMetadataRetriever
       FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
       mmr.setDataSource("https://youtu.be/f-ehTcWC6dc");
       Bitmap b = mmr.getFrameAtTime(2000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST);
       mmr.release();

       objMat = new MatOfPoint2f();
       sceneMat = new MatOfPoint2f();
       obj_corners = new Mat(4, 1, CvType.CV_32FC2);
       img = new Mat();
       img2 = new Mat();
    }

    in the build.gradle, I have added the following dependencies

    dependencies {

          //FFmpegMediaMetadataRetriever dependencies
          implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'

          implementation project(path: ':openCVLibrary340dev')
    }

    error that I get is :

    E/AndroidRuntime : FATAL EXCEPTION : main
    Process : com.example.jeverfun, PID : 8877
    java.lang.RuntimeException : Unable to resume activity com.example.jeverfun/com.example.jeverfun.jevercamera : java.lang.IllegalArgumentException : setDataSource failed : status = 0xFFFFFFFF
    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3581)
    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2862)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    Caused by : java.lang.IllegalArgumentException : setDataSource failed : status = 0xFFFFFFFF
    at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource(Native Method)
    at com.example.jeverfun.jevercamera.initializeOpenCVDependencies(jevercamera.java:373)
    at com.example.jeverfun.jevercamera.access$100(jevercamera.java:59)
    at com.example.jeverfun.jevercamera$1.onManagerConnected(jevercamera.java:347)
    at com.example.jeverfun.jevercamera.onResume(jevercamera.java:469)
    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355)
    at android.app.Activity.performResume(Activity.java:7117)
    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2862) 
    at android.app.ActivityThread.-wrap11(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6494) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
    I/MediaMetadataRetrieverJNI : release
    Application terminated.

  • FFMPEG : Reducing bandwidth usage while trimming youtube audio

    24 octobre 2022, par nash

    I have created a python script which creates audio trims of youtube videos using ffmpeg.

    


    The script works fine for small videos of about <20m, however my intention is to use this for large videos most of which are several hours long.&#xA;It appears ffmpeg may be streaming the entire audio while seeking the trim points, not only is this slow but it adds a lot of unnecessary network overhead, especially since the trims I'm making are barely a minute long.

    &#xA;

    Here is the script :

    &#xA;

    from yt_dlp import YoutubeDL as ydl&#xA;import ffmpeg, sys, getopt&#xA;&#xA;&#xA;default_url = "https://youtu.be/FtutLA63Cp8"&#xA;default_start = "6"&#xA;default_end = "36"&#xA;&#xA;&#xA;def get_secs(time_str) -> int:&#xA;&#xA;    h = "0"&#xA;    m = "0"&#xA;    s = "0"&#xA;&#xA;    time_hms = time_str.split(":")&#xA;&#xA;    if len(time_hms) == 1:&#xA;        s = time_hms[0]&#xA;    elif len(time_hms) == 2:&#xA;        m, s = time_hms&#xA;    elif len(time_hms) == 3:&#xA;        h, m, s = time_hms&#xA;&#xA;    secs = (int(h) * 3600) &#x2B; (int(m) * 60) &#x2B; int(s)&#xA;    return secs&#xA;&#xA;&#xA;# Extract Url&#xA;def get_url(url):&#xA;&#xA;    ydl_opts = {}&#xA;    info = ydl(ydl_opts).extract_info(url, download=False)  # dict of lists&#xA;    # info = ydl.sanitize_info(info)&#xA;&#xA;    title = info["title"].strip() &#x2B; ".mp4"&#xA;&#xA;    formats = info["formats"]  # list of dicts&#xA;    audio_direct_url = ""&#xA;    for format in formats:&#xA;        if format["audio_ext"] != "none":&#xA;            audio_direct_url = format["url"]&#xA;            break&#xA;&#xA;    # return r["formats"][-1]["url"]&#xA;    return audio_direct_url, title&#xA;&#xA;&#xA;def snip_url(url, title, start, end):&#xA;    input = ffmpeg.input(url)&#xA;    pts = "PTS-STARTPTS"&#xA;    audio = input.filter_("atrim", start=start, end=end).filter_("asetpts", pts)&#xA;    out = ffmpeg.output(audio, ("out/" &#x2B; title))&#xA;&#xA;    return ffmpeg.run(out)&#xA;&#xA;&#xA;def mince():&#xA;    pass&#xA;&#xA;&#xA;def main(argv):&#xA;    usage_str = "main.py -u <url> -o <outputfile> -s <starttime> -t <stoptime>"&#xA;    target_url = ""&#xA;    out_filename = ""&#xA;    start_time = default_start&#xA;    stop_time = default_end&#xA;&#xA;    try:&#xA;        opts, args = getopt.getopt(&#xA;            argv, "hu:o:s:t:", ["url=", "ofile=", "start=", "terminate="]&#xA;        )&#xA;&#xA;    except getopt.GetoptError:&#xA;        print(usage_str)&#xA;        sys.exit(2)&#xA;&#xA;    for opt, arg in opts:&#xA;        if opt == "-h":&#xA;            print(usage_str)&#xA;            sys.exit()&#xA;        elif opt in ("-u", "--url"):&#xA;            target_url = arg&#xA;        elif opt in ("-o", "--ofile"):&#xA;            out_filename = arg&#xA;        elif opt in ("-s", "--start"):&#xA;            start_time = arg&#xA;        elif opt in ("-t", "--terminate"):&#xA;            stop_time = arg&#xA;&#xA;        if target_url == "":&#xA;            print(usage_str)&#xA;            sys.exit(2)&#xA;&#xA;        # URLs may have seperators, remove them&#xA;        target_url = target_url.rsplit("?")[0]&#xA;&#xA;    stream_url, title = get_url(target_url)&#xA;    if out_filename != "":&#xA;        title = out_filename&#xA;    start_time = get_secs(start_time)&#xA;    stop_time = get_secs(stop_time)&#xA;    snip_url(stream_url, title, start_time, stop_time)&#xA;&#xA;&#xA;if __name__ == "__main__":&#xA;&#xA;    main(sys.argv[1:])&#xA;</stoptime></starttime></outputfile></url>

    &#xA;

    There is a similar question on this site, however this involves grabbing still frames and not audio sections.

    &#xA;

    I have also looked through both theffmpeg-python and regular ffmpeg documentation and not found anything relevant.

    &#xA;

    Is there a way to get ffmpeg to 'skip' to the desired trim position without streaming the entire audio ? Preferrably using the ffmpeg-python library.

    &#xA;

    If not, are there ways I can reduce the bandwidth overhead and/or speed up this process.

    &#xA;

    I am also open to using other software (preferrably python libraries) similar to ffmpeg that can achieve the same task.

    &#xA;

  • ffmpeg ; opus encoded sound in webm does not work with ffplay or YouTube, only VLC [on hold]

    2 août 2017, par Mockarutan

    I’m having trouble getting Opus encoded sound in the webm container to work. I’m using libopus in ffmpeg.

    The file does work in VLC. But not in ffplay or on YouTube. If I take the raw wav data in a wav file and then convert it to Opus/webm with the ffmpeg.exe that comes pre-compiled. It works in VLC, ffplay and YouTube.

    So ffmpeg can obviously do it correctly, I must be doing something wrong in my code.

    The file my code produces : https://drive.google.com/file/d/0B16rIXjPXJCqcU5HVllIYW1iODg/view?usp=sharing

    Edit, More details that I forgot in my frustration : The file can be opened by ffplay and uploaded to youtube (when I interlace it with VP9 video). But the sound is just "ticks", example : https://www.youtube.com/watch?v=j_ShBbuizeo&feature=youtu.be

    I have read though all example codes that I know of from ffmpeg, but all of them is in the old API, not the send/receive api, so a big part of the code does not apply anymore. This code works with all other Codes I’ve tested, including H.264+AAC in mp4, VP8+Opus in ogg and raw PCM F32LE in wav. I would have gone with VP8+Opus in ogg if the license was as straight forward as the webm license

    I’ve looked though the source for the ffmpeg.exe command line tool and coped everything applicable in to my code base.

    (Edit 3, reduced the code as much as I can)
    Here is my code : https://pastebin.com/HTuc0g8K

    Setup :

    int initialize(int sample_rate, int per_frame_audio_samples, int audio_bitrate, const char *filename)
       {
           int ret;

           avcodec_register_all();
           av_register_all();

           ret = avformat_alloc_output_context2(&amp;outctx, NULL, "webm", filename);

           if (ret &lt; 0)
               return ret;

           aud_codec = avcodec_find_encoder(aud_codec_id);
           avcodec_register(aud_codec);

           if (!aud_codec)
               return -1;

           // Setup Audio Stream

           aud_codec_context = avcodec_alloc_context3(aud_codec);
           if (!aud_codec_context)
               return -1;

           /* select other audio parameters supported by the encoder */
           aud_codec_context->bit_rate = audio_bitrate;
           aud_codec_context->sample_rate = sample_rate;
           aud_codec_context->sample_fmt = sample_fmt;
           aud_codec_context->channel_layout = AV_CH_LAYOUT_STEREO;
           aud_codec_context->channels = av_get_channel_layout_nb_channels(aud_codec_context->channel_layout);

           aud_codec_context->codec = aud_codec;
           aud_codec_context->codec_id = aud_codec_id;


           AVRational time_base;
           time_base.num = per_frame_audio_samples;
           time_base.den = aud_codec_context->sample_rate;
           aud_codec_context->time_base = time_base;

           ret = avcodec_open2(aud_codec_context, aud_codec, NULL);

           if (ret &lt; 0)
               return ret;

           outctx->audio_codec = aud_codec;
           outctx->audio_codec_id = aud_codec_id;

           audio_st = avformat_new_stream(outctx, aud_codec);

           avcodec_parameters_from_context(audio_st->codecpar, aud_codec_context);

           conv_time_base.num = aud_codec_context->frame_size;
           conv_time_base.den = aud_codec_context->sample_rate;

           // Setup audio frame
           aud_frame = av_frame_alloc();
           aud_frame->nb_samples = aud_codec_context->frame_size;
           aud_frame->format = aud_codec_context->sample_fmt;
           aud_frame->channel_layout = aud_codec_context->channel_layout;
           aud_frame->sample_rate = aud_codec_context->sample_rate;

           int buffer_size;
           if (aud_codec_context->frame_size == 0)
           {
               buffer_size = per_frame_audio_samples * 2 * 4;
               aud_frame->nb_samples = per_frame_audio_samples;
           }
           else
           {
               buffer_size = av_samples_get_buffer_size(NULL, aud_codec_context->channels, aud_codec_context->frame_size,
                   aud_codec_context->sample_fmt, 0);
           }

           if (av_sample_fmt_is_planar(sample_fmt))
               ret = av_frame_get_buffer(aud_frame, buffer_size / 2);
           else
               ret = av_frame_get_buffer(aud_frame, buffer_size);

           if (!aud_frame || ret &lt; 0)
               return ret;

           // Setup audio resampler

           audio_swr_ctx = swr_alloc();
           if (!audio_swr_ctx)
               return -1;

           /* set options */
           av_opt_set_int(audio_swr_ctx, "in_channel_layout", aud_codec_context->channel_layout, 0);
           av_opt_set_int(audio_swr_ctx, "in_sample_rate", sample_rate, 0);
           av_opt_set_int(audio_swr_ctx, "in_frame_size", per_frame_audio_samples, 0);
           av_opt_set_sample_fmt(audio_swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_FLT, 0);

           av_opt_set_int(audio_swr_ctx, "out_channel_layout", aud_codec_context->channel_layout, 0);
           av_opt_set_int(audio_swr_ctx, "out_sample_rate", aud_codec_context->sample_rate, 0);
           av_opt_set_int(audio_swr_ctx, "out_frame_size", aud_codec_context->frame_size, 0);
           av_opt_set_sample_fmt(audio_swr_ctx, "out_sample_fmt", aud_codec_context->sample_fmt, 0);

           /* initialize the resampling context */
           if ((ret = swr_init(audio_swr_ctx)) &lt; 0)
           {
               return ret;
           }

           dst_rate = aud_codec_context->sample_rate;
           src_rate = sample_rate;

           src_nb_samples = per_frame_audio_samples;
           dst_nb_samples = aud_codec_context->frame_size;

           max_dst_nb_samples = av_rescale_rnd(src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);

           dst_nb_channels = av_get_channel_layout_nb_channels(aud_codec_context->channel_layout);

           ret = av_samples_alloc_array_and_samples(&amp;dst_data, &amp;dst_linesize, dst_nb_channels, dst_nb_samples, sample_fmt, 0);

           aud_frame_counter = 0;

           if (ret &lt; 0)
               return ret;

           av_dump_format(outctx, 0, filename, 1);

           if (!(outctx->oformat->flags &amp; AVFMT_NOFILE))
           {
               ret = avio_open(&amp;outctx->pb, filename, AVIO_FLAG_WRITE);
               if (ret &lt; 0)
               {
                   return ret;
               }
           }

           ret = avformat_write_header(outctx, NULL);
           if (ret &lt; 0)
               return ret;

           return 0;
       }

    Encoding and ending :

    int process_encode_loop(AVFormatContext *local_outctx, AVCodecContext *codec_context, AVStream *stream, AVRational time_base, bool flush)
       {
           int ret;

           AVPacket pkt;
           av_init_packet(&amp;pkt);
           pkt.data = NULL;
           pkt.size = 0;

           while (true)
           {
               ret = avcodec_receive_packet(codec_context, &amp;pkt);
               if (!ret)
               {
                   pkt.stream_index = stream->index;
                   av_packet_rescale_ts(&amp;pkt, time_base, stream->time_base);
                   av_interleaved_write_frame(local_outctx, &amp;pkt);

                   av_packet_unref(&amp;pkt);
               }

               if (ret == AVERROR(EAGAIN))
                   break;
               else if (ret == AVERROR_EOF)
                   break;
               else if (ret &lt; 0)
                   return ret;
               else if (flush == false)
                   break;
           }

           return 0;
       }

       int write_audio_frame(float_t *aud_sample)
       {
           int ret;
           if (dst_nb_samples > max_dst_nb_samples)
           {
               av_free(&amp;aud_frame->data[0]);
               ret = av_samples_alloc(aud_frame->data, &amp;dst_linesize, dst_nb_channels, dst_nb_samples, sample_fmt, 1);
               if (ret &lt; 0)
                   return ret;

               max_dst_nb_samples = dst_nb_samples;
           }

           ret = swr_convert(audio_swr_ctx, dst_data, dst_nb_samples, (const uint8_t **)&amp;aud_sample, src_nb_samples);
           if (ret &lt; 0)
           {
               return ret;
           }

           aud_frame->data[0] = (uint8_t*)dst_data[0];
           aud_frame->extended_data[0] = (uint8_t*)dst_data[0];

           aud_frame->pts = aud_frame_counter++;

           ret = avcodec_send_frame(aud_codec_context, aud_frame);

           ret = process_encode_loop(outctx, aud_codec_context, audio_st, conv_time_base, false);

           if (ret &lt; 0)
               return ret;

           return 0;
       }

       int finish_audio_encoding()
       {
           int ret = avcodec_send_frame(aud_codec_context, NULL);
           if (ret &lt; 0)
               return ret;

           ret = process_encode_loop(outctx, aud_codec_context, audio_st, conv_time_base, true);
           if (ret &lt; 0)
               return ret;

           av_write_trailer(outctx);

           return ret;
       }

    Main :

    void fill_samples(float_t *dst, int nb_samples, int nb_channels, int sample_rate, float_t *t)
       {
           int i, j;
           float_t tincr = 1.0 / sample_rate;
           const float_t c = 2 * M_PI * 440.0;
           /* generate sin tone with 440Hz frequency and duplicated channels */
           for (i = 0; i &lt; nb_samples; i++) {
               *dst = sin(c * *t);
               for (j = 1; j &lt; nb_channels; j++)
                   dst[j] = dst[0];
               dst += nb_channels;
               *t += tincr;
           }
       }

       int main()
       {
           int frame_rate = 30;
           int sec = 12;
           int bit_rate = 192000;
           float t = 0;

           int src_samples_linesize;
           int src_nb_samples = 1024;
           int src_channels = 2;
           int sample_rate = 48000;

           uint8_t **src_data = NULL;

           int ret;

           initialize(sample_rate, src_nb_samples, bit_rate, "sound_test.webm");

           ret = av_samples_alloc_array_and_samples(&amp;src_data, &amp;src_samples_linesize, src_channels,
               src_nb_samples, AV_SAMPLE_FMT_FLT, 0);

           for (size_t i = 0; i &lt; frame_rate * sec; i++)
           {
               fill_samples((float *)src_data[0], src_nb_samples, src_channels, sample_rate, &amp;t);
               write_audio_frame((float *)src_data[0]);
           }
           finish_audio_encoding();

           cleanup();

           return 0;
       }

    Edit 2, This code reproduces the issue exactly and is fully self contained, if you have the ffmpeg 3.3.x libraries. It’s tried with 3.3.1 and 3.3.2 is the same results.

    So what could I be missing ? I do not think something is wrong with the sample rates or any other specifications, else it would not work in VLC or an ogg file. I do think the audio stream itself if correct, just some part of the header or how the file is formatted (look further down for some EBML inspection) that is not correct.

    As explained earlier, the licence with VP9+Opus in webm is why I have these specifics. And the exact problem is that I want the audio stream produced to work well when I upload it to YouTube.

    Any suggestion is appreciated, thanks in Advance !

    Some other things I’ve tried :

    I’ve looked at the header with the "MediaInfo" app built in to MVKTool :
    https://i.gyazo.com/3b29b41629a28bd526bf7637ce3f2601.png
    It all looks fine to me.

    I’ve also inspected the raw EBML file with EBML-Viewer (https://code.google.com/archive/p/ebml-viewer/) and in there I can se some difference between the files ;

    My file : https://i.gyazo.com/6fa8c540a2698a8a4d3421d363aede0a.png
    File produced with ffmpeg.exe : https://i.gyazo.com/04d60e64ff3c3040ea83e98cdf507530.png

    In my file it’s "Cluster" -> "BlockGroup" -> "Block", " ?"
    In the other it’s just "Cluster" -> "SimpleBlock"
    And in the webm specs, it says both are supported (https://www.webmproject.org/docs/container/)

    But I do not know much about these specific things, just looking for anything.