Recherche avancée

Médias (0)

Mot : - Tags -/tags

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

Autres articles (111)

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

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

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

Sur d’autres sites (10724)

  • ffmpeg and boost::asio NULL pointer

    9 avril 2015, par Georgi

    I am trying to make a special video software which will run on multiple core machines.

    I want many c++ object to stream video files and many other c++ objects to store the streamed data into file.

    I have created some simple classes, but when I try to create 2 and more objects I got :

    opening stream9079.sdp
    [udp @ 0xaef5380] bind failed: Address already in use
    Could not open input file stream9079.sdp
    Segmentation fault (core dumped)

    When I use only one object everything is fine.

    I use the following code

    int main(int argc, char **argv)
    {
       boost::asio::io_service ios;
       boost::asio::io_service ios1;

       Channel *channels[100];

       channels[0] = new Channel(ios, 9078, atoi(argv[1]));
       channels[0]->StartTimer(0);

       channels[1] = new Channel(ios1, 9079, atoi(argv[1]));
       channels[1]->StartTimer(0);

       boost::thread t(boost::bind(&worker, &ios));
       boost::thread t1(boost::bind(&worker, &ios1));


       t.join();
       t1.join();

       CEVLOG_MSG << "done" << std::endl;

       return 0;
    }

    My Channel class implementation is :

    #include "channel.hpp"
    #include "utils.hpp"
    #include "boost/lexical_cast.hpp"
    Channel::Channel(boost::asio::io_service &ioP, int i, bool to_send):
       Runnable(ioP),
       work( new boost::asio::io_service::work(ioP) ),
       ofmt(NULL),
       ifmt_ctx(NULL),
       ofmt_ctx(NULL)
    {
       id = i;
       sender = to_send;

       if (sender)
       {
               input.assign("/home/georgi/Downloads/video/IMG_0019.MOV");
               output.assign("rtp://10.101.3.60:"); output += boost::lexical_cast(id);
       }
       else
       {
               input.assign("stream"); input += boost::lexical_cast(id); input += ".sdp";
               output.assign("test"); output += boost::lexical_cast(id); output += ".mp4";
       }

    video_idx = audio_idx = sub_idx = -1;

       if (OpenInput())
       {
               if (sender)
                       OpenOutput(eStreamOutput);
               else
                       OpenOutput(eFileOutput);
       }
    }

    Channel::~Channel()
    {
       av_write_trailer(ofmt_ctx);

       avformat_close_input(&ifmt_ctx);

       if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
               avio_closep(&ofmt_ctx->pb);

       avformat_free_context(ofmt_ctx);

       work.reset();
    }

    bool Channel::OpenInput()
    {
       CEVLOG_MSG << "opening " << input << std::endl;

       int ret;
       if ((ret = avformat_open_input(&ifmt_ctx, input.c_str(), 0, 0)) < 0)
       {
               CEVLOG_ERR << "Could not open input file " << input << std::endl;
               return false;
       }

       CEVLOG_MSG << " " << ifmt_ctx << std::endl;

       if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0)
       {
               CEVLOG_ERR << "Failed to retrieve input stream information" << std::endl;
               return false;
       }

       ifmt_ctx->flags |= AVFMT_FLAG_GENPTS;

       //read and set timestamps to 0
    av_read_frame(ifmt_ctx, &pkt);
    pkt.pts = pkt.dts = 0;

    return true;
    }

    bool Channel::OpenOutput(tOutputType WhatToOpen)
    {
       int SDP_size;

       switch (WhatToOpen)
       {
       case eFileOutput:
               avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, output.c_str());
               break;

       case eStreamOutput:
               avformat_alloc_output_context2(&ofmt_ctx, NULL, "rtp", output.c_str());

               char SDP[4096];
               SDP_size = 4096;

               av_sdp_create(&ofmt_ctx, 1, SDP, SDP_size);
               CEVLOG_DBG << "SDP=" << SDP << std::endl;
               break;

       default:
               assert(false);
               break;
       }

       if (!ofmt_ctx)
       {
               CEVLOG_ERR << "Could not create output context" << std::endl;
               return false;
       }

       ofmt = ofmt_ctx->oformat;

       video_idx = FindIndex(AVMEDIA_TYPE_VIDEO);

       if (!(ofmt->flags & AVFMT_NOFILE))
       {
               if (avio_open(&ofmt_ctx->pb, output.c_str(), AVIO_FLAG_WRITE) < 0)
               {
                       CEVLOG_ERR << "Could not open output file " << output << std::endl;
                       return false;
               }
       }

       if (avformat_write_header(ofmt_ctx, NULL) < 0)
       {
               CEVLOG_ERR << "Error occurred when opening output file " << output << std::endl;
               return false;
       }

       return true;
    }

    unsigned int Channel::FindIndex(AVMediaType Type)
    {
       int idx;

       for (idx = 0; idx < ifmt_ctx->nb_streams; idx++)
       {
               if (ifmt_ctx->streams[idx]->codec->codec_type == Type)
               {
                       AVStream *in_stream = ifmt_ctx->streams[idx];
                       AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);

                       if (!out_stream)
                       {
                               CEVLOG_ERR << "Failed allocating output stream" << std::endl;
                               break;
                       }

                       if (avcodec_copy_context(out_stream->codec, in_stream->codec) < 0)
                       {
                               CEVLOG_ERR << "Failed to copy context from input to output stream codec context" << std::endl;
                               break;
                       }

                       out_stream->codec->codec_tag = 0;
                       if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
                       {
                               out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
                       }

                       break;
               }
       }

       return idx;
    }

    void Channel::Callback()
    {
       if (sender)
               SendVideo();
       else
               RecvVideo();
    }

    void Channel::SendVideo()
    {
       int ret = av_read_frame(ifmt_ctx, &pkt);
       int time_ms = 0;

       if (ret != 0)
       {
               av_write_trailer(ofmt_ctx);
               work.reset();
               return;
       }

       if (pkt.stream_index == video_idx)
       {
               AVStream *in_stream  = ifmt_ctx->streams[pkt.stream_index];
               AVStream *out_stream = ofmt_ctx->streams[pkt.stream_index];

               AVRational time_base = ifmt_ctx->streams[video_idx]->time_base;

               char timestamp[100];
               time_ms = 1000 * 1000 * strtof(timestamp2char(timestamp, pkt.duration, &time_base), NULL);

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

               ret = av_interleaved_write_frame(ofmt_ctx, &pkt);

               if (ret < 0)
               {
                       CEVLOG_ERR << "Error muxing packet" << std::endl;
                       return;
               }
       }

       av_free_packet(&pkt);

       StartTimer(time_ms);
    }

    void Channel::RecvVideo()
    {
       int ret = av_read_frame(ifmt_ctx, &pkt);

       if (ret != 0)
       {
               //Some error or end of stream is detected. Write file trailer
               av_write_trailer(ofmt_ctx);
               work.reset();
               return;
       }

       //if is NOT video just continue reading
       if (pkt.stream_index == video_idx)
       {
               AVStream *in_stream  = ifmt_ctx->streams[pkt.stream_index];
               AVStream *out_stream = ofmt_ctx->streams[pkt.stream_index];

               AVRational time_base = ifmt_ctx->streams[video_idx]->time_base;

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

               ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
               if (ret < 0)
               {
                       CEVLOG_ERR << "Error muxing packet" << std::endl;
                       return;
               }
       }

       av_free_packet(&pkt);

       StartTimer(0);
    }
  • avcodec/frame_thread_encoder : Avoid dictionaries

    11 mai 2021, par Andreas Rheinhardt
    avcodec/frame_thread_encoder : Avoid dictionaries
    

    avcodec_open2() allows to provide options via an AVDictionary ;
    but it is also allowed to set options by simply setting the value
    of the AVCodecContext or via the AVOptions API if the codec has
    a private class. Any options provided via an AVDictionary have already
    been applied before ff_frame_thread_init(), so in order to copy
    all the options from the main AVCodecContext and its private context,
    it is enough to av_opt_copy() these options.

    The current code does this, but it does more : It also copies the
    user-provided AVDictionary and uses it for the initialization of
    each of the worker-AVCodecContexts. This is completely unnecessary,
    because said options have already been copied from the main context.

    Furthermore, these options were also examined to decide if frame
    threading should be used for huffman encoding in case this would incur
    nondeterminism. This is wrong, because options not set via
    an AVDictionary are ignored. Instead inspect the values stored in the
    contexts directly. (In order to maintain the current behaviour, the
    default value of the "non_deterministic" option has been changed to false,
    because the absence of an entry with said key in the AVDictionary
    had the consequence of disallowing nondeterminism.)

    Finally, the AVDictionary has been removed from the signature of
    ff_frame_thread_encoder_init().

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/avcodec.c
    • [DH] libavcodec/frame_thread_encoder.c
    • [DH] libavcodec/frame_thread_encoder.h
    • [DH] libavcodec/huffyuvenc.c
  • FFMPeg exception setDataSource failed : status = 0xFFFFFFFF

    11 septembre 2019, par guensuanhoa

    I have 175 mp4 files. When I process file from index 0 to index 65 (or 66), I get exception :

    java.lang.IllegalArgumentException: setDataSource failed: status = 0xFFFFFFFF
    at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource(Native Method)
    at com.jni.utils.Mp4ParserUsingFFMpeg.createThumbnail(Mp4ParserUsingFFMpeg.java:518)
    at com.example.readmdtfile.activity.MainActivity$createMp4Async.createThumbnail(MainActivity.java:71)
    at com.example.readmdtfile.activity.MainActivity$createMp4Async.doInBackground(MainActivity.java:55)
    at com.example.readmdtfile.activity.MainActivity$createMp4Async.doInBackground(MainActivity.java:1)
    at android.os.AsyncTask$2.call(AsyncTask.java:288)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:841)

    If I run process from index 65 (or nearby), processing file 65 is successful. But it still get exception sometimes
    Here is code which i’m using :

    public static Bitmap createThumbnail (String videoPath) {
       FFmpegMediaMetadataRetriever retriever = new  FFmpegMediaMetadataRetriever();
       Bitmap bitmap = null;
       try {
           retriever.setDataSource(videoPath); //file's path
           String key;
           String value;
           for (int i = 0; i &lt; MetadataKey.METADATA_KEYS.length; i++) {
               key = MetadataKey.METADATA_KEYS[i];
               value = retriever.extractMetadata(key);
               if (value != null) {
                   // metadata.add(new Metadata(key, value));
                   Log.i(TAG, "Key: " + key + " Value: " + value);
               }
           }

           bitmap = retriever.getFrameAtTime();

           if (bitmap != null) {
               Log.d(TAG, "Extracted frame");
               Bitmap b2 = retriever.getFrameAtTime(4000000,
                       FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC);
               if (b2 != null) {
                   bitmap = b2;
               }
           } else {
               Log.d(TAG, "Failed to extract frame");
           }
       } catch (Exception e) {
           e.printStackTrace();
       } finally {
           retriever.release();
       }

       return bitmap;
    }

    https://github.com/wseemann/FFmpegMediaMetadataRetriever/issues/59

    Please help me.