Recherche avancée

Médias (0)

Mot : - Tags -/objet éditorial

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

Autres articles (103)

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

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

Sur d’autres sites (15773)

  • Transcoding video using ffmpeg from the internet or over http

    19 juillet 2015, par Robin

    I have a project for transcoding videos. Right now I am passing the absolute path of the video as the input variable, as such :

    inputfile = str(MEDIA_ROOT)+'/'+str(video.original_video)

    Here the MEDIA_ROOT is /home/user/code/Project/Viu/static/media

    And then

    subprocess.call(
           'ffmpeg -i '+ inputfile +' -codec:v libx264 -crf 23 -preset faster -codec:a libfdk_aac -vbr 4 \-movflags faststart -vf scale="720:trunc(ow/a/2)*2",format=yuv420p '+ outputfile,
           shell=True
       )

    This is ok for now. But I will be keeping those videos on different location from the server, how can I convert videos from that location over the internet or http?

    I tried this :

    inputfile = 'http://localhost:8000/media/'+str(video.original_video)

    But I get this error :

    [2015-07-19 13:27:14,933: INFO/MainProcess] Received task: vids.tasks.convert_video[41e36bc6-0d6a-4756-99fb-cb8005a4fbe3]
    [2015-07-19 13:27:14,944: INFO/Worker-2] running
    ffmpeg version N-73632-g39a04eb Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
     configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
     libavutil      54. 28.100 / 54. 28.100
     libavcodec     56. 47.100 / 56. 47.100
     libavformat    56. 40.100 / 56. 40.100
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 21.100 /  5. 21.100
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  2.100 /  1.  2.100
     libpostproc    53.  3.100 / 53.  3.100
    [h264 @ 0x9d46060] AVC: nal size 371788
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -530775991
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 1666002647
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -1986130888
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -710433401
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -723464079
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 378679291
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 1766542096
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -470898291
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -402699497
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 64441658
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 1892506351
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 1362707160
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -1845744002
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -327264949
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -14647022
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 332446592
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -673972274
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 2091272674
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -1219100086
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -1117890504
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -1221891828
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 1674360084
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size 1114909540
    [h264 @ 0x9d46060] no frame!
    [h264 @ 0x9d46060] AVC: nal size -1619615275
    [h264 @ 0x9d46060] no frame!
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x9d43be0] decoding for stream 0 failed
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x9d43be0] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(bt470bg/bt709/bt709), 1920x1080, 43842 kb/s): unspecified pixel format
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://localhost:8000/media/uploaded_files/1437312433_3_test1.MOV':
     Metadata:
       major_brand     : qt  
       minor_version   : 537331968
       compatible_brands: qt  CAEP
       creation_time   : 2014-07-25 22:11:02
     Duration: 00:00:48.68, start: 0.000000, bitrate: 8611 kb/s
       Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none(bt470bg/bt709/bt709), 1920x1080, 43842 kb/s, 25 fps, 25 tbr, 25k tbn, 50k tbc (default)
       Metadata:
         creation_time   : 2014-07-25 22:11:02
       Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
       Metadata:
         creation_time   : 2014-07-25 22:11:02
    [buffer @ 0x9d47c40] Unable to parse option value "-1" as pixel format
       Last message repeated 1 times
    [buffer @ 0x9d47c40] Error setting option pix_fmt to value -1.
    [graph 0 input from stream 0:0 @ 0x9de4d00] Error applying options to the filter.
    Error opening filters!

    I will really appreciate your help and guidance. Thank you.

  • What to do when last_pts > current_pts using ffmpeg libs (C++)

    11 mars 2015, par Rafael Lucio

    Im having some hard time figuring out where to find about this..

    Im building a simple recorder to learn about this video compression universe and Im facing some weird behaviors..

    Before all I need to explain the scenario...

    Its very simple... everytime I call av_read_frame( input_context, input_packet ) I save the pts into the last_pts variable...

    So...

    Whats bothering me is the fact that about 10% of my calls to av_read_frame I get
    input_packet.pts > last_pts

    Resulting in a error message from the encoder when I try to do it...
    Having it in mind I decided to just drop those frames when it happens....

    I think it is not a good idea to just drop frames because if I get them, its needed somehow...

    So... what to do when last_pts > current_pts ?

    I will paste my test code that Im using capturing the video from webcam and saving to mp4 file with libx264 encoder

    #include <qcoreapplication>

    extern "C" {
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libavutil></libavutil>avutil.h>
    #include <libavdevice></libavdevice>avdevice.h>
    }

    #include <qtime>
    #include <qthread>
    #include <qdebug>

    #define SM_DEBUG

    static const double max_fps = 30;
    static const double min_loop_duration = 1000 / max_fps;
    static const double max_duration = 5; // in seconds

    static void sleep_if_needed(const int &amp;elapsed) {
       int sleep_duration = min_loop_duration - elapsed;

       if (sleep_duration > 0)  {
           QThread::msleep(sleep_duration);
       }
    }

    #ifdef SM_DEBUG
    static void log_packet(const AVPacket *pkt,
                          const AVRational &amp;time_base,
                          int is_input=0)
    {

       qDebug() &lt;&lt; ((is_input) ? QString(">>") : QString("&lt;&lt;"))  &lt;&lt; "Size:" &lt;&lt; QString::number(pkt->size) &lt;&lt;
           "pts:" &lt;&lt; QString::number(pkt->pts) &lt;&lt;
           "pts_time:" &lt;&lt; QString::number(av_q2d(time_base) * pkt->pts) &lt;&lt;
           "dts:" &lt;&lt; QString::number(pkt->dts) &lt;&lt;
           "dts_time:" &lt;&lt; QString::number(av_q2d(time_base) * pkt->dts);
    }
    #endif

    int main()
    {
       int input_w, input_h, output_w = 640, output_h = 480;

       av_register_all();
       avdevice_register_all();
       avcodec_register_all();
    #ifdef SM_DEBUG
       av_log_set_level(AV_LOG_DEBUG);
    #else
       av_log_set_level(AV_LOG_ERROR);
    #endif

       AVFormatContext *ic;
       AVFormatContext *oc;

       AVInputFormat *ifmt;

       AVDictionary *opts = 0;

       AVCodecContext* dec_ctx;
       AVCodecContext* enc_ctx;
       AVCodec *dec;
       AVCodec *enc;

       AVStream* ist;
       AVStream* ost;

       ifmt = av_find_input_format("v4l2");

       av_dict_set(&amp;opts, "tune", "zerolatency", AV_DICT_APPEND);
       ic = avformat_alloc_context();

       ic->flags |= AVFMT_FLAG_NONBLOCK;

       avformat_open_input(&amp;ic, "/dev/video0", ifmt, &amp;opts);

       avformat_find_stream_info(ic, NULL);

       av_dump_format(ic, 0, ic->filename, 0);

       AVFrame *frame;
       AVFrame *tmp_frame;

       ist = ic->streams[0];

       dec_ctx =  ist->codec;

       input_w = dec_ctx->width;
       input_h = dec_ctx->height;

       dec_ctx->flags |= CODEC_FLAG_LOW_DELAY;
       dec = avcodec_find_decoder(dec_ctx->codec_id);

       av_format_set_video_codec(ic, dec);
       avcodec_open2(dec_ctx, dec, NULL);

       // output

       avformat_alloc_output_context2(&amp;oc, NULL, "MP4", "/home/poste9/grava.mp4");

       enc = avcodec_find_encoder(AV_CODEC_ID_H264);
       ost = avformat_new_stream(oc, enc);
       enc_ctx = ost->codec;

       enc_ctx->codec_id = AV_CODEC_ID_H264;
       enc_ctx->width = output_w;
       enc_ctx->height = output_h;

       ost->time_base.num = ist->time_base.num;
       ost->time_base.den = ist->time_base.den;

       enc_ctx->time_base = ost->time_base;

       enc_ctx->gop_size = 250;
       enc_ctx->keyint_min = 25;
       enc_ctx->qmax = 51;
       enc_ctx->qmin = 30;
       enc_ctx->pix_fmt = AV_PIX_FMT_YUV422P;
       enc_ctx->max_b_frames = 6;
       enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
       enc_ctx->flags |= CODEC_FLAG_LOW_DELAY;

       avcodec_open2(enc_ctx, enc, NULL);

       avio_open2(&amp;oc->pb, oc->filename, AVIO_FLAG_WRITE,
                  &amp;oc->interrupt_callback, NULL);

       av_dump_format(oc, 0, oc->filename, 1);

       avformat_write_header(oc, NULL);

       struct SwsContext *sws_ctx;

       sws_ctx = sws_getContext(input_w, input_h,
                                dec_ctx->pix_fmt,
                                output_w, output_h, enc_ctx->pix_fmt,
                                SWS_BICUBIC, NULL, NULL, NULL);

       frame = av_frame_alloc();
       tmp_frame = av_frame_alloc();

       frame->format = enc_ctx->pix_fmt;
       frame->width = output_w;
       frame->height = output_h;
       frame->pts = AV_NOPTS_VALUE;

       av_frame_get_buffer(frame, 32);
       av_frame_make_writable(frame);

       int got_picture=0;
       int got_packet=0;

       double recording_duration = 0;

       QTime timer;

       AVPacket pkt_out;

       av_init_packet(&amp;pkt_out);

       timer.start();

       bool started_recording = false;

       int64_t start_time = 0;

       int64_t last_pts = INT64_MIN;

       while(1) {
           timer.restart();
           AVPacket pkt_in;

           av_read_frame(ic, &amp;pkt_in);

           if (pkt_in.size == 0) {
               sleep_if_needed(timer.elapsed());
               continue;
           }

           avcodec_decode_video2(dec_ctx, tmp_frame, &amp;got_picture, &amp;pkt_in);

    #ifdef SM_DEBUG
           log_packet(&amp;pkt_in, ist->time_base, 1);
    #endif

           if (!started_recording) {

               start_time = pkt_in.dts;
               started_recording = true;
           }

           if (pkt_in.pts &lt; last_pts) {

               sleep_if_needed(timer.elapsed());

               continue;
           }

           last_pts = pkt_in.pts;

           frame->pts = (pkt_in.dts - start_time);

           if (!got_picture) {

               av_free_packet(&amp;pkt_in);

               sleep_if_needed(timer.elapsed());

               continue;
           } else {
               sws_scale(sws_ctx, tmp_frame->data, tmp_frame->linesize,
                 0, input_h, frame->data, frame->linesize);

               av_free_packet(&amp;pkt_in);
           }

           av_init_packet(&amp;pkt_out);

           avcodec_encode_video2(enc_ctx, &amp;pkt_out, frame, &amp;got_packet);

           if (got_packet) {

               if (pkt_out.pts &lt; pkt_out.dts) {
                   pkt_out.dts = pkt_out.pts;
               }

               pkt_out.stream_index = 0;

               recording_duration = pkt_out.pts * av_q2d(ost->time_base);
    #ifdef SM_DEBUG
               log_packet(&amp;pkt_out, ost->time_base, 0);
    #endif

               av_interleaved_write_frame(oc, &amp;pkt_out);

               av_free_packet(&amp;pkt_out);
           }

           if (recording_duration >= max_duration) {

               break;

           } else {

               sleep_if_needed(timer.elapsed());
           }
       }

       av_write_trailer(oc);

       av_dict_free(&amp;opts);

       av_frame_free(&amp;frame);
       av_frame_free(&amp;tmp_frame);

       sws_freeContext(sws_ctx);

       avcodec_close(dec_ctx);
       avcodec_close(enc_ctx);

       avio_close(oc->pb);
       avformat_free_context(oc);

       avformat_close_input(&amp;ic);

       return 0;
    }
    </qdebug></qthread></qtime></qcoreapplication>
  • C++/OpenCV - VideoCapture doesn't work but it worked before with exactly the same code

    5 mars 2015, par Damià Obrador

    I’m trying to write a shot boundary detection algorithm in C++ using OpenCV. After all, I have to say that I have no experience working with OpenCV.

    I have been improving the following code (and I am still in it) during the last two weeks and everything seems the works correctly, not in terms of perfect shot detection, but every line of code did what was expected from it.

    #include <cstdlib>
    #include <opencv2></opencv2>opencv.hpp>
    #include <opencv2></opencv2>core/core.hpp>
    #include <opencv2></opencv2>video/background_segm.hpp>
    #include <opencv2></opencv2>highgui/highgui.hpp>
    #include <iostream>
    #include <opencv2></opencv2>imgproc/imgproc.hpp>
    #include
    #include <istream>
    #include <fstream>
    using namespace cv;



    int main(){

       VideoCapture capture("vdevendetta.mp4");
       if ( !capture.isOpened() )
        {
            std::cout &lt;&lt; "Cannot open the video file";
            return -1;
        }
       int numFrames=capture.get(CV_CAP_PROP_FRAME_COUNT);
       bool SB_counter=false;
       Mat currentFrame;
       Mat frame;
       Mat fore;
       Mat back;
       vector<mat> frames;
       FileStorage file;
       FileStorage file2;
       Mat prev_Y;
       Mat channels[3];
       for(int i=0;i>currentFrame;
               frame=currentFrame.clone();
               cvtColor(frame,frame,CV_BGR2YUV);
               split( frame, channels );
               prev_Y=channels[0];
               SB_counter=false;
           }
           else
           {
               capture>>currentFrame;
               frame=currentFrame.clone();
               Mat channels[3];
               cvtColor(frame,frame,CV_BGR2YUV);
               split( frame, channels );
               Mat curr_Y=channels[0];
               channels[0]=prev_Y;
               prev_Y=curr_Y;
               merge(channels,3,frame);
               cvtColor(frame,frame,CV_Luv2BGR);
               cvtColor(frame,frame,CV_BGR2GRAY);
               frames.push_back(frame);
           }

       }

       vector<double> MAFDs;
       vector<double> MAFD;
       vector<double> aux;
       double min;
       double min2;

       for(int j=1;j14)
           {
               std::cout&lt;&lt;"De"&lt;*
       std::ofstream fout("MAFD.txt");
       if(fout.is_open()==true)
       {
         //file opened successfully so we are here
         std::cout &lt;&lt; "File Opened successfully!!!. Writing data from array to file" &lt;&lt; std::endl;

           for(int i = 0; MAFD[i] != '\0'; i++)
           {
           fout &lt;&lt; MAFD[i]; //writing ith character of array in the file
           }
         std::cout &lt;&lt; "Array data successfully saved into the file test.txt" &lt;&lt; std::endl;
       }
       else //file could not be opened
       {
           std::cout &lt;&lt; "File could not be opened." &lt;&lt; std::endl;
       }*/
       return 0;
    }
    </double></double></double></mat></fstream></istream></iostream></cstdlib>

    Three days ago I had an strange problem. The line :

    VideoCapture capture("vdevendetta.mp4");

    stopped working. I spent many hours looking for the solution but nothing seems to repair it. After reading everything related with OpenCV, VideoCapture and ffmpeg that I found on internet I decided to reinstall everything taking care of each detail, but it still didn’t work. Finally I solved it changing the line with this other one :

    VideoCapture capture("/home/damia/Documentos/Universitat/ARA/PAEAV/workspace_cpp/SBD/src/vdevendetta.mp4");

    I did not know why this solved it because the video is in the same directory than the program, but I continued working because everything seemed correct.
    Today I had the same problem again on the new line.
    The terminal doesn’t show any error comment (exceptuating "Cannot open the video file", obviously) but the code doesn’t work again.

    I’m using Ubuntu 14.04 LTS, OpenCV 2.4.9 and Eclipse.

    I think if someone test the code it will run correctly, but I would like to know if there is something I have no taking into account.

    Thank you very match.