Recherche avancée

Médias (0)

Mot : - Tags -/interaction

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

Autres articles (61)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • 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

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

Sur d’autres sites (7491)

  • C++ ffmpeg video missing frames and won't play in Quicktime

    5 décembre 2019, par Oliver Dain

    I wrote some C++ code that uses ffmpeg to encode a video. I’m having two strange issues :

    1. The final video is always missing 1 frame. That is, if I have it encode 10 frames the final video only has 9 (at least that’s what ffprobe -show_frames -pretty $VIDEO | grep -F '[FRAME]' | wc -l tells me.
    2. The final video plays fine in some players (mpv and vlc) but not in Quicktime. Quicktime just shows a completely black screen.

    My code is roughly this (modified a bit to remove types that are unique to our code base) :

    First, I open the video file, write the headers and initialize things :

    template <class ptrt="ptrt">
    using UniquePtrWithDeleteFunction = std::unique_ptr>;


    std::unique_ptr<ffmpegencodingframesink> FfmpegEncodingFrameSink::Create(
       const std::string&amp; dest_url) {
     AVFormatContext* tmp_format_ctxt;
     auto alloc_format_res = avformat_alloc_output_context2(&amp;tmp_format_ctxt, nullptr, "mp4", dest_url.c_str());
     if (alloc_format_res &lt; 0) {
       throw FfmpegException("Error opening output file.");
     }
     auto format_ctxt = UniquePtrWithDeleteFunction<avformatcontext>(
         tmp_format_ctxt, CloseAvFormatContext);

     AVStream* out_stream_video = avformat_new_stream(format_ctxt.get(), nullptr);
     if (out_stream_video == nullptr) {
       throw FfmpegException("Could not create outputstream");
     }

     auto codec_context = GetCodecContext(options);
     out_stream_video->time_base = codec_context->time_base;

     auto ret = avcodec_parameters_from_context(out_stream_video->codecpar, codec_context.get());
     if (ret &lt; 0) {
       throw FfmpegException("Failed to copy encoder parameters to outputstream");
     }

     if (!(format_ctxt->oformat->flags &amp; AVFMT_NOFILE)) {
       ret = avio_open(&amp;format_ctxt->pb, dest_url.c_str(), AVIO_FLAG_WRITE);
       if (ret &lt; 0) {
         throw VideoDecodeException("Could not open output file: " + dest_url);
       }
     }

     ret = avformat_init_output(format_ctxt.get(), nullptr);
     if (ret &lt; 0) {
       throw FfmpegException("Unable to initialize the codec.");
     }

     ret = avformat_write_header(format_ctxt.get(), nullptr);
     if (ret &lt; 0) {
       throw FfmpegException("Error occurred writing format header");
     }

     return std::unique_ptr<ffmpegencodingframesink>(
         new FfmpegEncodingFrameSink(std::move(format_ctxt), std::move(codec_context)));
    }
    </ffmpegencodingframesink></avformatcontext></ffmpegencodingframesink></class>

    Then, every time I get a new frame to encode I pass it to this function (the frames are being decoded via ffmpeg from another mp4 file which Quicktime plays just fine) :

    // If frame == nullptr then we're done and we're just flushing the encoder
    // otherwise encode an actual frame
    void FfmpegEncodingFrameSink::EncodeAndWriteFrame(
       const AVFrame* frame) {
     auto ret = avcodec_send_frame(codec_ctxt_.get(), frame);
     if (ret &lt; 0) {
       throw FfmpegException("Error encoding the frame.");
     }

     AVPacket enc_packet;
     enc_packet.data = nullptr;
     enc_packet.size = 0;
     av_init_packet(&amp;enc_packet);

     do {
       ret = avcodec_receive_packet(codec_ctxt_.get(), &amp;enc_packet);
       if (ret ==  AVERROR(EAGAIN)) {
         CHECK(frame != nullptr);
         break;
       } else if (ret ==  AVERROR_EOF) {
         CHECK(frame == nullptr);
         break;
       } else if (ret &lt; 0) {
         throw FfmpegException("Error putting the encoded frame into the packet.");
       }

       assert(ret == 0);
       enc_packet.stream_index = 0;

       LOG(INFO) &lt;&lt; "Writing packet to stream.";
       av_interleaved_write_frame(format_ctxt_.get(), &amp;enc_packet);
       av_packet_unref(&amp;enc_packet);
     } while (ret == 0);
    }

    Finally, in my destructor I close everything up like so :

    FfmpegEncodingFrameSink::~FfmpegEncodingFrameSink() {
     // Pass a nullptr to EncodeAndWriteFrame so it flushes the encoder
     EncodeAndWriteFrame(nullptr);
     // write mp4 trailer
     av_write_trailer(format_ctxt_.get());
    }

    If I run this passing n frames to EncodeAndWriteFrame line LOG(INFO) &lt;&lt; "Writing packet to stream."; gets run n times indicating the n packets were written to the stream. But ffprobe always shows only n - 1 frames int he video. And the final video doesn’t play on quicktime.

    What am I doing wrong ??

  • FFmpeg live editing

    17 décembre 2024, par NikxDa

    I am trying to create a video editing tool in HTML/CSS and PHP. For the video editing, I am using ffmpeg. Now, the file upload and the general editing works pretty well, but I have a problem. I would like to preview the final result inside an HTML video-tag. Thus, wenn I upload 4 clips and then select seconds 5 to 10 to be cut out, I'd like to immediately view the result so I can decide whether I want to keep it or not. Does FFmpeg support something like this ? If not, what would be the best solution ?

    &#xA;

  • FFmpeg live editing

    17 octobre 2016, par NikxDa

    I am trying to create a video editing tool in HTML/CSS and PHP. For the video editing, I am using ffmpeg. Now, the file upload and the general editing works pretty well, but I have a problem. I would like to preview the final result inside an HTML video-tag. Thus, wenn I upload 4 clips and then select seconds 5 to 10 to be cut out, I’d like to immediately view the result so I can decide whether I want to keep it or not. Does FFmpeg support something like this ? If not, what would be the best solution ?