Recherche avancée

Médias (91)

Autres articles (84)

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

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

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

Sur d’autres sites (16268)

  • ffmpeg concat of two files results in malformed video

    18 avril 2021, par Stas Ezersky

    I processing two videos as follows :

    


    ffmpeg -i video-raw/455848793538790988_duration18.051.mp4 -b:v 993k -b:a 128k -vf "scale=720x1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2,setsar=1:1" video-proc/455848793538790988_duration18.051.mp4


    


    and

    


    ffmpeg -i video-raw/14425661295137552_duration11.666.mp4  -b:v 993k -b:a 128k -vf "scale=720x1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2,setsar=1:1" video-proc/14425661295137552_duration11.666.mp4


    


    then running the following command to concat :

    


    ffmpeg -f concat -safe 0 -i video-concat/dogs-2021-04-17-06-46-id-1.txt -c:v copy -c:a copy ./output.mp4

    


    the resulting video starts properly but when getting to the second video the image stuck and and sound becomes slow.

    


    The ffprobe results are as follow :

    


    Before processing :

    


    ffprobe video-raw/14425661295137552_duration11.666.mp4 

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-raw/14425661295137552_duration11.666.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:11.68, start: 0.000000, bitrate: 565 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x800 [SAR 1:1 DAR 4:5], 462 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


    


    for the second one :

    


    ffprobe video-raw/455848793538790988_duration18.051.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-raw/455848793538790988_duration18.051.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:18.07, start: 0.000000, bitrate: 655 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 576x1024 [SAR 1:1 DAR 9:16], 585 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (HE-AACv2) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 62 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


    


    after processing :

    


    ffprobe video-proc/14425661295137552_duration11.666.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-proc/14425661295137552_duration11.666.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:11.70, start: 0.000000, bitrate: 1133 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 993 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


    


    and the second one

    


    ffprobe video-proc/455848793538790988_duration18.051.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-proc/455848793538790988_duration18.051.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:18.19, start: 0.000000, bitrate: 1044 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 923 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 112 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


    


    any ideas whats wrong ? both videos play perfect separately after processing but not after the concat

    


  • ffmpeg library - why does the Bitrate parameter change on encoding, and how do I force to preserve it ?

    22 avril 2021, par QRrabbit

    Hello forum and all the members of the community !

    


    I have this question on ffmpeg library, why does the bitrate parameter not retained after encoding, even though I explicitly specify the desired rate.

    


    Input file ffprobe :

    


      Duration: 00:00:10.01, start: 0.000000, bitrate: 534719 kb/s
    Stream #0:0(eng): Video: qtrle (rle  / 0x20656C72), argb(progressive), 1920x1080, 533881 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      creation_time   : 2021-04-13T16:35:16.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : Animation
      timecode        : 00:00:00;00


    


    Here's the command I run :

    


    ffmpeg -i input.mov -map 0:a? -map 0:s? -pix_fmt argb -b:v 533881667 -maxrate 533881667 -minrate 533881667 -r 29.97 -top 1 -color_range 1 -colorspace 1 -color_primaries 1 -color_trc bt709 -map_metadata 0 -c:a copy -timecode 00:00:00.00 -c:v qtrle -c:s copy output.mov


    


    Output file ffprobe :

    


      Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2021-04-13T16:35:16.000000Z
  Duration: 00:00:10.01, start: 0.000000, bitrate: 100126 kb/s
    Stream #0:0: Video: qtrle (rle  / 0x20656C72), argb(progressive), 1920x1080, 100133 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 11988 tbn, 11988 tbc (default)
    Metadata:
      creation_time   : 2021-04-13T16:35:16.000000Z
      handler_name    : VideoHandler
      encoder         : Lavf58.58.100
      timecode        : 00:00:00;00


    


    As it is visible from the ffprobe from above, I go from :

    


    The Input's file bitrate : 534719 kb/s
