Recherche avancée

Médias (1)

Mot : - Tags -/censure

Autres articles (49)

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

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

Sur d’autres sites (6876)

  • avcodec_open2 returns -22 "Invalid argument" trying to encode AV_CODEC_ID_H264

    26 mai 2023, par Fries of Doom

    I'm trying to use libavcodec to encode h264 video but avcodec_open2 returns -22 "Invalid argument" and I can't figure out why. Here is my code, which is mostly a copy from the encode example from libavcodec.

    


        /* find the mpeg1video encoder */
    const AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);
    if (!codec) {
        fprintf(stderr, "Codec '%s' not found\n", "h.264");
        exit(1);
    }

    AVCodecContext* codecContext = avcodec_alloc_context3(codec);
    if (!codecContext) {
        fprintf(stderr, "Could not allocate video codec context\n");
        exit(1);
    }

    AVPacket* pkt = av_packet_alloc();
    if (!pkt)
        exit(1);

    /* put sample parameters */
    codecContext->bit_rate = 400000;
    /* resolution must be a multiple of two */
    codecContext->width = 1920;
    codecContext->height = 1080;
    /* frames per second */
    codecContext->time_base = { 1, 25 };
    codecContext->framerate = { 25, 1 };

    /* emit one intra frame every ten frames
     * check frame pict_type before passing frame
     * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
     * then gop_size is ignored and the output of encoder
     * will always be I frame irrespective to gop_size
     */
    codecContext->gop_size = 10;
    codecContext->max_b_frames = 1;
    codecContext->codec_type = AVMEDIA_TYPE_VIDEO;
    codecContext->pix_fmt = AV_PIX_FMT_YUV420P;

    if (codec->id == AV_CODEC_ID_H264)
        av_opt_set(codecContext->priv_data, "profile", "baseline", 0);

    /* open it */
    int ret = avcodec_open2(codecContext, codec, nullptr);
    if (ret < 0) {
        char eb[AV_ERROR_MAX_STRING_SIZE];
        fprintf(stderr, "Could not open codec: %s\n", av_make_error_string(eb, AV_ERROR_MAX_STRING_SIZE, ret));
        exit(1);
    }


    


    Does anyone know what I'm doing wrong ?

    


  • AVCodecContex returns zero for width and height in android

    17 février 2023, par Whoami

    Not sure what was my mistake in the below code. I m trying with ffmpeg 0.11 and SDL2.0 in android.

    



    QUESTION :
