Recherche avancée

Médias (91)

Autres articles (77)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

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

Sur d’autres sites (5968)

  • What is the correct way to write Frames in ffmpeg

    6 février 2020, par hagor

    I am working on some ffmpeg writer implementation and I can not undrestand what do I do wrong.
    I have a mdf (media digital file) file which I need to convert to avi and I have a software that does it. The test case : Avi file I get from my software and avi file I get from software are identical.
    I can get frames from input mdf file, and can convert them to bmps correctly. So I suppose I do something wrong with ffmpeg.
    I also need to use raw RGB codec in ffmpeg.

    Here is the code I wrote to fill avi files with frames :

    if (hOffLoaderDVR && m_hDeviceCollection && device && hDriveSetDVR && hFile)
                       {
                           std::string camSuffix = "_cam_";
                           std::string cameraName = hFile->streamByIndex(streamC)->cameraPortName().c_str();
                           std::string fileName = pathToAviDir + hFile->parameters()->name.c_str() + camSuffix + cameraName + std::to_string(streamC).c_str() + ".avi";

                           Offload::Request request;
                           Common::DataTypeHandle cameraParams = hFile->streamByIndex(streamC)->streamView()->dataType();

                           AVFrame* frame = m_ffwriter.alloc_picture(AV_PIX_FMT_BGR24, cameraParams->width(), cameraParams->height());

                           size_t datasize = hFile->streamByIndex(streamC)->streamView()->frameAtIndex(0)->buffer()->size();  // size in bytes

                           RecordingParams params(fileName, cameraParams->width(), cameraParams->height(), 50,
                               AV_PIX_FMT_BGR24, datasize);

                           frame->pkt_size = datasize;
                           m_ffwriter.delayedOpen(params);

                           for (unsigned int frameC = 0; frameC < hFile->streamByIndex(streamC)->streamView()->frameCount(); frameC++)
                           {
                               m_ffwriter.fill_rgb_image(frame, hFile->streamByIndex(streamC)->streamView()->frameAtIndex(frameC)->buffer()->data());
                               m_ffwriter.putImage(frame);
                           }
                           m_ffwriter.close();
                           av_frame_free(&frame);

                       }

    To open the AVI file I use the function ffmpegWriter::delayedOpen :

    bool FfmpegWriter::delayedOpen(const RecordingParams & params) {

       unsigned int w = params.getWidth();
       unsigned int h = params.getHeight();
       unsigned int framerate = params.getFramerate();
       unsigned int datasize = params.getDataSize();
       m_filename = params.getPath();

       unsigned int sample_rate = 0; //default
       unsigned int channels = 0;    //default

       m_delayed = false;
       if (w <= 0 || h <= 0) {
           m_delayed = true;
           return true;
       }
       m_ready = true;

       // auto detect the output format from the name. default is mpeg.
       m_fmt = av_guess_format(nullptr, m_filename.c_str(), nullptr);
       m_fmt->video_codec = AV_CODEC_ID_RAWVIDEO; //can be moved to a parameter if required

       if (!m_fmt) {
           printf("Could not deduce output format from file extension: using MPEG.\n");
           m_fmt = av_guess_format("mpeg", nullptr, nullptr);
       }

       if (!m_fmt) {
           fprintf(stderr, "Could not find suitable output format\n");
           ::exit(1);
       }


       // allocate the output media context
       m_oc = avformat_alloc_context();
       if (!m_oc) {
           fprintf(stderr, "Memory error\n");
           ::exit(1);
       }
       m_oc->oformat = m_fmt;
       m_fmt->flags = AVFMT_NOTIMESTAMPS;


       snprintf(m_oc->filename, sizeof(m_oc->filename), "%s", m_filename.c_str());

       // add the audio and video streams using the default format codecs
       // and initialize the codecs
       m_video_st = nullptr;
       m_audio_st = nullptr;

       if (m_fmt->video_codec != AV_CODEC_ID_NONE) {
           m_video_st = add_video_stream(m_oc, m_fmt->video_codec, w, h, framerate);
       }

       av_dump_format(m_oc, 0, m_filename.c_str(), 1);

       // now that all the parameters are set, we can open
       // video codecs and allocate the necessary encode buffers

       if (m_video_st) {
           open_video(m_oc, m_video_st, datasize);
       }

       // open the output file, if needed
       if (!(m_fmt->flags & AVFMT_NOFILE)) {
           if (avio_open(&m_oc->pb, m_filename.c_str(), AVIO_FLAG_WRITE) < 0) {
               fprintf(stderr, "Could not open '%s'\n", m_filename.c_str());
               ::exit(1);
           }
       }

       // write the stream header, if any
       avformat_write_header(m_oc, NULL);
       return true;
    }

    And to fill images and put them into the AVI I use these functions :

    void FfmpegWriter::fill_rgb_image(AVFrame *pict, void *p)
    {

       memcpy(pict->data[0], p, pict->pkt_size);

    }
    bool FfmpegWriter::putImage(AVFrame * newFrame) {
       if (m_delayed) {
           // savedConfig.put("width",Value((int)image.width()));
          //  savedConfig.put("height",Value((int)image.height()));
       }
       if (!isOk()) {
           return false;
       }

       if (m_video_st) {
           m_video_pts = (double)av_stream_get_end_pts(m_video_st) *m_video_st->time_base.num / m_video_st->time_base.den;
       }
       else {
           m_video_pts = 0.0;
       }

       if (!(m_video_st)) {
           return false;
       }

       // write interleaved video frame
       write_video_frame(m_oc, m_video_st, newFrame);

       return true;
    }

    Do I not open context correctly ? Or where might be the problem ? The problems I can see are that the output AVI has around minute delay in the beginning with no frames changing, and the video channels behave differently(it seems that red and blue dissapeared). Does it make any difference to use other format ? I currently use AV_PIX_FMT_BGR24 which seems to be correct (I can visualize frames from the same pointer correctly).

    Thank you for your help !

  • Correct layout for FFMPEG scripts inside Powershell

    24 juin 2019, par Virgosh

    I’ve found several FFMPEG scripts I want to run on Windows10 using powershell.
    I’m not so skilled so I can’t understand why I receive some errors and what is the correct way I can launch those scripts.

    for example I’ve just grabbed this script

    ffmpeg -i input0 -i input1 -filter_complex \
    "[1:v][0:v]blend=all_expr=if(gt(X\,Y*(W/H))\,A\,B)" output

    and I receive this error as both when I just paste into powershell or making a .bat file containint the code

    At line:1 char:53
    + "[1:v][0:v]blend=all_expr=if(gt(X\,Y*(W/H))\,A\,B)" output.mov
    +                                                     ~~~~~~~~~~
    Unexpected token 'output.mov' in expression or statement.
       + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
       + FullyQualifiedErrorId : UnexpectedToken

    How can I use this script inside powershell ?
    Is there any guide about "formatting" scripts for W10 ?

    best

  • How do I correct the ffmpeg to stream my mp4 ?

    16 avril 2019, par Alex Serban

    I’m trying to setup a live stream from my raspberry pi to youtube using ffmpeg, but the stream fails to start

    I’ve tried first streaming an MP4 file I’ve captured using raspivid to figure out how ffmpeg works. I’ve captured a 10 mins video, at 426x240, bitrate 222kbps, 25 frames/sec and tried streaming.

    ffmpeg -re -i "video4-10min.mp4"  -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 426x240 -bufsize 2048k -vb 222k -maxrate 800k -deinterlace -vcodec libx264 -preset medium -g 30 -r 30 -f flv "rtmp://a.rtmp.youtube.com/live2/[my-stream-key]"

    Stream looks like it’s starting, the health prompt says : "4:48 PM Good Stream is healthy / Stream health is excellent."
    but in a few secs goes to : "4:48 PM No data No active stream",
    even though the ffmpeg looks like it’s streaming accurately : "frame= 1061 fps= 25 q=-1.0 Lsize=    1205kB time=00:00:42.40 bitrate= 232.9kbits/s speed=0.994x"