Recherche avancée

Médias (3)

Mot : - Tags -/collection

Autres articles (64)

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

  • Issues with encoded video in Chrome playback

    4 novembre 2022, par Michael Joseph Aubry

    Chrome is very particular about how a video is encoded. An issue I am facing with a specific type of video is seeked either does not get called at all or at least within a 20s period of time within certain frames.

    


    I can consistently repeat this issue using this muxer https://github.com/redbrain/ytdl-core-muxer/blob/main/index.js

    


    When I paint each frame in puppeteer Lambda there are certain frames where either seeked never gets called or the 20s timeout is called before the frame can resolve.

    


    Here is an example of a log sequence for this particular frame that fails enter image description here

    


    When I re-encode this video, simply by running ffmpeg -i VIDEO_URL then try with the new one there are no issues.

    


    In order to see the differences on a frame level I run ffprobe -show_frames goodvideo.mp4 > good.txt && ffprobe -show_frames badvideo.mp4 > bad.txt and here is what I see with the frames around the 117s mark where the first sign of corruption occurs

    


    Good Frame @ 117s

    


    [FRAME]
media_type=video
stream_index=0
key_frame=0
pts=7020013
pts_time=117.000217
pkt_dts=7020013
pkt_dts_time=117.000217
best_effort_timestamp=7020013
best_effort_timestamp_time=117.000217
pkt_duration=1001
pkt_duration_time=0.016683
pkt_pos=27029408
pkt_size=1741
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=B
coded_picture_number=7014
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=tv
color_space=bt709
color_primaries=bt709
color_transfer=bt709
chroma_location=left
[/FRAME]


    


    Bad Frame @ 117s

    


    [FRAME]
media_type=video
stream_index=0
key_frame=0
pts=117000
pts_time=117.000000
pkt_dts=117000
pkt_dts_time=117.000000
best_effort_timestamp=117000
best_effort_timestamp_time=117.000000
pkt_duration=16
pkt_duration_time=0.016000
pkt_pos=20592998
pkt_size=18067
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=P
coded_picture_number=7011
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=tv
color_space=bt709
color_primaries=bt709
color_transfer=bt709
chroma_location=left
[/FRAME]


    


    Does anyone know the differences and why the bad frame is causing my rendering function to have issues seeking ?

    


    This is how I am muxing the bad video, Im trying to avoid re-encoding, but by re-encoding it seems to fix the issue. Are there any settings I can apply to avoid re-encoding while making the video more durable on Chrome ?

    


    // default export: the ffmpeg muxer
const ytmux = (link, options: any = {}) => {
  const result = new stream.PassThrough({
    highWaterMark: options.highWaterMark || 1024 * 512
  });

  ytdl.getInfo(link, options).then((info: videoInfo) => {
    let audioStream: Readable = ytdl.downloadFromInfo(info, {
      ...options,
      quality: "highestaudio"
    });
    let videoStream: Readable = ytdl.downloadFromInfo(info, {
      ...options,
      quality: "highestvideo"
    });
    // create the ffmpeg process for muxing
    let ffmpegProcess: any = cp.spawn(
      ffmpegPath.path,
      [
        // supress non-crucial messages
        "-loglevel",
        "8",
        "-hide_banner",
        // input audio and video by pipe
        "-i",
        "pipe:3",

        "-i",
        "pipe:4",

        // map audio and video correspondingly
        "-map",
        "0:v",
        "-map",
        "1:a",

        // no need to change the codec
        "-c",
        "copy",

        // Allow output to be seekable, which is needed for mp4 output
        "-movflags",
        "frag_keyframe+empty_moov",

        "-fflags",
        "+genpts",

        "-f",
        "matroska",

        "pipe:5"
      ],
      {
        // no popup window for Windows users
        windowsHide: true,
        stdio: [
          // silence stdin/out, forward stderr,
          "inherit",
          "inherit",
          "inherit",
          // and pipe audio, video, output
          "pipe",
          "pipe",
          "pipe"
        ]
      }
    );

    audioStream.pipe(ffmpegProcess.stdio[4]);
    videoStream.pipe(ffmpegProcess.stdio[3]);
    ffmpegProcess.stdio[5].pipe(result);
  });
  return result;
};


    


  • Problem : FFmpeg and C++ extract and save frame

    26 mai 2021, par Simba_cl25

    I am doing a project where I must do the following : extract frames (along with the associated metadata - KLV) from a video given a period (for the moment every 10 seconds).