Why Width and Height of the CodecContext gives me always zero ?..

    



    int main(int argc, char *argv[])&#xA;{&#xA;&#xA;    int flags;&#xA;    flags = SDL_INIT_VIDEO | SDL_INIT_TIMER;&#xA;&#xA;    if (SDL_Init (flags)) {&#xA;        LOGD ("Could not intialize Video for SDL: %s \n", SDL_GetError());&#xA;    }&#xA;    else &#xA;        LOGD (" SUCCESS: SDL_Init ");&#xA;&#xA;    // ffmpeg Register all services..&#xA;    ffmpeg_register_all (); &#xA;&#xA;&#xA;    pFrame = avcodec_alloc_frame ();&#xA;    context = avformat_alloc_context();&#xA;&#xA;    err = avformat_open_input (&amp;context, "rtsp:ip:port", NULL, NULL);&#xA;    if ( err &lt; 0) {&#xA;        __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Unable to open rtsp... ");&#xA;&#xA;        return -1;&#xA;    }&#xA;&#xA;    for (i = 0; i &lt; context->nb_streams; i&#x2B;&#x2B;)&#xA;    {               &#xA;        // Find the Decoder.&#xA;        codec = avcodec_find_decoder(context->streams[i]->codec->codec_id);&#xA;        if (codec->type  == AVMEDIA_TYPE_VIDEO ) {&#xA;            __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Found Video Streaming..  ");&#xA;            videoStreamIndex = i;&#xA;&#xA;        }&#xA;    }&#xA;&#xA;    // Play RTSP&#xA;    av_read_play(context);&#xA;&#xA;    // Get Codec Context.&#xA;    pCodecCtx = context->streams[videoStreamIndex]->codec;&#xA;    if ( pCodecCtx == NULL )&#xA;        __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "CodecCtx is NULL>>> ");&#xA;    else&#xA;        __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "CodecCtx is &lt;&lt;<ok>>> ");&#xA;&#xA;&#xA;    //Find the Decoder.&#xA;    pCodec = avcodec_find_decoder (pCodecCtx->codec_id);&#xA;    avcodec_open2 (pCodecCtx, pCodec, NULL);&#xA;&#xA;&#xA;    int w = pCodecCtx->width;  // Why me getting 0 ? &#xA;    int h = pCodecCtx->height;&#xA;&#xA;    window = SDL_CreateWindow ("Test ffmpeg",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_SHOWN|SDL_WINDOW_ALLOW_HIGHDPI);&#xA;    // What this HIGHDPI Means ??&#xA;&#xA;    if ( window != NULL ) &#xA;    {&#xA;        LOGD (" WINDOW CREATED.. , create Renderer ..");&#xA;        renderer = SDL_CreateRenderer (window, -1, 0);  &#xA;    }&#xA;    else&#xA;    {&#xA;        LOGD (" Invalid SDL Window ");  &#xA;    }&#xA;__android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Width and Height of PCodeccCtx.. %d .. %d " , w, h); &#xA;    return 0;&#xA;}&#xA;</ok>

    &#xA;

  • AVCodecContex returns zero for width and height in android

    7 mars 2014, par Whoami

    Not sure what was my mistake in the below code. I m trying with ffmpeg 0.11 and SDL2.0 in android.

    QUESTION :
    Why Width and Height of the CodecContext gives me always zero ?..

    int main(int argc, char *argv[])
    {

       int flags;
       flags = SDL_INIT_VIDEO | SDL_INIT_TIMER;

       if (SDL_Init (flags)) {
           LOGD ("Could not intialize Video for SDL: %s \n", SDL_GetError());
       }
       else
           LOGD (" SUCCESS: SDL_Init ");

       // ffmpeg Register all services..
       ffmpeg_register_all ();


       pFrame = avcodec_alloc_frame ();
       context = avformat_alloc_context();

       err = avformat_open_input (&amp;context, "rtsp:ip:port", NULL, NULL);
       if ( err &lt; 0) {
           __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Unable to open rtsp... ");

           return -1;
       }

       for (i = 0; i &lt; context->nb_streams; i++)
       {              
           // Find the Decoder.
           codec = avcodec_find_decoder(context->streams[i]->codec->codec_id);
           if (codec->type  == AVMEDIA_TYPE_VIDEO ) {
               __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Found Video Streaming..  ");
               videoStreamIndex = i;

           }
       }

       // Play RTSP
       av_read_play(context);

       // Get Codec Context.
       pCodecCtx = context->streams[videoStreamIndex]->codec;
       if ( pCodecCtx == NULL )
           __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "CodecCtx is NULL>>> ");
       else
           __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "CodecCtx is &lt;&lt;<ok>>> ");


       //Find the Decoder.
       pCodec = avcodec_find_decoder (pCodecCtx->codec_id);
       avcodec_open2 (pCodecCtx, pCodec, NULL);


       int w = pCodecCtx->width;  // Why me getting 0 ?
       int h = pCodecCtx->height;

       window = SDL_CreateWindow ("Test ffmpeg",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_SHOWN|SDL_WINDOW_ALLOW_HIGHDPI);
       // What this HIGHDPI Means ??

       if ( window != NULL )
       {
           LOGD (" WINDOW CREATED.. , create Renderer ..");
           renderer = SDL_CreateRenderer (window, -1, 0);  
       }
       else
       {
           LOGD (" Invalid SDL Window ");  
       }
    __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Width and Height of PCodeccCtx.. %d .. %d " , w, h);
       return 0;
    }
    </ok>