Recherche avancée

Médias (1)

Mot : - Tags -/biomaping

Autres articles (70)

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

  • 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 ?