Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (59)

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

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (9195)

  • Creating a shared library that statically includes ffmpeg

    10 octobre 2017, par El Sampsa

    I’m having hard time trying to create a shared library that has ffmpeg libraries "baked in" as static ones.

    Consider the following directory schema :

    include/
     my own .h files
     ext/
       ffmpeg .h files
    lib/
     libav*.a archive files (softlinks to the actual .a files)
     libValkka.so (my shared library)
    test/
     mytest.cpp
    bin/
     (binaries appear here)

    I’ve come a long way (see Including objects to a shared library from a C++ archive (.a) ) and the library compiles ok with this : ([STUFF] has been omitted for brevity)

    /usr/bin/c++ -fPIC -std=c++14 -pthread -Iinclude/ext -I/usr/include/libdrm -g -shared -Wl,-soname,libValkka.so -o lib/libValkka.so CMakeFiles/Valkka.dir/src/avthread.cpp.o CMakeFiles/Valkka.dir/src/opengl.cpp.o CMakeFiles/Valkka.dir/src/openglthread.cpp.o [STUFF] CMakeFiles/Valkka.dir/src/filters.cpp.o -lX11 -lGLEW -lGLU -lGL -Wl,—allow-multiple-definition -Wl,-Bsymbolic -Wl,—whole-archive -Wreorder lib/libavdevice.a lib/libavfilter.a lib/libavformat.a lib/libavcodec.a lib/libavutil.a lib/libswscale.a lib/libswresample.a -Wl,—no-whole-archive

    However, when creating executables - their source code does not use any ffmpeg api (just my own api) - with :

    c++ -std=c++14 -pthread -Iinclude -Iinclude/ext -Llib test/mytest.cpp -lValkka -g -o bin/mytest

    I get a hoard of errors about missing ffmpeg dependencies. Not everything is missing, just some weird stuff :

    lib/libValkka.so: undefined reference to `pa_stream_get_index'
    lib/libValkka.so: undefined reference to `deflateInit_'
    lib/libValkka.so: undefined reference to `pa_stream_get_state'
    lib/libValkka.so: undefined reference to `lzma_stream_decoder'
    lib/libValkka.so: undefined reference to `BZ2_bzDecompress'
    lib/libValkka.so: undefined reference to `vaInitialize'
    lib/libValkka.so: undefined reference to `pa_stream_unref'
    lib/libValkka.so: undefined reference to `deflateInit2_'
    lib/libValkka.so: undefined reference to `snd_pcm_close'
    ...
    lib/libValkka.so: undefined reference to `vaGetDisplayDRM'
    lib/libValkka.so: undefined reference to `vaMaxNumEntrypoints'
    lib/libValkka.so: undefined reference to `uncompress'
    lib/libValkka.so: undefined reference to `pa_stream_drop'
    lib/libValkka.so: undefined reference to `pa_context_connect'
    lib/libValkka.so: undefined reference to `FT_Get_Kerning'
    lib/libValkka.so: undefined reference to `ass_free_track'
    lib/libValkka.so: undefined reference to `pa_operation_unref'
    lib/libValkka.so: undefined reference to `FT_Stroker_Done'
    lib/libValkka.so: undefined reference to `vaTerminate'
    lib/libValkka.so: undefined reference to `ass_new_track'
    lib/libValkka.so: undefined reference to `jack_client_close'
    ...
    lib/libValkka.so: undefined reference to `xcb_xfixes_query_version'
    lib/libValkka.so: undefined reference to `xcb_shape_rectangles'
    lib/libValkka.so: undefined reference to `pa_mainloop_free'
    lib/libValkka.so: undefined reference to `snd_device_name_hint'
    lib/libValkka.so: undefined reference to `vaCreateImage'
    lib/libValkka.so: undefined reference to `vaBeginPicture'
    lib/libValkka.so: undefined reference to `DtsSetColorSpace'
    lib/libValkka.so: undefined reference to `vaDestroyConfig'
    lib/libValkka.so: undefined reference to `pa_stream_writable_size'
    lib/libValkka.so: undefined reference to `snd_pcm_hw_params_get_buffer_size_max'
    lib/libValkka.so: undefined reference to `ass_read_file'

    This is pretty frustrating, especially when I can see that those names are included in the shared library..!

    nm lib/libValkka.so | grep "vaBeginPicture"

    gives

    U vaBeginPicture

    etc. I thought it might be a problem regarding the dependency order the archive .a files, and also tried with :

    ..... -Wl,—allow-multiple-definition -Wl,-Bsymbolic -Wl,—start-group -Wl,—whole-archive -Wreorder lib/libavdevice.a lib/libavfilter.a lib/libavformat.a lib/libavcodec.a lib/libavutil.a lib/libswscale.a lib/libswresample.a -Wl,—no-whole-archive -Wl,—end-group

    But the problem persists.

    I have succesfully created a shared library that does not "bake in" those .a archives, i.e. that just depends dynamically on ffmpeg libraries, and there are no such problems.

    I am baffled.. Have I misunderstood something fundamental, forgot some annoying linked option, or both ? Help appreciated !

  • ffmpeg avcodec_open2() return error -22 only in ubuntu

    26 octobre 2020, par User800222

    AS title,

    


    I'm working on a project on Mac with ffmpeg. It runs on my Mac to encode frames to vp9 & vp8. But when I run it on my docker image in a ubuntu, the function avcodec_open2(), returns -22 error. (only for vp9&vp8, h264 works).

    


    I wonder if the error comes from the setting parameters part ? But it's still weird to have it working on mac but not in ubuntu.

    


    Does anyone has a similar experience ?

    


    bool open_video(AVFormatContext * oc,AVCodec * codec,OutputStream * ost,AVDictionary * opt_arg, bool reduceQuality) {
    int ret;
    AVCodecContext * c = ost->st->codec;
    AVDictionary * opt = NULL;
    av_dict_copy(&opt,opt_arg,0);

    if(codec264){
      // http://arstechnica.com/civis/viewtopic.php?f=6&t=1239375
      av_dict_set(&opt,"refs",    "3",          0);
      av_dict_set(&opt,"vprofile","main",       0);  // 2 versions to support differents libav/ffmpeg
      av_dict_set(&opt,"profile", "main",       0);
      
      //av_dict_set(&opt,"preset","superfast",0);
      //av_dict_set(&opt,"preset","ultrafast",0);
      av_dict_set(&opt,"preset","superfast",0);
      //av_dict_set(&opt,"preset","slow",0);
      
      //https://mattgadient.com/2013/06/12/a-best-settings-guide-for-handbrake-0-9-9/
      //av_dict_set(&opt, "tune", "zerolatency", 0); //bluerry but very small size
      //av_dict_set(&opt, "tune", "fastdecode", 0); // hd but large size
      // 23 300k, 29 150k, 35 75k
      if(reduceQuality)
        av_dict_set(&opt, "crf", "35", 0); //35 +-6 decrease/increase bitrate half/twice
      else
        av_dict_set(&opt, "crf", "29", 0); //29 +-6 decrease/increase bitrate half/twice
    
    }
    else if (codecVP9)
    { 
        // Setting explanation:
        // http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide
        // https://developers.google.com/media/vp9/live-encoding/
        // https://developers.google.com/media/vp9/settings/vod/
        // https://developers.google.com/media/vp9/bitrate-modes/

        if(reduceQuality) //crf is the quality value for VP9 (0-63), lower the better quality youll get 
          av_dict_set(&opt, "crf"    ,      "40",         0); 
        else
          av_dict_set(&opt, "crf"    ,      "45",         0);
        av_dict_set(&opt, "speed"  ,        "8" ,         0);
        av_dict_set(&opt, "quality",        "realtime",   0); //realtime is recommended
        //av_dict_set(&opt, "threads",        "4" ,         0);
        //av_dict_set(&opt, "tile-columns",   "2",          0);
        //av_dict_set(&opt, "frame-parallel", "1",          0);
        //av_dict_set(&opt, "row-mt",         "1",          0);
        av_dict_set(&opt, "b:v",            "1",         0);
        av_dict_set(&opt, "g",              "400",        0); //key frame interval (big difference in vid size)

        //av_dict_set(&opt, "maxrate",        "3k",         0);
        //av_dict_set(&opt, "minrate",        "1k",         0);
        //av_dict_set(&opt, "hwaccel",        "vaapi",      0);
        //av_dict_set(&opt, "c:v",            "libvpx-vp9", 0);
        
    }
    else if (codecVP8)
    {
        // https://trac.ffmpeg.org/wiki/Encode/VP8 
        av_dict_set(&opt, "passes"    ,        "1" ,         0);   
        av_dict_set(&opt, "cpu-used"  ,        "15" ,         0); 
        av_dict_set(&opt, "qmax"      ,        "63",         0);   
        av_dict_set(&opt, "rt"        ,          "",         0); // realtime setting
        //av_dict_set(&opt, "crf"       ,        "10",         0);   

        if(reduceQuality)
          av_dict_set(&opt, "qmin"     ,        "40",        0); // Lower quality, smaller sizes
        else
          av_dict_set(&opt, "qmin"     ,        "35",        0); // Higher quality, larger sizes
    }
    else 
    {
        if(reduceQuality)
            av_dict_set(&opt, "x265-params", "crf=29", 0);
        else
            av_dict_set(&opt, "x265-params", "crf=23", 0);
        
        av_dict_set(&opt, "preset", "ultrafast", 0);
        av_dict_set(&opt, "tune", "zerolatency", 0);
//        av_dict_set(&opt, "profile", "main", 0);
    }
      
    // Open the codec
    ret = avcodec_open2(c,codec,&opt);
    av_dict_free(&opt);
    if (ret < 0) {
        cout << "Could not open video codec. (error code:" << ret << ")\n";
        return false;
    } // if


    


    Edit : Does anyone know if the ffmpeg-linux using different parameters' name for setting from other platform's (like Mac) ?

    


    Eidt2 : It seems like even if I don't set any options parameters, it's still giving me -22 error. Ex : ret = avcodec_open2(c, codec, NULL)

    


  • How to update a byte array in a method, without running it again ?

    18 février 2016, par AR792

    I have a class(an AsyncTask) which does image processing and generates yuv bytes continously, at around 200ms interval.

    Now I send these yuv bytes to another method where the they are recorded using FFmpeg frame recorder :

    public void recordYuvData() {

           byte[] yuv = getNV21();
           System.out.println(yuv.length + "  returned yuv bytes  ");
           if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
               startTime = System.currentTimeMillis();
               return;
           }
           if (RECORD_LENGTH > 0) {
               int i = imagesIndex++ % images.length;
               yuvimage = images[i];
               timestamps[i] = 1000 * (System.currentTimeMillis() - startTime);
           }
           /* get video data */
           if (yuvimage != null && recording) {
               ((ByteBuffer) yuvimage.image[0].position(0)).put(yuv);

               if (RECORD_LENGTH <= 0) {
                   try {
                       long t = 1000 * (System.currentTimeMillis() - startTime);
                       if (t > recorder.getTimestamp()) {
                           recorder.setTimestamp(t);
                       }
                       recorder.record(yuvimage);
                   } catch (FFmpegFrameRecorder.Exception e) {

                       e.printStackTrace();
                   }
               }
           }
       }

    This method ; recordYuvData() is initiated on button click.

    1. If I initiate it only once , then only the initial image gets recorded, rest are not.

    2. If I initiate this each time after the end of the image processing it records but leads to ’weird’ fps count of the video ; and finally this leads to application crash after sometime.

      For above what I feel is, at the end of image processing a new instance of recordYuvData() is created without ending the previous one, accumulating many instances of recordYuvData(). [correct me if I am wrong]

    So, how do I update ’ONLY’ yuv bytes in the method without running it again ?

    Thanks....!

    Edit :

    On Click :

       record.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               recordYuvdata();
               startRecording();

    getNV21()

    byte[] getNV21(Bitmap bitmap) {

       int inputWidth = 1024;
       int inputHeight = 640;
       int[] argb = new int[inputWidth * inputHeight];

       bitmap.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight);
       System.out.println(argb.length + "@getpixels ");


       byte[] yuv = new byte[inputWidth * inputHeight * 3 / 2];
       encodeYUV420SP(yuv, argb, inputWidth, inputHeight);

       return yuv;

    }

    void encodeYUV420SP(byte[] yuv420sp, int[] argb, int width, int height) {
       final int frameSize = width * height;

       int yIndex = 0;
       int uvIndex = frameSize;
       System.out.println(yuv420sp.length + " @encoding " + frameSize);

       int a, R, G, B, Y, U, V;
       int index = 0;
       for (int j = 0; j < height; j++) {
           for (int i = 0; i < width; i++) {

               a = (argb[index] & 0xff000000) >> 24; // a is not used obviously
               R = (argb[index] & 0xff0000) >> 16;
               G = (argb[index] & 0xff00) >> 8;
               B = (argb[index] & 0xff) >> 0;

               // well known RGB to YUV algorithm

               Y = ((66 * R + 129 * G + 25 * B + 128) >> 8) + 16;
               U = ((-38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
               V = ((112 * R - 94 * G - 18 * B + 128) >> 8) + 128;

               // NV21 has a plane of Y and interleaved planes of VU each sampled by a factor of 2
               //    meaning for every 4 Y pixels there are 1 V and 1 U.  Note the sampling is every other
               //    pixel AND every other scanline.
               yuv420sp[yIndex++] = (byte) ((Y < 0) ? 0 : ((Y > 255) ? 255 : Y));
               if (j % 2 == 0 && index % 2 == 0) {
                   yuv420sp[uvIndex++] = (byte) ((V < 0) ? 0 : ((V > 255) ? 255 : V));
                   yuv420sp[uvIndex++] = (byte) ((U < 0) ? 0 : ((U > 255) ? 255 : U));
               }

               index++;
           }
       }
    }