Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (46)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, 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 (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

Sur d’autres sites (6001)

  • Losing quality when encoding with ffmpeg

    22 mai 2016, par lupod

    I am using the c libraries of ffmpeg to read frames from a video and create an output file that is supposed to be identical to the input.
    However, somewhere during this process some quality gets lost and the result is "less sharp". My guess is that the problem is the encoding and that the frames are too compressed (also because the size of the file decreases quite significantly). Is there some parameter in the encoder that allows me to control the quality of the result ? I found that AVCodecContext has a compression_level member, but changing it that does not seem to have any effect.

    I post here part of my code in case it could help. I would say that something must be changed in the init function of OutputVideoBuilder when I set the codec. The AVCodecContext that is passed to the method is the same of InputVideoHandler.
    Here are the two main classes that I created to wrap the ffmpeg functionalities :

    // This class opens the video files and sets the decoder
    class InputVideoHandler {
    public:
     InputVideoHandler(char* name);
     ~InputVideoHandler();
     AVCodecContext* getCodecContext();
     bool readFrame(AVFrame* frame, int* success);

    private:
     InputVideoHandler();
     void init(char* name);
     AVFormatContext* formatCtx;
     AVCodec* codec;
     AVCodecContext* codecCtx;
     AVPacket packet;
     int streamIndex;
    };

    void InputVideoHandler::init(char* name) {
     streamIndex = -1;
     int numStreams;

     if (avformat_open_input(&formatCtx, name, NULL, NULL) != 0)
       throw std::exception("Invalid input file name.");

     if (avformat_find_stream_info(formatCtx, NULL)<0)
       throw std::exception("Could not find stream information.");

     numStreams = formatCtx->nb_streams;

     if (numStreams < 0)
       throw std::exception("No streams in input video file.");

     for (int i = 0; i < numStreams; i++) {
       if (formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
         streamIndex = i;
         break;
       }
     }

     if (streamIndex < 0)
       throw std::exception("No video stream in input video file.");

     // find decoder using id
     codec = avcodec_find_decoder(formatCtx->streams[streamIndex]->codec->codec_id);
     if (codec == nullptr)
       throw std::exception("Could not find suitable decoder for input file.");

     // copy context from input stream
     codecCtx = avcodec_alloc_context3(codec);
     if (avcodec_copy_context(codecCtx, formatCtx->streams[streamIndex]->codec) != 0)
       throw std::exception("Could not copy codec context from input stream.");

     if (avcodec_open2(codecCtx, codec, NULL) < 0)
       throw std::exception("Could not open decoder.");
    }

    // frame must be initialized with av_frame_alloc() before!
    // Returns true if there are other frames, false if not.
    // success == 1 if frame is valid, 0 if not.
    bool InputVideoHandler::readFrame(AVFrame* frame, int* success) {
     *success = 0;
     if (av_read_frame(formatCtx, &packet) < 0)
       return false;
     if (packet.stream_index == streamIndex) {
       avcodec_decode_video2(codecCtx, frame, success, &packet);
     }
     av_free_packet(&packet);
     return true;
    }

    // This class opens the output and write frames to it
    class OutputVideoBuilder{
    public:
     OutputVideoBuilder(char* name, AVCodecContext* inputCtx);
     ~OutputVideoBuilder();
     void writeFrame(AVFrame* frame);
     void writeVideo();

    private:
     OutputVideoBuilder();
     void init(char* name, AVCodecContext* inputCtx);
     void logMsg(AVPacket* packet, AVRational* tb);
     AVFormatContext* formatCtx;
     AVCodec* codec;
     AVCodecContext* codecCtx;
     AVStream* stream;
    };

    void OutputVideoBuilder::init(char* name, AVCodecContext* inputCtx) {
     if (avformat_alloc_output_context2(&formatCtx, NULL, NULL, name) < 0)
       throw std::exception("Could not determine file extension from provided name.");

     codec = avcodec_find_encoder(inputCtx->codec_id);
     if (codec == nullptr) {
       throw std::exception("Could not find suitable encoder.");
     }

     codecCtx = avcodec_alloc_context3(codec);
     if (avcodec_copy_context(codecCtx, inputCtx) < 0)
       throw std::exception("Could not copy output codec context from input");

     codecCtx->time_base = inputCtx->time_base;
     codecCtx->compression_level = 0;

     if (avcodec_open2(codecCtx, codec, NULL) < 0)
       throw std::exception("Could not open encoder.");

     stream = avformat_new_stream(formatCtx, codec);
     if (stream == nullptr) {
       throw std::exception("Could not allocate stream.");
     }

     stream->id = formatCtx->nb_streams - 1;
     stream->codec = codecCtx;
     stream->time_base = codecCtx->time_base;



     av_dump_format(formatCtx, 0, name, 1);
     if (!(formatCtx->oformat->flags & AVFMT_NOFILE)) {
       if (avio_open(&formatCtx->pb, name, AVIO_FLAG_WRITE) < 0) {
         throw std::exception("Could not open output file.");
       }
     }

     if (avformat_write_header(formatCtx, NULL) < 0) {
       throw std::exception("Error occurred when opening output file.");
     }

    }

    void OutputVideoBuilder::writeFrame(AVFrame* frame) {
     AVPacket packet = { 0 };
     int success;
     av_init_packet(&packet);

     if (avcodec_encode_video2(codecCtx, &packet, frame, &success))
       throw std::exception("Error encoding frames");

     if (success) {
       av_packet_rescale_ts(&packet, codecCtx->time_base, stream->time_base);
       packet.stream_index = stream->index;
       logMsg(&packet,&stream->time_base);
       av_interleaved_write_frame(formatCtx, &packet);
     }
     av_free_packet(&packet);
    }

    This is the part of the main function that reads and write frames :

    while (inputHandler->readFrame(frame,&gotFrame)) {

       if (gotFrame) {
         try {
           outputBuilder->writeFrame(frame);
         }
         catch (std::exception e) {
           std::cout << e.what() << std::endl;
           return -1;
         }
       }
     }
  • avcodec/nvenc : rework library load and GPU selection

    29 mai 2016, par Andrey Turkin
    avcodec/nvenc : rework library load and GPU selection
    

    Use explicit nvenc capability checks instead to determine usable devices
    instead of SM versions.

    Signed-off-by : Timo Rothenpieler <timo@rothenpieler.org>

    • [DH] libavcodec/nvenc.c
    • [DH] libavcodec/nvenc.h
    • [DH] libavcodec/nvenc_h264.c
    • [DH] libavcodec/nvenc_hevc.c
  • vaapi_h264 : Fix bit offset of slice data.

    2 avril 2016, par Mark Thompson
    vaapi_h264 : Fix bit offset of slice data.
    

    Commit ca2f19b9cc37be509d85f05c8f902860475905f8 modified the meaning of
    H264SliceContext.gb : it is now initialised at the start of the NAL unit
    header, rather than at the start of the slice header. The VAAPI slice
    decoder uses the offset after parsing to determine the offset of the
    slice data in the bitstream, so with the changed meaning we no longer
    need to add the extra byte to account for the NAL unit header because
    it is now included directly.

    Signed-off-by : Derek Buitenhuis <derek.buitenhuis@gmail.com>

    • [DH] libavcodec/vaapi_h264.c