Recherche avancée

Médias (91)

Autres articles (41)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (8460)

  • Add padding with ffmpeg to videos increases file size, why ?

    12 mars 2023, par try2getsmarter

    I need to add padding to mp4 video files (since tv changes aspect ratio on playback) and I simply can do this with -pad option of ffmpeg.

    


    The output is ok for me, but I see that most of the video files increase about 25%-30% in file size.

    


    ffmpeg -i in.mp4 -preset slow -vf "pad=1920:1080 :(1920-iwmin(1920/iw,1080/ih))/2 :(1080-ihmin(1920/iw,1080/ih))/2" -c:v h264 -c:a copy out_fhd.mp4"

    


    Is there a way to preserve the input quality and have the same file size ? As the black bars contain no information I had the expectation that there is a lossless mode to take the already H264 encoded stream and just add blocks with black pixels.

    


  • libvlc ffmpeg : No seek in mpegts h264 stream

    26 juillet 2016, par ElDorado

    I am using ffmpeg to record video input from GDI (windows screen recorder) to view it later using VLC (via ActiveX plugin) + ffmpeg to decode it.

    Right now seeking in video is not working in VLC via plugin (which is critical). VLC player itself provide seeking, but it is more like byte position seeking (on I- frames which are larger than other frames it makes larger steps on horizontal scroll and also there are no timestamps).

    Encoder is opened with next defaults :

    avformat_alloc_output_context2(&outputContext, NULL, "mpegts", "test.mpg");
    outputFormat = outputContext->oformat;
    encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
    outputStream = avformat_new_stream(outputContext, encoder);
    outputStream->id = outputContext->nb_streams - 1;
    encoderContext = outputStream->codec;
    encoderContext->bit_rate = bitrate;   // 800000 by default
    encoderContext->rc_max_rate = bitrate;
    encoderContext->width = imageWidth;   // 1920
    encoderContext->height = imageHeight; // 1080
    encoderContext->time_base.num = 1;
    encoderContext->time_base.den = fps;  // 25 by default
    encoderContext->gop_size = fps;
    encoderContext->keyint_min = fps;
    encoderContext->max_b_frames = 0;
    encoderContext->pix_fmt = AV_PIX_FMT_YUV420P;
    outputStream->time_base = encoderContext->time_base;
    avcodec_open2(encoderContext, encoder, NULL);

    Recording is done this way :

    // my impl of GDI recorder, returning AVFrame with only data and linesize filled.
    AVFrame* tmp_frame = impl_->recorder->acquireFrame();

    // converting RGB -> YUV420
    sws_scale(impl_->scaleContext, tmp_frame->data, tmp_frame->linesize, 0, impl_->frame->height, impl_->frame->data, impl_->frame->linesize);

    // pts variable is calculated by using QueryPerformanceCounter form WinAPI. It is strictly increasing
    impl_->frame->pts = pts;

    avcodec_encode_video2(impl_->encoderContext, impl_->packet, impl_->frame, &out_size);

    if (out_size) {
        impl_->packet->pts = pts;
        impl_->packet->dts = pts;
        impl_->packet->duration = 1; // here it is! It is set but has no effect
        av_packet_rescale_ts(impl_->packet, impl_->encoderContext->time_base, impl_->outputStream->time_base);
        // here pts = 3600*pts, dts = 3600*pts, duration = 3600 what I consider to be legit in terms of milliseconds
        impl_->packet->stream_index = impl_->outputStream->index;
        av_interleaved_write_frame(impl_->outputContext, impl_->packet);
        av_packet_unref(impl_->packet);
        out_size = 0;
    }

    ffprobe is providing next info on frames :

    [FRAME]
    media_type=video
    stream_index=0
    key_frame=1
    pkt_pts=3600
    pkt_pts_time=0:00:00.040000
    pkt_dts=3600
    pkt_dts_time=0:00:00.040000
    best_effort_timestamp=3600
    best_effort_timestamp_time=0:00:00.040000
    pkt_duration=N/A
    pkt_duration_time=N/A
    pkt_pos=564
    pkt_size=97.018555 Kibyte
    width=1920
    height=1080
    pix_fmt=yuv420p
    sample_aspect_ratio=N/A
    pict_type=I
    coded_picture_number=0
    display_picture_number=0
    interlaced_frame=0
    top_field_first=0
    repeat_pict=0
    [/FRAME]

    I believe that problem is in pkt_duration variable, though it was set.
    What I am doing wrong in recording so I can’t seek in video ?

    P.S. on other videos (also h264) seeking is working in ActiveX VLC plugin.

  • FFMPEG avformat_open_input returning AVERROR_INVALIDDATA [on hold]

    10 août 2016, par Victor.dMdB

    I’m trying to use ffmpeg to take in video data from a buffer but keep on getting the same error.

    I’ve implemented the same code as described here :
    http://www.ffmpeg.org/doxygen/trunk/doc_2examples_2avio_reading_8c-example.html

    Here is the code (I’ve tried removing the unnecessary bits)

    VideoInputFile *video_input_file;
    VideoDataConf *video_data_conf;

    video_data_conf->width = 1920;
    video_data_conf->height = 1080;

    int vbuf_size = 9 * cmd_data_ptr->video_data_conf.width * cmd_data_ptr->video_data_conf.height + 10000;
    uint8_t *buffer = (uint8_t *) av_malloc(vbuf_size);

    video_data_conf->input_ptr.ptr = buffer;
    video_data_conf->input_ptr.size = vbuf_size;
    strncpy(video_data_conf->filename, "localmem");

    video_input_file->vbuf_size = 9 * video_data_conf->width * video_data_conf->height + 10000;
    video_input_file->vbuf = (uint8_t *) av_malloc(video_input_file->vbuf_size);
    video_input_file->av_io_ctx = avio_alloc_context(video_input_file->vbuf, video_input_file->vbuf_size, 0, &video_data_conf->input_ptr, &read_function, NULL, NULL);

    if ( !video_input_file->av_io_ctx ) {
       fprintf(stdout,"Failed to create the buffer avio context\n");
    }

    video_input_file->av_fmt_ctx = avformat_alloc_context();

    if ( !video_input_file->av_fmt_ctx ) {
       printf(stdout,"Failed to create the video avio context\n");
    }

    video_input_file->av_fmt_ctx->pb = video_input_file->av_io_ctx;

    open_res = avformat_open_input(&video_input_file->av_fmt_ctx, video_data_conf->filename, NULL, NULL);

    Read function :

    static int read_function(void* opaque, uint8_t* buf, int buf_size) {
       BufferData *bd = (BufferData *) opaque;
       buf_size = FFMIN(buf_size, bd->size);
       memcpy(buf, bd->ptr, buf_size);
       bd->ptr  += buf_size;
       bd->size -= buf_size;
       return buf_size;
    }

    BufferData structure

    typedef struct {
       uint8_t *ptr;
       size_t size; ///< size left in the buffer
    } BufferData;

    It starts to work if I initialise the buffer and vbuf_size with a real file like so :

     uint8_t *buffer;
     size_t vbuf_size;
     av_file_map("/path/to/image.png", &buffer, &vbuf_size, 0, NULL);