I have followed codes found on internet but I get an error that I can find a solution to.

    


    extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavdevice></libavdevice>avdevice.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavfilter></libavfilter>avfilter.h>&#xA;#include <libswresample></libswresample>swresample.h>&#xA;#include <libavutil></libavutil>avutil.h>&#xA;#include <libavutil></libavutil>imgutils.h> &#xA;}&#xA;&#xA;static void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame);&#xA;&#xA;&#xA;int main(int argc, const char * argv[])&#xA;{&#xA;    AVFormatContext *pFormatCtx;&#xA;    int             i, videoStream;&#xA;    AVCodecContext  *pCodecCtx = NULL;&#xA;    const AVCodec         *pCodec = NULL;&#xA;    AVFrame         *pFrame;&#xA;    AVFrame         *pFrameRGB;&#xA;    AVPacket        *packet = av_packet_alloc();&#xA;    AVStream        *pStream;&#xA;    int             numBytes;&#xA;    int64_t         Duration;&#xA;    uint8_t         *buffer;&#xA;    bool frameFinished = false;&#xA;&#xA;    // Open video file - check for errors&#xA;    pFormatCtx = 0;&#xA;    if (avformat_open_input(&amp;pFormatCtx, "00Video\\VideoR.ts", 0, 0) != 0)&#xA;        return -1; &#xA;&#xA;    if (avformat_find_stream_info(pFormatCtx, 0) &lt; 0)&#xA;        return -1;&#xA;&#xA;    if (av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, 0, 0) &lt;0)&#xA;        return -1;&#xA;&#xA;    av_dump_format(pFormatCtx, 0, "00Video\\VideoR.ts", false);&#xA;&#xA;&#xA;    // Find the first video stream&#xA;    videoStream = -1;&#xA;    for (i = 0; i &lt; pFormatCtx->nb_streams; i&#x2B;&#x2B;)&#xA;        if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;            videoStream = i;&#xA;            break;&#xA;        }&#xA;    if (videoStream == -1)&#xA;        return -1; &#xA;    &#xA;&#xA;&#xA;    // Find the decoder for the video stream&#xA;    pCodec = avcodec_find_decoder(pFormatCtx->streams[videoStream]->codecpar->codec_id);&#xA;    pCodecCtx = avcodec_alloc_context3(pCodec);&#xA;&#xA;    if (pCodec == NULL)&#xA;    {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        return -1; &#xA;    }&#xA;&#xA;&#xA;    if (avcodec_open2(pCodecCtx, pCodec, NULL) &lt; 0)&#xA;    {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        return -1; &#xA;    }&#xA;&#xA;    // Hack to correct wrong frame rates that seem to be generated by some codecs&#xA;    if (pCodecCtx->time_base.num > 1000 &amp;&amp; pCodecCtx->time_base.den == 1)&#xA;        pCodecCtx->time_base.den = 1000;&#xA;&#xA;&#xA;&#xA;&#xA;    // Allocate video frame - original frame &#xA;    pFrame = av_frame_alloc();&#xA;&#xA;    if (!pFrame) {&#xA;        fprintf(stderr, "Could not allocate video frame\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;&#xA;    // Allocate an AVFrame structure&#xA;    pFrameRGB = av_frame_alloc();&#xA;&#xA;    if (pFrameRGB == NULL)&#xA;    {&#xA;        fprintf(stderr, "Could not allocate video RGB frame\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    &#xA;    Duration = av_rescale_q(vstrm->duration, vstrm->time_base, { 1,1000 });&#xA;    &#xA;    numBytes = av_image_get_buffer_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, 0);&#xA;    buffer = (uint8_t*)av_malloc(numBytes * sizeof(uint8_t));&#xA;&#xA;&#xA;    av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, buffer, AV_PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height, 1);&#xA;    &#xA;    &#xA;        &#xA;    &#xA;    i = 0;&#xA;    while (av_read_frame(pFormatCtx, packet) >= 0)&#xA;    {&#xA;        // Is this a packet from the video stream?&#xA;        if (packet->stream_index == videoStream)&#xA;        {&#xA;            int ret;&#xA;            ret = avcodec_send_packet(pCodecCtx, packet);&#xA;            if (ret &lt; 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                fprintf(stderr, "Error sending a packet for decoding\n");&#xA;                //break;&#xA;            }&#xA;            while (ret >= 0) {&#xA;                ret = avcodec_receive_frame(pCodecCtx, pFrame);&#xA;                if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                    return -1;&#xA;                else if (ret &lt; 0) {&#xA;                    fprintf(stderr, "Error during decoding\n");&#xA;                    return -1;&#xA;                 frameFinished = true;&#xA;                }&#xA;&#xA;&#xA;                // Did we get a video frame?&#xA;                if (frameFinished)&#xA;                {&#xA;                    static struct SwsContext *img_convert_ctx;&#xA;&#xA;                    &#xA;                    if (img_convert_ctx == NULL) {&#xA;                        int w = pCodecCtx->width;&#xA;                        int h = pCodecCtx->height;&#xA;                        img_convert_ctx = sws_getContext(w, h,&#xA;                            pCodecCtx->pix_fmt,&#xA;                            w, h, AV_PIX_FMT_RGB24, SWS_FAST_BILINEAR,&#xA;                            NULL, NULL, NULL);&#xA;&#xA;                        if (img_convert_ctx == NULL) {&#xA;                            fprintf(stderr, "Cannot initialize the conversion context!\n");&#xA;                            exit(1);&#xA;                        }&#xA;                    }&#xA;&#xA;                    int ret = sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0,&#xA;                        pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);&#xA;&#xA;&#xA;                    // Save the frame to disk&#xA;                    if (i &lt;= Duration)&#xA;                    {&#xA;                        SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height, i);&#xA;                        i &#x2B;= 10*1000;&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;        &#xA;        }&#xA;&#xA;        // Free the packet that was allocated by av_read_frame&#xA;        av_packet_unref(packet);&#xA;    }&#xA;&#xA;    &#xA;&#xA;    // Free the RGB image&#xA;    free(buffer);&#xA;    av_free(pFrameRGB);&#xA;&#xA;    // Free the YUV frame&#xA;    av_free(pFrame);&#xA;&#xA;    // Close the codec&#xA;    avcodec_close(pCodecCtx);&#xA;&#xA;    // Close the video file&#xA;    avformat_close_input(&amp;pFormatCtx);&#xA;    return 0;&#xA;    &#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;static void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame)&#xA;{&#xA;    FILE *pFile;&#xA;    char szFilename[32];&#xA;    int  y;&#xA;&#xA;&#xA;    // Open file&#xA;    sprintf(szFilename, "Im\\frame%d.png", iFrame);&#xA;    pFile = fopen(szFilename, "wb");&#xA;    if (pFile == NULL)&#xA;        return;&#xA;&#xA;    // Write header&#xA;    fprintf(pFile, "P6\n%d %d\n255\n", width, height);&#xA;    // Write pixel data&#xA;    for (y = 0; y &lt; height; y&#x2B;&#x2B;)&#xA;        fwrite(pFrame->data[0] &#x2B; y * pFrame->linesize[0], 1, width*3, pFile);&#xA;&#xA;    // Close file&#xA;    fclose(pFile);&#xA;}&#xA;

    &#xA;

    The error I get is :

    &#xA;

    [swscaler @ 03055A80] bad dst image pointers&#xA;

    &#xA;

    I think is because

    &#xA;

    numBytes = av_image_get_buffer_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, 0);&#xA;

    &#xA;

    Returns a negative value ( -22) but I don't know why.

    &#xA;

    Thanks,

    &#xA;

  • ffmpeg libx264 non-existing PPS 0 referenced

    18 août 2014, par k961

    hello i have installed ffmpeg and libx264 based in the offical tutorial on ffmpeg installation here :
    https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

    i want to get an stream from mumudvb and pass it to ffmpeg for h264 encoding
    when i use

    ffserver -f /path/to/config -d

    i get this output :

    [h264 @ 0x1ab32c0] non-existing PPS 0 referenced
    [mpegts @ 0x2c7cca0] Could not find codec parameters for stream 0 (Video: h264 ([27][0][0][0] / 0x001B)): unspecified size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [h264 @ 0x1ab32c0] non-existing SPS 0 referenced in buffering period
    [h264 @ 0x1ab32c0] non-existing PPS 0 referenced
    [h264 @ 0x1ab32c0] decode_slice_header error
    [h264 @ 0x1ab32c0] no frame!
    [mpegts @ 0x1aadca0]
    decoding for stream 0 failed
    [mpegts @ 0x1aadca0] decoding for stream 1 failed
    Input #0, mpegts, from 'http://127.0.0.1:9097':
     Duration: N/A, start: 45508.714822, bitrate: N/A
     Program 107
    [mpegts @ 0x1aadca0]     Stream #0:0[0x42e]: Video: h264 ([27][0][0][0] / 0x001B)[mpegts @ 0x30b0ca0] decoding for stream 1 failed
    , 50 fpsitech@itech-All-Series:~$ , 50 tbr, 90k tbn, 180k tbc
    [mpegts @ 0x1cd5ca0]     Stream #0:1Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [0x42f](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    http://127.0.0.1:8888/tv7.ffm: Input/output error
    Input #0, mpegts, from 'http://127.0.0.1:9093':
     Duration: N/A, start: 25560.704144, bitrate: N/A
     Program 103
       Stream #0:0[0x406]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 16:11 DAR 20:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
       Stream #0:1[0x407](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp
       Stream #0:2[0x40b](ara): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Received signal 2: terminating.
    [mpegts @ 0x30b0ca0] Could not find codec parameters for stream 0 (Video: h264 ([27][0][0][0] / 0x001B)): unspecified size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    http://127.0.0.1:8888/tv3.ffm: Input/output error
    [mpegts @ 0x1aadca0] Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, mpegts, from 'http://127.0.0.1:9094':
    Received signal 2: terminating.
    Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
     Duration: N/A, start: 43409.427056, bitrate: N/A
     Program 104
       Stream #0:0[0x410]Input #0, mpegts, from 'http://127.0.0.1:9098':
    : Video: h264 ([27][0][0][0] / 0x001B), 50 fps, 50 tbr, 90k tbn, 180k tbc
       Stream #0:1[0x411](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp
       Stream #0:2[0x415](ara): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    http://127.0.0.1:8888/tv4.ffm: Input/output error
    Received signal 2: terminating.
     Duration: N/A, start: 26351.744300, bitrate: N/A
     Program 108
       Stream #0:0[0x438]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
       Stream #0:1[0x439](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp
       Stream #0:2[0x43d](ara): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    http://127.0.0.1:8888/tv8.ffm: Input/output error
    Received signal 2: terminating.

    ffmpeg will gime me the output. but the prooblem is that the outputs bitrate is around 2000k to 3000k it should be 512k

    this is my ffserver config :

    Port 8888
    BindAddress 0.0.0.0
    MaxHTTPConnections 20000
    MaxClients 10000
    MaxBandwidth 1000000
    CustomLog -
    <feed>
    File /tmp/ch1.ffm
    FileMaxSize 100M
    ACL allow 127.0.0.1
    launch ffmpeg -i http://127.0.0.1:9094
    </feed>

    <stream ch1="ch1">
    Feed ch1.ffm
    Format mpegts
    AudioBitRate 64
    AudioChannels 2
    AudioSampleRate 44100
    #AVOptionAudio flags +global_header
    VideoBitRate 512
    VideoBufferSize 400
    VideoFrameRate 25
    VideoBitRateTolerance 100
    VideoSize 720x576
    VideoGopSize 12
    AudioCodec aac
    VideoCodec libx264
    AVOptionVideo bsf h264_mp4toannexb
    #AVOptionVideo threads 0
    AVOptionVideo threads_type frame
    AVOptionVideo coder 0
    AVOptionVideo bf 0
    AVOptionVideo flags +loop
    AVOptionVideo partitions +parti8x8+parti4x4+partp8x8+partb8x8
    AVOptionVideo me_method hex
    AVOptionVideo subq 7
    AVOptionVideo me_range 16
    AVOptionVideo g 250
    AVOptionVideo keyint_min 10
    AVOptionVideo sc_threshold 40
    AVOptionVideo i_qfactor 0.71
    AVOptionVideo b_strategy 1
    AVOptionVideo qcomp 0.6
    AVOptionVideo qmin 10
    AVOptionVideo qmax 51
    AVOptionVideo qdiff 4
    AVOptionVideo refs 3
    AVOptionVideo directpred 1
    AVOptionVideo trellis 1
    AVOptionVideo wpredp 0
    #AVOptionVideo flags +global_header

    StartSendOnKey
    </stream>