to Output bitrate : 100126 kb/s

    


  • How do you set framerate of AVStream in FFmpeg muxing ?

    16 avril 2021, par TheNeuronalCoder

    Almost everything works fine, this code at least produces playable video. The issue is basically with all time-related metadata about the video file. The FPS and bitrate of the video are WAY higher than what I specified and the duration is only milliseconds. I did some playing around with the framerate data and found this all ultimately stems from incorrectly specifying the framerate. What did I do wrong ? How do I fix this ? How do you properly set the framerate of a video stream in FFmpeg ?

    


    ffprobe version N-101948-g870bfe1 Copyright (c) 2007-2021 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --disable-asm --enable-shared --enable-libx264 --enable-gpl
  libavutil      56. 72.100 / 56. 72.100
  libavcodec     58.136.101 / 58.136.101
  libavformat    58. 78.100 / 58. 78.100
  libavdevice    58. 14.100 / 58. 14.100
  libavfilter     7.111.100 /  7.111.100
  libswscale      5. 10.100 /  5. 10.100
  libswresample   3. 10.100 /  3. 10.100
  libpostproc    55. 10.100 / 55. 10.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'animation.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.78.100
  Duration: 00:00:00.01, start: 0.000000, bitrate: 990171 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1082928 kb/s, 12409.66 fps, 12288 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]


    


    class Camera {
 private:
  AVFrame* frame_;
  AVStream* stream_;
  AVPacket* packet_;
  AVCodecContext* context_;
  AVFormatContext* format_;

 public:
  const int fps_;
  bool recording_;
  std::string output_;

  Camera(std::string path, int fps) : fps_(fps), output_(path) {
    recording_ = false;
  }

  void Record() {
    if (recording_ == true)
      throw std::runtime_error(
        "you must close your camera before starting another recording"
      );
    recording_ = true;

    avformat_alloc_output_context2(&format_, NULL, "mp4", output_.c_str());
    if (!format_)
      throw std::runtime_error("failed to find output format");

    stream_ = avformat_new_stream(format_, NULL);
    if (!stream_)
      throw std::runtime_error("failed to allocate video stream");

    stream_->id = format_->nb_streams-1;
    stream_->codecpar->codec_id = AV_CODEC_ID_H264;
    stream_->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
    stream_->codecpar->width = 1920;
    stream_->codecpar->height = 1080;
    stream_->codecpar->bit_rate = 0.15 * fps_ * stream_->codecpar->width *
                                  stream_->codecpar->height;
    stream_->codecpar->format = AV_PIX_FMT_YUV420P;
    stream_->time_base = (AVRational){ 1, fps_ };

    AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);
    if (!codec)
      throw std::runtime_error("failed to find codec");

    context_ = avcodec_alloc_context3(codec);
    if (!context_)
      throw std::runtime_error("failed to allocate video codec context");

    context_->width = stream_->codecpar->width;
    context_->height = stream_->codecpar->height;
    context_->bit_rate = stream_->codecpar->bit_rate;
    context_->time_base = stream_->time_base;
    context_->framerate = (AVRational){ fps_, 1 };
    context_->gop_size = 10;
    context_->max_b_frames = 1;
    context_->pix_fmt = AV_PIX_FMT_YUV420P;

    if (avcodec_open2(context_, codec, NULL) < 0)
      throw std::runtime_error("failed to open codec");

    if (format_->oformat->flags & AVFMT_GLOBALHEADER)
      context_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;

    if (!(format_->flags & AVFMT_NOFILE))
      if (avio_open(&format_->pb, output_.c_str(), AVIO_FLAG_WRITE) < 0)
        throw std::runtime_error("failed to open video file");

    if (avformat_write_header(format_, NULL) < 0)
      throw std::runtime_error("failed to write headers");

    frame_ = av_frame_alloc();
    if (!frame_)
      throw std::runtime_error("failed to allocate video frame");

    frame_->width = context_->width;
    frame_->height = context_->height;
    frame_->format = AV_PIX_FMT_YUV420P;

    if (av_frame_get_buffer(frame_, 32) < 0)
      throw std::runtime_error("failed to allocate the video frame data");
  }

  void Encode(Frame frame) {
    if (av_frame_make_writable(frame_) < 0)
      throw std::runtime_error("failed to write to frame");

    for (int y = 0; y < frame.height_; ++y) {
      for (int x = 0; x < frame.width_; ++x) {
        int r = frame.pixels_[3 * frame.width_ * y + 3 * x];
        int g = frame.pixels_[3 * frame.width_ * y + 3 * x + 1];
        int b = frame.pixels_[3 * frame.width_ * y + 3 * x + 2];
        frame_->data[0][y * frame_->linesize[0] + x] = (uint8_t)((66*r+129*g+25*b+128) >> 8) + 16;
      }
    }

    for (int y = 0; y < frame.height_/2; ++y) {
      for (int x = 0; x < frame.width_/2; ++x) {
        int r = frame.pixels_[3 * frame.width_ * y + 3 * x];
        int g = frame.pixels_[3 * frame.width_ * y + 3 * x + 1];
        int b = frame.pixels_[3 * frame.width_ * y + 3 * x + 2];
        frame_->data[1][y * frame_->linesize[1] + x] = (uint8_t)((-38*r-74*g+112*b+128) >> 8) + 128;
        frame_->data[2][y * frame_->linesize[2] + x] = (uint8_t)((112*r-94*g-18*b+128) >> 8) + 128;
      }
    }

    if (avcodec_send_frame(context_, frame_) < 0)
      throw std::runtime_error("failed to send a frame for encoding");

    int ret = 0;
    while (ret >= 0) {
      AVPacket packet = { 0 };
      ret = avcodec_receive_packet(context_, &packet);
      if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
        break;
      else if (ret < 0)
        throw std::runtime_error("failed to encode frame");

      av_packet_rescale_ts(&packet, context_->time_base, stream_->time_base);
      packet.pos = -1;
      packet.stream_index = stream_->index;

      ret = av_interleaved_write_frame(format_, &packet);
      av_packet_unref(&packet);
    }
  }

  void Close() {
    if (recording_ == false)
      throw std::runtime_error(
        "you cannot close the camera without starting a recording"
      );
    recording_ = false;

    av_write_trailer(format_);

    avcodec_free_context(&context_);
    av_frame_free(&frame_);

    if (!(format_->oformat->flags & AVFMT_NOFILE))
      avio_closep(&format_->pb);
    avformat_free_context(format_);
  }
}