Recherche avancée

Médias (0)

Mot : - Tags -/clipboard

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (41)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Initialisation de MediaSPIP (préconfiguration)

    20 février 2010, par

    Lors de l’installation de MediaSPIP, celui-ci est préconfiguré pour les usages les plus fréquents.
    Cette préconfiguration est réalisée par un plugin activé par défaut et non désactivable appelé MediaSPIP Init.
    Ce plugin sert à préconfigurer de manière correcte chaque instance de MediaSPIP. Il doit donc être placé dans le dossier plugins-dist/ du site ou de la ferme pour être installé par défaut avant de pouvoir utiliser le site.
    Dans un premier temps il active ou désactive des options de SPIP qui ne le (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

Sur d’autres sites (4932)

  • ffmpeg using MediaCodec, avcodec_open2 says error code :-1 (0xffffffff) text : "Operation not permitted"

    11 mai 2017, par Miguel Del Amor

    I’m trying to use the Android API MediaCoded that have been supported by ffmpeg but while I try to open the codec I got "Operation not permitted" all times, I’ve tried some changes and I’ve tried to find examples without not luck.

    This is what I’m doing

    av_jni_set_java_vm(QAndroidJniEnvironment::javaVM(), NULL);

    av_register_all();
    avcodec_register_all();

    AVCodec *_codec(nullptr);
    AVCodecContext *_codecContext(nullptr);

    if (_codec == nullptr)
       _codec = avcodec_find_decoder_by_name("h264_mediacodec");

    if (_codecContext == nullptr)
       _codecContext = avcodec_alloc_context3(_codec);

    int ret = 0;
    if( (ret = avcodec_open2(_codecContext, _codec, NULL)) < 0 ) {

       char str[AV_ERROR_MAX_STRING_SIZE];
       memset(str, 0, sizeof(str));
       av_strerror(ret, str, sizeof(str));

       qDebug("avcodec_open2 \"%s\" error[code:%d text:\"%s\"]",_codec->long_name, ret, str);
    }

    And I’m getting this output

    avcodec_open2 "H.264 Android MediaCodec decoder" error[code:-1 text:"Operation not permitted"]

    What I’m doing wrong ?

  • ffmpeg av_read_frame "Invalid data found"

    26 mai 2017, par DweebsUnited

    I am using ffmpeg to cut part of a file, following the remux example provided. However, I am having issues reading from files. I am given a file descriptor as input and an output filename, and can successfully set up the output file, read the stream info, copy all the streams, etc, etc. On the first call to av_read_frame though, I get an "Invalid data found when processing input" error. I have tried this with many different video files, and have not been able to get a single one to process correctly.

    Here is my code. I get no errors anywhere, except av_read_frame, which gives Invalid data found no matter what video file I give it.

    char path[512];
    sprintf(path, "pipe:%d", fileno(fp));


    AVOutputFormat *ofmt = NULL;
    AVFormatContext *ifmt_ctx = avformat_alloc_context(), *ofmt_ctx = NULL;
    AVPacket pkt;
    int ret, i;

    av_register_all();
    avcodec_register_all();

    if ((ret = avformat_open_input(&ifmt_ctx, path, av_find_input_format("mp4"), NULL)) < 0) {
       LOG("Could not open input file '%s'", path);
       goto end;
    }

    if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) {
       LOG("Failed to retrieve input stream information", "");
       goto end;
    }

    avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename);
    if (!ofmt_ctx) {
       LOG("Could not create output context\n");
       ret = AVERROR_UNKNOWN;
       goto end;
    }

    ofmt = ofmt_ctx->oformat;

    for (i = 0; i < ifmt_ctx->nb_streams; i++) {
       AVStream *in_stream = ifmt_ctx->streams[i];
       AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);

       if (!out_stream) {
           LOG("Failed allocating output stream\n");
           goto end;
       }

       ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar);
       if (ret < 0) {
           LOG("Failed to copy context from input to output stream codec context\n");
           goto end;
       }
       out_stream->codecpar->codec_tag = 0;
    }

    if (!(ofmt->flags & AVFMT_NOFILE)) {
       ret = avio_open(&ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE);
       if (ret < 0) {
           LOG("Could not open output file '%s'", out_filename);
           goto end;
       }
    }

    ret = avformat_write_header(ofmt_ctx, NULL);
    if (ret < 0) {
       LOG("Error occurred when opening output file\n");
       goto end;
    }

    //    int indexs[8] = {0};

    //    int64_t start_from = 8*AV_TIME_BASE;
    ret = av_seek_frame(ifmt_ctx, -1, from_seconds*AV_TIME_BASE, AVSEEK_FLAG_ANY);
    if (ret < 0) {
       LOG("Error seek\n");
       goto end;
    }

    int64_t *dts_start_from;
    int64_t *pts_start_from;
    dts_start_from = (int64_t *) malloc(sizeof(int64_t) * ifmt_ctx->nb_streams);
    memset(dts_start_from, 0, sizeof(int64_t) * ifmt_ctx->nb_streams);
    pts_start_from = (int64_t *) malloc(sizeof(int64_t) * ifmt_ctx->nb_streams);
    memset(pts_start_from, 0, sizeof(int64_t) * ifmt_ctx->nb_streams);

    while (1) {
       AVStream *in_stream, *out_stream;

       ret = av_read_frame(ifmt_ctx, &pkt);
       if (ret < 0)
           break;

       in_stream = ifmt_ctx->streams[pkt.stream_index];
       out_stream = ofmt_ctx->streams[pkt.stream_index];

       if (av_q2d(in_stream->time_base) * pkt.pts > end_seconds) {
           av_packet_unref(&pkt);
           break;
       }

       if (dts_start_from[pkt.stream_index] == 0)
           dts_start_from[pkt.stream_index] = pkt.dts;
       if (pts_start_from[pkt.stream_index] == 0)
           pts_start_from[pkt.stream_index] = pkt.pts;

       /* copy packet */
       pkt.pts = ::av_rescale_q_rnd(pkt.pts - pts_start_from[pkt.stream_index], in_stream->time_base, out_stream->time_base, (AVRounding) (AV_ROUND_NEAR_INF |
                                                                                                                                           AV_ROUND_PASS_MINMAX));
       pkt.dts = ::av_rescale_q_rnd(pkt.dts - dts_start_from[pkt.stream_index], in_stream->time_base, out_stream->time_base, (AVRounding) (AV_ROUND_NEAR_INF |
                                                                                                                                           AV_ROUND_PASS_MINMAX));
       if (pkt.pts < 0) {
           pkt.pts = 0;
       }
       if (pkt.dts < 0) {
           pkt.dts = 0;
       }
       pkt.duration = (int) av_rescale_q((int64_t) pkt.duration, in_stream->time_base, out_stream->time_base);
       pkt.pos = -1;

       ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
       if (ret < 0) {
           LOG("Error muxing packet\n");
           break;
       }
       av_packet_unref(&pkt);
    }
    free(dts_start_from);
    free(pts_start_from);

    av_write_trailer(ofmt_ctx);

    end:
    LOG("END");

    avformat_close_input(&ifmt_ctx);

    /* close output */
    if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
       avio_closep(&ofmt_ctx->pb);
    avformat_free_context(ofmt_ctx);

    if (ret < 0 && ret != AVERROR_EOF) {
       LOG("-- Error occurred: %s\n", av_err2str(ret));
       return 1;
    }

    Thank you for any help, I’m still getting used to ffmpeg. Did I miss some setting on the input ? Am I not setting something up that I need to be ? This problem is really stumping me.

  • Why there is no AVFrame->data[2] data when decode h264 by ffmpeg use "h264_cuvid"

    27 juillet 2017, par Wu NL

    env : ubuntu 16.04 64 bit ; ffmpeg 3.3.2 build whih cuda cuvid libnpp...
    use ffmpeg cmd : ffmpeg -vsync 0 -c:v h264_cuvid -i test.264 -f rawvideo test.yuv works fine, the generated yuv file is ok.
    BUT When I decode this 264 file by my code use ’h264_cuvid’ decoder, something problem happens, this is my code :

    #include

    #define __STDC_CONSTANT_MACROS

    #ifdef _WIN32
    //Windows
    extern "C"
    {
    #include "libavcodec/avcodec.h"
    };
    #else
    //Linux...
    #ifdef __cplusplus
    extern "C"
    {
    #endif
    #include <libavcodec></libavcodec>avcodec.h>
    #ifdef __cplusplus
    };
    #endif
    #endif


    //test different codec
    #define TEST_H264  1
    #define TEST_HEVC  0

    int main(int argc, char* argv[])
    {
       AVCodec *pCodec;
       AVCodecContext *pCodecCtx= NULL;
       AVCodecParserContext *pCodecParserCtx=NULL;

       FILE *fp_in;
       FILE *fp_out;
       AVFrame *pFrame;

       const int in_buffer_size=4096;
       unsigned char in_buffer[in_buffer_size + FF_INPUT_BUFFER_PADDING_SIZE]= {0};
       unsigned char *cur_ptr;
       int cur_size;
       AVPacket packet;
       int ret, got_picture;


    #if TEST_HEVC
       enum AVCodecID codec_id=AV_CODEC_ID_HEVC;
       char filepath_in[]="bigbuckbunny_480x272.hevc";
    #elif TEST_H264
       AVCodecID codec_id=AV_CODEC_ID_H264;
       char filepath_in[]="2_60_265to264.264";
    #else
       AVCodecID codec_id=AV_CODEC_ID_MPEG2VIDEO;
       char filepath_in[]="bigbuckbunny_480x272.m2v";
    #endif

       char filepath_out[]="mainSend.yuv";
       int first_time=1;


       //av_log_set_level(AV_LOG_DEBUG);

       avcodec_register_all();

    //    pCodec = avcodec_find_decoder(codec_id);
       pCodec = avcodec_find_decoder_by_name("h264_cuvid");
       if (!pCodec)
       {
           printf("Codec not found\n");
           return -1;
       }
       pCodecCtx = avcodec_alloc_context3(pCodec);
       if (!pCodecCtx)
       {
           printf("Could not allocate video codec context\n");
           return -1;
       }

       pCodecParserCtx=av_parser_init(pCodec->id);
       if (!pCodecParserCtx)
       {
           printf("Could not allocate video parser context\n");
           return -1;
       }

       if (avcodec_open2(pCodecCtx, pCodec, NULL) &lt; 0)
       {
           printf("Could not open codec\n");
           return -1;
       }
       //Input File
       fp_in = fopen(filepath_in, "rb");
       if (!fp_in)
       {
           printf("Could not open input stream\n");
           return -1;
       }
       //Output File
       fp_out = fopen(filepath_out, "wb");
       if (!fp_out)
       {
           printf("Could not open output YUV file\n");
           return -1;
       }

       pFrame = av_frame_alloc();
       av_init_packet(&amp;packet);

       while (1)
       {

           cur_size = fread(in_buffer, 1, in_buffer_size, fp_in);
           if (cur_size == 0)
               break;
           cur_ptr=in_buffer;

           while (cur_size>0)
           {

               int len = av_parser_parse2(
                             pCodecParserCtx, pCodecCtx,
                             &amp;packet.data, &amp;packet.size,
                             cur_ptr, cur_size,
                             AV_NOPTS_VALUE, AV_NOPTS_VALUE, AV_NOPTS_VALUE);

               cur_ptr += len;
               cur_size -= len;

               if(packet.size==0)
                   continue;

               //Some Info from AVCodecParserContext
               printf("[Packet]Size:%6d\t",packet.size);
               switch(pCodecParserCtx->pict_type)
               {
               case AV_PICTURE_TYPE_I:
                   printf("Type:I\tNumber:%4d\n",pCodecParserCtx->output_picture_number);
                   break;
               case AV_PICTURE_TYPE_P:
                   printf("Type:P\t");
                   break;
               case AV_PICTURE_TYPE_B:
                   printf("Type:B\t");
                   break;
               default:
                   printf("Type:Other\t");
                   break;
               }
               printf("Number:%4d\n",pCodecParserCtx->output_picture_number);
               AVFrame* myFrame = av_frame_alloc();
               ret = avcodec_decode_video2(pCodecCtx, myFrame, &amp;got_picture, &amp;packet);
               if (ret &lt; 0)
               {
                   printf("Decode Error.\n");
                   return ret;
               }
               if (got_picture)
               {
                   if(first_time)
                   {
                       printf("\nCodec Full Name:%s\n",pCodecCtx->codec->long_name);
                       printf("width:%d\nheight:%d\n\n",pCodecCtx->width,pCodecCtx->height);
                       first_time=0;
                   }
                   //Y, U, V
                   for(int i=0; iheight; i++)
                   {
                       fwrite(myFrame->data[0]+myFrag-g>linesize[0]*i,1,myFrame->width,fp_out);
                   }
                   for(int i=0; iheight/2; i++)
                   {
                       fwrite(myFrame->data[1]+myFrag-g>linesize[1]*i,1,myFrame->width/2,fp_out);
                   }
                   for(int i=0; iheight/2; i++)
                   {
                       fwrite(myFrame->data[2]+myFrag-g>linesize[2]*i,1,myFrame->width/2,fp_out);
                   }
    //                printf("pframe's width height %d %d\t key frame %d\n",myFrame->width,myFrame->height,myFrame->key_frame);
                   printf("Succeed to decode 1 frame!\n");
                   av_frame_free(&amp;myFrame);
               }
           }

       }

       fclose(fp_in);
       fclose(fp_out);


       av_parser_close(pCodecParserCtx);

       av_frame_free(&amp;pFrame);
       avcodec_close(pCodecCtx);
       av_free(pCodecCtx);

       return 0;
    }

    In this demo code, I call h264_cuvid by vcodec_find_decoder_by_name("h264_cuvid");
    BUT the code crash at fwrite(myFrame->data[2]+myFrag-g>linesize[2]*i,1,myFrame->width/2,fp_out);
    So after debug with codeblocks, I found that there is no data in myFrame->data[2] codeblocks watching window

    Any suggestion ? thanks !