Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (42)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Les thèmes de MediaSpip

    4 juin 2013

    3 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
    Thèmes MediaSPIP
    3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...)

Sur d’autres sites (4833)

  • ffmpeg ndk multiple definition libavcodec.a(golomb.o)

    4 décembre 2014, par WLGfx

    I’m trying to link ffmpeg as static libraries with android NDK but I’m getting ’multiple definition’ error’ errors as below. I’ve also included my build script which runs through everything just fine but when I come to using the libraries in Eclipse with the ADT plugin, I can’t get anywhere.

    From this it looks like it wants something to do with VLC. I don’t want anything to do with VLC, just ffmpeg for video streaming. Everything works fine with shared libraries, but I’m after a very tiny player because I’m restricted to space on the device.

    EDIT : Also ’log2_tab_tab.o’ has multiple definitions.

    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_golomb_vlc_len'  Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_dirac_golomb_vlc_code'   Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_golomb_vlc_len'  Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_se_golomb_vlc_code'  Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_ue_golomb_vlc_code'  Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_se_golomb_vlc_code'  Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_ue_golomb_len'   Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_ue_golomb_vlc_code'  Ffplayer            C/C++ Problem
    error: jni/libs\libavcodec.a(log2_tab.o): multiple definition of 'ff_log2_tab'  Ffplayer            C/C++ Problem
    error: jni/libs\libavformat.a(log2_tab.o): multiple definition of 'ff_log2_tab' Ffplayer            C/C++ Problem
    jni/libs\libavformat.a(golomb_tab.o): previous definition here  Ffplayer            C/C++ Problem
    jni/libs\libavutil.a(log2_tab.o): previous definition here  Ffplayer            C/C++ Problem
    make.exe: *** [obj/local/armeabi-v7a-hard/libffplayer.so] Error 1   Ffplayer            C/C++ Problem

    Using the latest branch of ffmpeg (2.4.3) my build script for Android (using toolchain 8 because it’s old hardware I’m working with) and wanting the NEON hardware support :

    export ANDROID_NDK=/home/carl/dev/ndk
    export TOOLCHAIN=/home/carl/temp/ffmpeg
    export SYSROOT=$TOOLCHAIN/sysroot/
    $ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
       --platform=android-8 --install-dir=$TOOLCHAIN

    export PATH=$TOOLCHAIN/bin:$PATH
    export CC=arm-linux-androideabi-gcc
    export LD=arm-linux-androideabi-ld
    export AR=arm-linux-androideabi-ar

    CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \
     -finline-limit=300 -ffast-math \
     -fstrict-aliasing -Werror=strict-aliasing \
     -fmodulo-sched -fmodulo-sched-allow-regmoves \
     -Werror=implicit-function-declaration \
     -Wno-psabi -Wa,--noexecstack"
    #  -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ \
    #  -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ \
    #  -DANDROID -DNDEBUG"

    EXTRA_CFLAGS="-march=armv7-a -mfpu=neon \
                 -mfloat-abi=softfp -mvectorize-with-neon-quad \
                 -DHAVE_ISNAN -DHAVE_ISINF
                 -std=c99"
    EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"

    FFMPEG_FLAGS="--prefix=/home/dev/ffmpeg/build \
     --target-os=linux \
     --arch=arm \
     --enable-cross-compile \
     --cross-prefix=arm-linux-androideabi- \
     --enable-shared \
     --enable-static \
     --enable-small \
     --disable-symver \
     --disable-doc \
     --disable-ffplay \
     --disable-ffmpeg \
     --disable-ffprobe \
     --disable-ffserver \
     --disable-avdevice \
     --disable-avfilter \
     --disable-encoders  \
     --disable-muxers \
     --disable-demuxers \
     --disable-filters \
     --disable-devices \
     --disable-decoders \
     --enable-decoder=mjpeg \
     --enable-decoder=mp1 \
     --enable-decoder=mp2 \
     --enable-decoder=mp3 \
     --enable-decoder=mpeg1_vdpau \
     --enable-decoder=mpeg1video \
     --enable-decoder=mpeg2video \
     --enable-decoder=mpeg4 \
     --enable-decoder=mpeg4_vdpau \
     --enable-decoder=mpegvideo \
     --enable-decoder=mpeg_xvmc \
     --enable-decoder=h261 \
     --enable-decoder=h263 \
     --enable-decoder=h263i \
     --enable-decoder=h263p \
     --enable-hwaccel=h263_vaapi \
     --enable-hwaccel=h263_vdpau \
     --enable-hwaccel=mpeg1_vdpau \
     --enable-hwaccel=mpeg1_xvmc \
     --enable-hwaccel=mpeg2_dxva2 \
     --enable-hwaccel=mpeg2_vaapi \
     --enable-hwaccel=mpeg2_vdpau \
     --enable-hwaccel=mpeg2_xvmc \
     --enable-hwaccel=mpeg4_vaapi \
     --enable-hwaccel=mpeg4_vdpau \
     --enable-demuxer=aac \
     --enable-demuxer=ac3 \
     --enable-demuxer=h261 \
     --enable-demuxer=h263 \
     --enable-demuxer=pcm_s16be \
     --enable-demuxer=pcm_s16le \
     --enable-demuxer=pcm_s8 \
     --enable-demuxer=mpegps \
     --enable-demuxer=mpegts \
     --enable-demuxer=mpegtsraw \
     --enable-demuxer=mpegvideo \
     --enable-demuxer=rtp \
     --enable-demuxer=rtsp \
     --enable-parser=aac \
     --enable-parser=mpegvideo \
     --enable-parser=ac3 \
     --enable-parser=h261 \
     --enable-parser=h263 \
     --enable-parser=mjpeg \
     --enable-parser=mpeg4video \
     --enable-parser=mpegaudio \
     --enable-protocol=rtp \
     --enable-protocol=file \
     --enable-protocol=ftp \
     --enable-protocol=tcp \
     --enable-protocol=http \
     --enable-protocol=udp \
     --enable-protocol=pipe \
     --enable-protocol=unix \
     --enable-network \
     --disable-swscale  \
     --enable-asm \
     --enable-memalign-hack \
     --disable-golomb \
     --enable-stripping \
     --enable-pthreads \
     --disable-symver \
     --enable-version3"

    ./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" \
     --extra-ldflags="$EXTRA_LDFLAGS"

    make clean
    echo "Project now cleaned"
    make -j4

    echo "Stripping multiple references from libraries"
    arm-linux-androideabi-ar d libavcodec.a log2_tab.o
    arm-linux-androideabi-ar d libavutil.a log2_tab.o

    echo "Done..."

    And this is the Android.mk file which works fine.

    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)
    LOCAL_MODULE    := avutil
    LOCAL_SRC_FILES := libs\libavutil.a
    include $(PREBUILT_STATIC_LIBRARY)

    include $(CLEAR_VARS)
    LOCAL_MODULE    := avformat
    LOCAL_SRC_FILES := libs\libavformat.a
    include $(PREBUILT_STATIC_LIBRARY)

    include $(CLEAR_VARS)
    LOCAL_MODULE    := avcodec
    LOCAL_SRC_FILES := libs\libavcodec.a
    include $(PREBUILT_STATIC_LIBRARY)

    include $(CLEAR_VARS)

    LOCAL_MODULE    := ffplayer
    LOCAL_SRC_FILES := ffplayer.cpp

    LOCAL_C_INCLUDES := C:\DEV\ffmpeg\

    LOCAL_LDLIBS    += -llog -ljnigraphics -lGLESv2 -ldl
    LOCAL_LDLIBS    += -lstdc++ -lc
    LOCAL_LDLIBS    += -lz -lm

    LOCAL_WHOLE_STATIC_LIBRARIES += libavutil libavformat libavcodec

    include $(BUILD_SHARED_LIBRARY)

    If anybody can spot what’s wrong with this it would be so appreciated.

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

  • How to convert H264 RTP stream from PCAP to a playable video file

    7 novembre 2017, par yoosha

    I have captured stream of H264 in PCAP files and trying to create media files from the data. The container is not important (avi,mp4,mkv,…).
    When I’m using videosnarf or rtpbreak (combined with python code that adds 00 00 00 01 before each packet) and then ffmpeg, the result is OK only if the input frame rate is constant (or near constant). However, when the input is vfr, the result plays too fast (and on same rare cases too slow).
    For example :

    videosnarf -i captured.pcap –c
    ffmpeg -i H264-media-1.264 output.avi

    After doing some investigation of the issue I believe now that since the videosnarf (and rtpbreak) are removing the RTP header from the packets, the timestamp is lost and ffmpeg is referring to the input data as cbr.

    1. I would like to know if there is a way to pass (on a separate file ?)
      the timestamps vector or any other information to ffmpeg so the
      result will be created correctly ?
    2. Is there any other way I can take the data out of the PCAP file and play it or convert it and then play it ?
    3. Since all work is done in Python, any suggestion of libraries/modules that can help with the work (even if requires some codding) is welcome as well.

    Note : All work is done offline, no limitations on the output. It can be cbr/vbr, any playable container and transcoding. The only "limitation" I have : it should all run on linux…

    Thanks
    Y

    Some additional information :
    Since the nothing provides the FFMPEG with the timestamp data, i decided to try a different approach : skip videosnarf and use Python code to pipe the packets directly to ffmpeg (using the "-f -i -" options) but then it refuses to accept it unless I provide an SDP file...
    How do I provide the SDP file ? is it an additional input file ? ("-i config.sdp")

    The following code is an unsuccessful try doing the above :

    import time  
    import sys  
    import shutil  
    import subprocess  
    import os  
    import dpkt  

    if len(sys.argv) &lt; 2:  
       print "argument required!"  
       print "txpcap <pcap file="file">"  
       sys.exit(2)  
    pcap_full_path = sys.argv[1]  

    ffmp_cmd = ['ffmpeg','-loglevel','debug','-y','-i','109c.sdp','-f','rtp','-i','-','-na','-vcodec','copy','p.mp4']  

    ffmpeg_proc = subprocess.Popen(ffmp_cmd,stdout = subprocess.PIPE,stdin = subprocess.PIPE)  

    with open(pcap_full_path, "rb") as pcap_file:  
       pcapReader = dpkt.pcap.Reader(pcap_file)  
       for ts, data in pcapReader:  
           if len(data) &lt; 49:  
               continue  
           ffmpeg_proc.stdin.write(data[42:])

    sout, err = ffmpeg_proc.communicate()  
    print "stdout ---------------------------------------"  
    print sout  
    print "stderr ---------------------------------------"  
    print err  
    </pcap>

    In general this will pipe the packets from the PCAP file to the following command :

    ffmpeg -loglevel debug -y -i 109c.sdp -f rtp -i - -na -vcodec copy p.mp4

    SDP file : [RTP includes dynamic payload type # 109, H264]

    v=0
    o=- 0 0 IN IP4 ::1
    s=No Name
    c=IN IP4 ::1
    t=0 0
    a=tool:libavformat 53.32.100
    m=video 0 RTP/AVP 109
    a=rtpmap:109 H264/90000
    a=fmtp:109
    packetization-mode=1 ;profile-level-id=64000c ;sprop-parameter-sets=Z2QADKwkpAeCP6wEQAAAAwBAAAAFI8UKkg==,aMvMsiw= ;
    b=AS:200

    Results :

    ffmpeg version 0.10.2 Copyright (c) 2000-2012 the FFmpeg developers
    built on Mar 20 2012 04:34:50 with gcc 4.4.6 20110731 (Red Hat
    4.4.6-3) configuration : —prefix=/usr —libdir=/usr/lib64 —shlibdir=/usr/lib64 —mandir=/usr/share/man —enable-shared —enable-runtime-cpudetect —enable-gpl —enable-version3 —enable-postproc —enable-avfilter —enable-pthreads —enable-x11grab —enable-vdpau —disable-avisynth —enable-frei0r —enable-libopencv —enable-libdc1394 —enable-libdirac —enable-libgsm —enable-libmp3lame —enable-libnut —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libopenjpeg —enable-librtmp —enable-libschroedinger —enable-libspeex —enable-libtheora —enable-libvorbis —enable-libvpx —enable-libx264 —enable-libxavs —enable-libxvid —extra-cflags=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector —param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC’ —disable-stripping libavutil 51. 35.100 / 51. 35.100 libavcodec 53. 61.100 / 53. 61.100 libavformat 53. 32.100
    / 53. 32.100 libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 61.100 / 2. 61.100 libswscale 2. 1.100
    / 2. 1.100 libswresample 0. 6.100 / 0. 6.100
    libpostproc 52. 0.100 / 52. 0.100 [sdp @ 0x15c0c00] Format sdp
    probed with size=2048 and score=50 [sdp @ 0x15c0c00] video codec set
    to : h264 [NULL @ 0x15c7240] RTP Packetization Mode : 1 [NULL @
    0x15c7240] RTP Profile IDC : 64 Profile IOP : 0 Level : c [NULL @
    0x15c7240] Extradata set to 0x15c78e0 (size : 36) !error,_recognition
    separate : 1 ; 1 [h264 @ 0x15c7240] error,_recognition combined : 1 ;
    10001 [sdp @ 0x15c0c00] decoding for stream 0 failed [sdp @
    0x15c0c00] Could not find codec parameters (Video : h264) [sdp @
    0x15c0c00] Estimating duration from bitrate, this may be inaccurate
    109c.sdp : could not find codec parameters Traceback (most recent
    call last) : File "./ffpipe.py", line 26, in
    ffmpeg_proc.stdin.write(data[42 :]) IOError : [Errno 32] Broken pipe

    (forgive the mass above, the editor keep on complaining about code that is not indented OK ??)

    I’m working on this issue for days... any help/suggestion/hint will be appreciated.