Recherche avancée

Médias (0)

Mot : - Tags -/protocoles

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

Autres articles (34)

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

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Submit enhancements and plugins

    13 avril 2011

    If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
    You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.

Sur d’autres sites (5780)

  • Reading mp3 file using ffmpeg caues memory leaks, even after freeing it in main

    12 août 2020, par leonardltk1

    i am continuously reading mp3 files and processing them, but the memory keeps getting build up even though i freed it.

    


    At the bottom read_audio_mp3(), they are already freeing some variable.
why do i still face a memory build up and how do i deal with it ?

    


    following this code : https://rodic.fr/blog/libavcodec-tutorial-decode-audio-file/, i read mp3 using this function

    


        int read_audio_mp3(string filePath_str, const int sample_rate, 
      double** output_buffer, int &AUDIO_DURATION){
      const char* path = filePath_str.c_str();

      /* Reads the file header and stores information about the file format. */
        AVFormatContext* format = avformat_alloc_context();
        if (avformat_open_input(&format, path, NULL, NULL) != 0) {
            fprintf(stderr, "Could not open file '%s'\n", path);
            return -1;
        }

      /* Check out the stream information in the file. */
        if (avformat_find_stream_info(format, NULL) < 0) {
            fprintf(stderr, "Could not retrieve stream info from file '%s'\n", path);
            return -1;
        }

      /* find an audio stream. */
        int stream_index =- 1;
        for (unsigned i=0; inb_streams; i++) {
          if (format->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            stream_index = i;
            break;
          }
        }
        if (stream_index == -1) {
            fprintf(stderr, "Could not retrieve audio stream from file '%s'\n", path);
            return -1;
        }
        AVStream* stream = format->streams[stream_index];

      // find & open codec
        AVCodecContext* codec = stream->codec;
        if (avcodec_open2(codec, avcodec_find_decoder(codec->codec_id), NULL) < 0) {
            fprintf(stderr, "Failed to open decoder for stream #%u in file '%s'\n", stream_index, path);
            return -1;
        }

      // prepare resampler
        struct SwrContext* swr = swr_alloc();
        av_opt_set_int(swr, "in_channel_count",  codec->channels, 0);
        av_opt_set_int(swr, "out_channel_count", 1, 0);
        av_opt_set_int(swr, "in_channel_layout",  codec->channel_layout, 0);
        av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);
        av_opt_set_int(swr, "in_sample_rate", codec->sample_rate, 0);
        av_opt_set_int(swr, "out_sample_rate", sample_rate, 0);
        av_opt_set_sample_fmt(swr, "in_sample_fmt",  codec->sample_fmt, 0);
        av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_DBL,  0);
        swr_init(swr);
        if (!swr_is_initialized(swr)) {
            fprintf(stderr, "Resampler has not been properly initialized\n");
            return -1;
        }

      /* Allocate an audio frame. */
        AVPacket packet;
        av_init_packet(&packet);
        AVFrame* frame = av_frame_alloc();
        if (!frame) {
          fprintf(stderr, "Error allocating the frame\n");
          return -1;
        }

      // iterate through frames
        *output_buffer = NULL;
        AUDIO_DURATION = 0;
        while (av_read_frame(format, &packet) >= 0) {
          // decode one frame
            int gotFrame;
            if (avcodec_decode_audio4(codec, frame, &gotFrame, &packet) < 0) {
              // free packet
                av_free_packet(&packet);
                break;
            }
            if (!gotFrame) {
              // free packet
                av_free_packet(&packet);
                continue;
            }
          // resample frames
            double* buffer;
            av_samples_alloc((uint8_t**) &buffer, NULL, 1, frame->nb_samples, AV_SAMPLE_FMT_DBL, 0);
            int frame_count = swr_convert(swr, (uint8_t**) &buffer, frame->nb_samples, (const uint8_t**) frame->data, frame->nb_samples);
          // append resampled frames to output_buffer
            *output_buffer = (double*) realloc(*output_buffer,
             (AUDIO_DURATION + frame->nb_samples) * sizeof(double));
            memcpy(*output_buffer + AUDIO_DURATION, buffer, frame_count * sizeof(double));
            AUDIO_DURATION += frame_count;
          // free buffer & packet
            av_free_packet(&packet);
            av_free( buffer );
        }

      // clean up
        av_frame_free(&frame);
        swr_free(&swr);
        avcodec_close(codec);
        avformat_free_context(format);

      return 0;
    }


    


    Main Script : MemoryLeak.cpp

    


        // imports&#xA;      #include <fstream>&#xA;      #include &#xA;      #include &#xA;      #include &#xA;      #include &#xA;      #include <iostream>&#xA;      #include <sstream>&#xA;      #include <vector>&#xA;      #include <sys></sys>time.h> &#xA;      extern "C"&#xA;      {&#xA;      #include <libavutil></libavutil>opt.h>&#xA;      #include <libavcodec></libavcodec>avcodec.h>&#xA;      #include <libavformat></libavformat>avformat.h>&#xA;      #include <libswresample></libswresample>swresample.h>&#xA;      }&#xA;      using namespace std;&#xA;&#xA;    int main (int argc, char ** argv) {&#xA;      string wavpath = argv[1];&#xA;      printf("wavpath=%s\n", wavpath.c_str());&#xA;&#xA;      printf("\n==== Params =====\n");&#xA;      // Init&#xA;        int AUDIO_DURATION;&#xA;        int sample_rate = 8000;&#xA;        av_register_all();&#xA;&#xA;      printf("\n==== Reading MP3 =====\n");&#xA;        while (true) {&#xA;            // Read mp3&#xA;              double* buffer;&#xA;              if (read_audio_mp3(wavpath, sample_rate, &amp;buffer, AUDIO_DURATION) != 0) {&#xA;                printf("Cannot read %s\n", wavpath.c_str());&#xA;                continue;&#xA;              }&#xA;&#xA;            /* &#xA;              Process the buffer for down stream tasks.&#xA;            */&#xA;&#xA;            // Freeing the buffer&#xA;            free(buffer);&#xA;        }&#xA;&#xA;      return 0 ;&#xA;    }&#xA;</vector></sstream></iostream></fstream>

    &#xA;

    Compiling

    &#xA;

        g&#x2B;&#x2B; -o ./MemoryLeak.out -Ofast -Wall -Wextra \&#xA;        -std=c&#x2B;&#x2B;11 "./MemoryLeak.cpp" \&#xA;        -lavformat -lavcodec -lavutil -lswresample&#xA;

    &#xA;

    Running, by right my input an argument wav.scp that reads text file of all the mp3s.&#xA;But for easy to replicate purpose, i only read 1 file song.mp3 in and i keep re-reading it

    &#xA;

    ./MemoryLeak.out song.mp3&#xA;

    &#xA;

    Why do i know i have memory leaks ?

    &#xA;

      &#xA;
    1. I was running up 32 jobs in parallel for 14 million files, and when i wake up in the morning, they were abruptly killed.
    2. &#xA;

    3. I run htop and i monitor the progress when i re-run it, and i saw that the VIRT & RES & Mem are continuously increasing.
    4. &#xA;

    &#xA;

    &#xA;

    Edit 1 :&#xA;My setup :

    &#xA;

    &#xA;

    ffmpeg version 2.8.15-0ubuntu0.16.04.1&#xA;built with gcc 5.4.0&#xA;

    &#xA;

  • Can I Config FFMEG-2.4.3 to use in android windows 64 ?

    13 novembre 2014, par Ngo Ky

    I want to build ffmpeg-2.4.3 (lastest c lib) to use it on android for managing video.
    my OS is windows 7 Utimate x64
    cywin64 in directory : C :/cywin64/ have make installed.
    NDK in directory : D :\solfware\Programming\android-ndk-r10c

    i follow toturial form : http://www.roman10.net/how-to-build-ffmpeg-for-android/comment-page-1/
    my project struture like :

    enter image description here

    i create build_android.sh like roman10 as following code :

    # ARMv7+Neon (Cortex-A8)
    # Customizing:
    # 1. Feel free to change ./configure parameters for more features
    # 2. To adapt other ARM variants
    # set $CPU and $OPTIMIZE_CFLAGS
    # call build_one
    ######################################################
    NDK=D:\solfware\Programming\android-ndk-r10c
    PLATFORM=$NDK/platforms/android-8/arch-arm/
    PREBUILT=$NDK/prebuilt/windows-x86_64
    function build_one
    {
    ./configure --target-os=linux \
       --prefix=$PREFIX \
       --enable-cross-compile \
       --extra-libs="-lgcc" \
       --arch=arm \
       --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
       --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
       --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
       --sysroot=$PLATFORM \
       --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
       --disable-shared \
       --enable-static \
       --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
       --disable-everything \
       --enable-demuxer=mov \
       --enable-demuxer=h264 \
       --disable-ffplay \
       --enable-protocol=file \
       --enable-avformat \
       --enable-avcodec \
       --enable-decoder=rawvideo \
       --enable-decoder=mjpeg \
       --enable-decoder=h263 \
       --enable-decoder=mpeg4 \
       --enable-decoder=h264 \
       --enable-parser=h264 \
       --disable-network \
       --enable-zlib \
       --disable-avfilter \
       --disable-avdevice \
       $ADDITIONAL_CONFIGURE_FLAG

    make clean
    make  -j4 install
    $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
    $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
    }

    #arm v6
    #CPU=armv6
    #OPTIMIZE_CFLAGS="-marm -march=$CPU"
    #PREFIX=./android/$CPU
    #ADDITIONAL_CONFIGURE_FLAG=
    #build_one

    #arm v7vfpv3
    CPU=armv7-a
    OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
    PREFIX=./android/$CPU
    ADDITIONAL_CONFIGURE_FLAG=
    build_one

    #arm v7vfp
    #CPU=armv7-a
    #OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
    #PREFIX=./android/$CPU-vfp
    #ADDITIONAL_CONFIGURE_FLAG=
    #build_one

    #arm v7n
    #CPU=armv7-a
    #OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
    #PREFIX=./android/$CPU
    #ADDITIONAL_CONFIGURE_FLAG=--enable-neon
    #build_one

    #arm v6+vfp
    #CPU=armv6
    #OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
    #PREFIX=./android/${CPU}_vfp
    #ADDITIONAL_CONFIGURE_FLAG=
    #build_one

    i have set my path like above
    I built it in Eclipse Everything is ok. but when i ran it in Android it crashed Unfortunately.
    I found the errors in Logcat monitor :

    E/AndroidRuntime(1931) : java.lang.UnsatisfiedLinkError : Couldn’t load avcodec-55 from loader dalvik.system.PathClassLoader[DexPathList [1]] : findLibrary returned null

    E/AndroidRuntime(1931) : at java.lang.Runtime.loadLibrary(Runtime.java:358)

    In my activity i just call add Library from C preference like :

    static {
           //System.loadLibrary("avutil-52");
           System.loadLibrary("avcodec-55");
           System.loadLibrary("avformat-55");
           System.loadLibrary("swscale-2");
           System.loadLibrary("tutorial02");
       }

    i check in DDMS in app-lib there is no existing Library in there.

    The question is : Can i can compile the ffmpeg on windows ?
    if ok. how can i config build_android.sh to point to Android $PREBUILT

    PLATFORM=$NDK/platforms/android-8/arch-arm/
       PREBUILT=$NDK/prebuilt/windows-x86_64
       function build_one
       {
       ./configure --target-os=linux \
           --prefix=$PREFIX \
           --enable-cross-compile \
           --extra-libs="-lgcc" \
           --arch=arm \
           --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
           --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
           --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
           --sysroot=$PLATFORM \
           --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
           --disable-shared \

    i found that in $NDK/prebuilt/windows-x86_64/bin did not exist arm-linux-androideabi-gcc\
    How can i config to be suitable to run on windows ?

    Thank in advanced

  • How to add subtitles using FFmpeg-kit ?

    17 novembre 2024, par Mohammed Bekele

    I'm running a Flutter app with Ffmpeg-kit package to burn a subtitle on a video. I have a words list with the timings and map that to generate an srt and ass file, but when executing this it didn't work.

    &#xA;

    Firstly, here is how I generated the Ass file.

    &#xA;

    Future<string> _createAssFile() async {&#xA;    String filePath = await getAssOutputFilePath();&#xA;&#xA;    final file = File(filePath);&#xA;    final buffer = StringBuffer();&#xA;&#xA;    // Write ASS headers&#xA;    buffer.writeln(&#x27;[Script Info]&#x27;);&#xA;    buffer.writeln(&#x27;Title: Generated ASS&#x27;);&#xA;    buffer.writeln(&#x27;ScriptType: v4.00&#x2B;&#x27;);&#xA;    buffer.writeln(&#x27;Collisions: Normal&#x27;);&#xA;    buffer.writeln(&#x27;PlayDepth: 0&#x27;);&#xA;    buffer.writeln(&#x27;Timer: 100,0000&#x27;);&#xA;    buffer.writeln(&#x27;[V4&#x2B; Styles]&#x27;);&#xA;    buffer.writeln(&#xA;        &#x27;Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding&#x27;);&#xA;    buffer.writeln(&#xA;        &#x27;Style: Default,Arial,40,&amp;H00FFFFFF,&amp;H000000FF,&amp;H00000000,&amp;H80000000,1,1,1,1,100,100,0,0,1,1,1,2,10,10,10,1&#x27;);&#xA;    buffer.writeln(&#x27;[Events]&#x27;);&#xA;    buffer.writeln(&#xA;        &#x27;Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text&#x27;);&#xA;&#xA;    // Write events (subtitles)&#xA;    for (int i = 0; i &lt; widget.words.length; i&#x2B;&#x2B;) {&#xA;      final word = widget.words[i];&#xA;      final startTime = _formatAssTime(word[&#x27;startTime&#x27;].toDouble());&#xA;      final endTime = _formatAssTime(word[&#x27;endTime&#x27;].toDouble());&#xA;      final text = word[&#x27;word&#x27;];&#xA;&#xA;      buffer.writeln(&#x27;Dialogue: 0,$startTime,$endTime,Default,,0,0,0,,$text&#x27;);&#xA;    }&#xA;&#xA;    await file.writeAsString(buffer.toString());&#xA;    return filePath;&#xA;  }&#xA;&#xA;  String _formatAssTime(double seconds) {&#xA;    final int hours = seconds ~/ 3600;&#xA;    final int minutes = ((seconds % 3600) ~/ 60);&#xA;    final int secs = (seconds % 60).toInt();&#xA;    final int millis = ((seconds - secs) * 1000).toInt() % 1000;&#xA;&#xA;    return &#x27;${hours.toString().padLeft(1, &#x27;0&#x27;)}:${minutes.toString().padLeft(2, &#x27;0&#x27;)}:${secs.toString().padLeft(2, &#x27;0&#x27;)}.${(millis ~/ 10).toString().padLeft(2, &#x27;0&#x27;)}&#x27;;&#xA;  }&#xA;</string>

    &#xA;

    Then I used this command which was the official way of adding ass file to a video.

    &#xA;

      String newCmd = "-i $videoPath -vf ass=$assFilePath -c:a copy $_outputPath";&#xA;

    &#xA;

    Yet when executing this command it did not work. However I changed it to this command

    &#xA;

    String newCmd = "-i $videoPath -i $assFilePath $_outputPath";&#xA;

    &#xA;

    Well, that code works but the styling is not being applied. So I tried yet another command to filter and position the ass file.

    &#xA;

    String newCmd = "-i $videoPath -i $assFilePath -filter_complex \"[0:v][1:s]ass=\\an5:text=&#x27;%{event.text}&#x27;,scale=iw*0.8:ih*0.8,setdar=16/9[outv]\" -map [outv] -c:a copy $_outputPath";&#xA;

    &#xA;

    This made it even worse, because the app crashed when I ran this. Also there is a log for this command before crashing

    &#xA;

    F/libc    (19624): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x19 in tid 21314 (pool-4-thread-7), pid 19624 (ple.caption_app)&#xA;*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***&#xA;Build fingerprint: &#x27;samsung/a15nsxx/a15:14/UP1A.231005.007/A155FXXU1AWKA:user/release-keys&#x27;&#xA;Revision: &#x27;5&#x27;&#xA;ABI: &#x27;arm64&#x27;&#xA;Processor: &#x27;7&#x27;&#xA;Timestamp: 2024-07-10 19:27:40.812476860&#x2B;0300&#xA;Process uptime: 1746s&#xA;Cmdline: com.example.caption_app&#xA;pid: 19624, tid: 21314, name: pool-4-thread-7  >>> com.example.caption_app &lt;&lt;&lt;&#xA;uid: 10377&#xA;tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)&#xA;signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000019&#xA;Cause: null pointer dereference&#xA;    x0  0000000000000001  x1  b400006ec98d8660  x2  0000000000000000  x3  0000000000000002&#xA;    x4  0000006f62d1ea12  x5  b400006e04f745ea  x6  352f35372f64352f  x7  7f7f7f7f7f7f7f7f&#xA;    x8  632ace36577a905e  x9  632ace36577a905e  x10 0000006e191378c0  x11 0000000000000001&#xA;    x12 0000000000000001  x13 0000000000000000  x14 0000000000000004  x15 0000000000000008&#xA;    x16 0000006e27ffa358  x17 0000006e27dbfb00  x18 0000006e00d48000  x19 0000006f62d1f0e8&#xA;    x20 0000006f62d24000  x21 0000006e27ffc5d0  x22 0000006e27ffc5f0  x23 0000000000000000&#xA;    x24 b400006f3f089248  x25 0000006f62d1f220  x26 b400006f3f057b20  x27 0000000000000002&#xA;    x28 0000000000000088  x29 0000006f62d1f100&#xA;    lr  0000006e27dbfb0c  sp  0000006f62d1f0a0  pc  0000006e27dbfb10  pst 0000000060001000&#xA;1 total frames&#xA;backtrace:&#xA;      #00 pc 0000000000121b10  /data/app/~~oWqjrGA2indQhuEw6u_J2A==/com.example.caption_app-u2Ofk54FVtMc5D-i3SLC6g==/base.apk!libavfilter.so (offset 0x10a46000) (avfilter_inout_free&#x2B;16)    &#xA;Lost connection to device.&#xA;

    &#xA;

    I tried the normal command in my local machine on Windows, and this is what I used

    &#xA;

    ffmpeg -i F:\ffmpeg\video.avi -vf subtitles=&#x27;F\:\\ffmpeg\\caption.srt&#x27;:force_style=&#x27;Fontsize=24&#x27; F:\ffmpeg\new.mp4&#xA;

    &#xA;

    As you can see above when subtitles are used it had an extra backslashes for each path and a pre backslash after the partition letter. But I don't know if this does apply for android devices. How can I make sense of this ?

    &#xA;