Recherche avancée

Médias (0)

Mot : - Tags -/logo

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

Autres articles (69)

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

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

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

  • I need some help accurately trimming video using the FFmpeg C api

    20 mars 2015, par Justin Bradley

    I need some help accurately trimming video using the FFmpeg C api.
    What I’m seeing is when the input video stream has a time_base of 1/48000 it correctly selects the trimmed start and end times. However when the input video stream has a time_base other than 1/48000 the trim is incorrect.

    Time bases of 1/30000 and 1/24000 trim half the expected video stream length - 10s instead of 20s.
    1/25 trims almost nothing at all - the output file size is only a few kb.

    The audio stream appears to always be trimmed correctly.

    For example if I try to trim the first 20s of a video whose video stream time base is 1/30000, the output mp4’s length is 20s. It has first 10s of video and first 20s of audio.

    I think I’m incorrectly calculating the end_time but I’m not sure why it’s correct for 1/48000 time_base streams.

    record[i].start_time = av_rescale_q((int64_t)( start_time * AV_TIME_BASE ), default_timebase, in_stream->time_base);
    record[i].end_time = av_rescale_q((int64_t)( end_time   * AV_TIME_BASE ), default_timebase, in_stream->time_base);

    Here is a more complete sample of code :

    int num_of_streams = ifmt_ctx->nb_streams;
    if(num_of_streams > 0) {
       // keeps track of each stream's trimmed start and end times
       struct stream_pts record[num_of_streams];

       for (i = 0; i < num_of_streams; i++) {
           AVStream *in_stream = ifmt_ctx->streams[i];
           AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);
           if (!out_stream) {
               LOGE("=> Failed allocating output stream");
               ret = AVERROR_UNKNOWN;
               return close_connection(ret);
           }

           ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
           if (ret < 0) {
               LOGE("=> Failed to copy context from input to output stream codec context");
               return close_connection(ret);
           }
           out_stream->codec->codec_tag = 0;
           if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
               out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;

           AVRational default_timebase;
           default_timebase.num = 1;
           default_timebase.den = AV_TIME_BASE;

           // determine start/end times for each stream
           record[i].index = i;
           record[i].start_time = av_rescale_q((int64_t)( start_time * AV_TIME_BASE ), default_timebase, in_stream->time_base);
           record[i].end_time = av_rescale_q((int64_t)( end_time   * AV_TIME_BASE ), default_timebase, in_stream->time_base);
       }

       av_dump_format(ofmt_ctx, 0, output_file, 1);

       if (!(ofmt->flags & AVFMT_NOFILE)) {
           ret = avio_open(&ofmt_ctx->pb, output_file, AVIO_FLAG_WRITE);
           if (ret < 0) {
               LOGE("=> Could not open output file '%s'", output_file);
               return close_connection(ret);
           }
       }

       ret = avformat_write_header(ofmt_ctx, NULL);
       if (ret < 0) {
           LOGE("=> Error occurred when opening output file");
           return close_connection(ret);
       }

       while (1) {
           AVStream *in_stream, *out_stream;

           ret = av_read_frame(ifmt_ctx, &pkt);
           if (ret < 0)
               break;

           in_stream  = ifmt_ctx->streams[pkt.stream_index];
           out_stream = ofmt_ctx->streams[pkt.stream_index];

           // copy packet
           pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
           pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
           pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
           pkt.pos = -1;

           // write the frames we're looking for
           if(pkt.pts >= record[pkt.stream_index].start_time && pkt.pts <= record[pkt.stream_index].end_time) {
               ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
               if (ret < 0) {
                   LOGE("=> Error muxing packet");
                   break;
               }
           }

           av_free_packet(&pkt);
       }
    }
  • ffmpeg_kit_flutter commands work on some devices but not on some other devices

    5 août 2023, par eashhh

    I have been trying to create videos from a series of images with similar formats using the ffmpeg_kit_flutter package. While using the package, I have encountered an issue where the video generation works on certain devices but not on my Android device (Android 10). Below are the code snippets I have been using for the video generation process.

    


    I have invoked the videoCreator() function in the following manner.

    


     Future<void> videoCreator() async {&#xA;    if (await Permission.storage.request().isGranted) {&#xA;      print(&#x27;generation initiated&#x27;);&#xA;      outputPath = File(&#x27;/storage/emulated/0/Download/output123.mp4&#x27;).path;&#xA;      String commandToExecute = &#x27;-framerate ${framerate.toInt()} -i &#x27;&#xA;          &#x27;\&#x27;$videoDirectory/%d.jpeg\&#x27;&#x27;&#xA;          &#x27; -q:v 1 -y $outputPath&#x27;;&#xA;      print(&#x27;$commandToExecute&#x27;);&#xA;      await FFmpegKit.execute(commandToExecute).then((session) async {&#xA;      final returnCode = await session.getReturnCode();&#xA;&#xA;</void>

    &#xA;

    The output from debug console is as follows :

    &#xA;

    I/flutter ( 5871): generation initiated&#xA;I/flutter ( 5871): -framerate 12 -i &#x27;/data/user/0/com.example.test_project/app_flutter/1/%d.jpeg&#x27; -q:v 1 -y /storage/emulated/0/Download/output123.mp4&#xA;I/flutter ( 5871): Loading ffmpeg-kit-flutter.&#xA;D/ffmpeg-kit-flutter( 5871): FFmpegKitFlutterPlugin com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin@8324d61 started listening to events on io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler$EventSinkImplementation@50da4a8.&#xA;

    &#xA;

    And also to determine whether the video generation was successful or not, the code checks the return code obtained from the session. If the return code indicates success (using the ReturnCode.isSuccess() method), it prints "Success !" to the console else prints "Failure !" wrt to the following conditions given :

    &#xA;

    &#xA;        if (ReturnCode.isSuccess(returnCode)) {&#xA;          print("Success!");&#xA;          setState(() {&#xA;            processing = false;&#xA;            status = true;&#xA;          });&#xA;        } else if (ReturnCode.isCancel(returnCode)) {&#xA;          print("Cancelled!");&#xA;          setState(() {&#xA;            processing = false;&#xA;            status = false;&#xA;          });&#xA;        } else {&#xA;          print("Failure!");&#xA;          print(await session.getFailStackTrace());&#xA;          print("Failure!");&#xA;          print(await session.getOutput());&#xA;          setState(() {&#xA;            processing = false;&#xA;            status = false;&#xA;          });&#xA;        }&#xA;

    &#xA;

    But I continue to receive "Failure !" messages in the debug console.

    &#xA;

    I/flutter ( 5871): Failure!&#xA;I/flutter ( 5871): LightThemeSet&#xA;I/flutter ( 5871): null&#xA;I/flutter ( 5871): Failure!&#xA;

    &#xA;

    I attempted the following approaches to resolve the issue :

    &#xA;

      &#xA;
    1. Tried changing the output path for the generated video.

      &#xA;

    2. &#xA;

    3. Tried updating the required storage permissions in the AndroidManifest.xml file. Currently the permissions include the standard READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions used for the older android versions and the MANAGE_EXTERNAL_STORAGE permission used for newer versions

      &#xA;

    4. &#xA;

    5. Tested the app on various Android emulators with different configurations where it worked properly.

      &#xA;

    6. &#xA;

    &#xA;

    Any sort of help would be appreciated !&#xA;Warm regards

    &#xA;

  • Why does the new version of ffmpeg play non-interleaved http files so stuck ?

    22 juillet 2020, par fredirty2017
      &#xA;
    • I use MAC's AVAssetWriter/AVAssetWriterInput to generate MP4, then upload it to the website, and then use the latest version (ffmpeg4.2 or 4.3) of ffplay to play the file as https file on Windows, but I find it is very stuck. I use the old version of ffmpeg For example, the 3.4 version is normal. By analyzing the old and new ffmpeg source code, the general problem is basically located, but the deeper reason is still unclear.

      &#xA;

    • &#xA;

    • The audio and video frames recorded by MAC are partially (within 3 seconds) non-interleaved

      &#xA;

    • &#xA;

    • The latest version of Window's ffplay will continue to reconnect http to Seek&#xA;In the mov.c file, it is found that the number of AVIndexEntry created by the new and old versions ffmpeg is different, because the read buffer size is determined by the calculation of ff_configure_buffers_for_index : the buffer_size of the new version of AVIOContext is only the default 16k, so the pre-step of mov_read_packet avio_seek finds that the pos of the next frame is not within the 16k range, which leads to reconnecting to http and seeking to a new position ; while the AVIOContext.buffer_size of the old version of ffmpeg has a size of M Bytes level, it will not trigger reconnection of http.

      &#xA;

    • &#xA;

    • Further analysis found that ff_configure_buffers_for_index will be calculated based on the relative maximum offset of the AVIndexEntry of each stream, because the new version skips the opportunity to adjust the buffer_size because the pos_delta is greater than 1<<24.

      &#xA;

    • &#xA;

    • But I don’t know why the new version of AVIndexEntry has this situation. Do you know why the "new" version has made this change ? And how to make the player plays as smoothly as the old version ?

      &#xA;

       void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)&#xA; {&#xA;     int ist1, ist2;&#xA;     int64_t pos_delta = 0;&#xA;     int64_t skip = 0;&#xA;     //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable&#xA;     const char *proto = avio_find_protocol_name(s->filename);&#xA;&#xA;     if (!proto) {&#xA;         av_log(s, AV_LOG_INFO,&#xA;            "Protocol name not provided, cannot determine if input is local or "&#xA;            "a network protocol, buffers and access patterns cannot be configured "&#xA;            "optimally without knowing the protocol\n");&#xA;     }&#xA;&#xA;     if (proto &amp;&amp; !(strcmp(proto, "file") &amp;&amp; strcmp(proto, "pipe") &amp;&amp; strcmp(proto, "cache")))&#xA;         return;&#xA;&#xA;     for (ist1 = 0; ist1 &lt; s->nb_streams; ist1&#x2B;&#x2B;) {&#xA;         AVStream *st1 = s->streams[ist1];&#xA;         for (ist2 = 0; ist2 &lt; s->nb_streams; ist2&#x2B;&#x2B;) {&#xA;             AVStream *st2 = s->streams[ist2];&#xA;             int i1, i2;&#xA;&#xA;             if (ist1 == ist2)&#xA;                 continue;&#xA;&#xA;             for (i1 = i2 = 0; i1 &lt; st1->nb_index_entries; i1&#x2B;&#x2B;) {&#xA;                 AVIndexEntry *e1 = &amp;st1->index_entries[i1];&#xA;                 int64_t e1_pts = av_rescale_q(e1->timestamp, st1->time_base, AV_TIME_BASE_Q);&#xA;&#xA;                 skip = FFMAX(skip, e1->size);&#xA;                 for (; i2 &lt; st2->nb_index_entries; i2&#x2B;&#x2B;) {&#xA;                     AVIndexEntry *e2 = &amp;st2->index_entries[i2];&#xA;                     int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);&#xA;                     if (e2_pts - e1_pts &lt; time_tolerance)&#xA;                         continue;&#xA;                     pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);&#xA;                     av_log(s, AV_LOG_VERBOSE, "ff_configure_buffers_for_index  [%d, %d]  (%"PRId64", %"PRId64"):    %"PRId64"\n",  i1, i2, e1_pts, e2_pts, pos_delta);&#xA;                     break;&#xA;                 }&#xA;             }&#xA;         }&#xA;     }&#xA;&#xA;     pos_delta *= 2;&#xA;     /* XXX This could be adjusted depending on protocol*/&#xA;     if (s->pb->buffer_size &lt; pos_delta &amp;&amp; pos_delta &lt; (1&lt;&lt;24)) {&#xA;         av_log(s, AV_LOG_VERBOSE, "Reconfiguring buffers to size %"PRId64"\n", pos_delta);&#xA;         ffio_set_buf_size(s->pb, pos_delta);&#xA;         s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, pos_delta/2);&#xA;     }&#xA;&#xA;     if (skip &lt; (1&lt;&lt;23)) {&#xA;         s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, skip);&#xA;     }&#xA; }&#xA;

      &#xA;

    • &#xA;

    &#xA;