Recherche avancée

Médias (91)

Autres articles (98)

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

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

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

Sur d’autres sites (16556)

  • TCP connection failed - python stream view

    18 avril 2022, par knottyextinct

    simple question :

    


    I'm getting the following error message :

    


    [tcp @ 000001fe4c283680] Connection to tcp://raspcam:8000 failed: Error number -138 occurred


    


    My code looks like this :

    


    import cv2

url = 'http://raspcam:8000/stream.mjpg'

try:
    video = cv2.VideoCapture(url)
except Exception as e:
    print(e)

while True:
    _, img = video.read()
    cv2.imshow("stream", img)

    if cv2.waitKey(1) == ord('q'):
        break

video.release()


    


    I know why I'm getting this message, my stream is currently down. My question here is now, how can I handle this exception if the default try except method is not working ?

    


  • av_read_frame function in ffmpeg in android always returning packet.stream_index as 0

    31 juillet 2013, par droidmad

    I am using the following standard code pasted below (ref : http://dranger.com/ffmpeg/) to use ffmpeg in android using ndk. My code is working fine in ubuntu 10.04 using gcc compiler. But I am facing an issue in android.The issue is av_read_frame(pFormatCtx, &packet) is always returning packet.stream_index=0. I have tested my code with various rtsp urls and I have the same behaviour in all cases. I do not have any linking or compiling issues as everything seems to be working fine except this issue. I am trying to solve this from last 2 days but I am stuck badly.Please point me in right direction.

    #include
    #include <android></android>log.h>

    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libswscale></libswscale>swscale.h>

    #include
    #define DEBUG_TAG "mydebug_ndk"

    jint Java_com_example_tut2_MainActivity_myfunc(JNIEnv * env, jobject this,jstring myjurl) {
     AVFormatContext *pFormatCtx = NULL;
     int             i, videoStream;
     AVCodecContext  *pCodecCtx = NULL;
     AVCodec         *pCodec = NULL;
     AVFrame         *pFrame = NULL;
     AVPacket        packet;
     int             frameFinished;

     AVDictionary    *optionsDict = NULL;
     struct SwsContext *sws_ctx = NULL;

     jboolean isCopy;
     const char * mycurl = (*env)->GetStringUTFChars(env, myjurl, &amp;isCopy);
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:p2: [%s]", mycurl);

     // Register all formats and codecs
     av_register_all();
     avformat_network_init();
     // Open video file
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:before_open");

     if(avformat_open_input(&amp;pFormatCtx, mycurl, NULL, NULL)!=0)
         return -1;
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "start: %d\t%d\n",pFormatCtx->raw_packet_buffer_remaining_size,pFormatCtx->max_index_size);

     (*env)->ReleaseStringUTFChars(env, myjurl, mycurl);
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:before_stream");
     // Retrieve stream information
     if(avformat_find_stream_info(pFormatCtx, NULL)&lt;0)
         return -1;
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:after_stream");
     // Find the first video stream
     videoStream=-1;
     for(i=0; inb_streams; i++)
         if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
           videoStream=i;
           break;
         }
     if(videoStream==-1)
         return -1; // Didn&#39;t find a video stream
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:after_videostream");
     // Get a pointer to the codec context for the video stream
     pCodecCtx=pFormatCtx->streams[videoStream]->codec;
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:after_codec_context");

     // Find the decoder for the video stream
     pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:after_decoder");

     if(pCodec==NULL)
         return -1;
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:found_decoder");

     // Open codec
     if(avcodec_open2(pCodecCtx, pCodec, &amp;optionsDict)&lt;0)
         return -1;
     // Allocate video frame
     pFrame=avcodec_alloc_frame();
     sws_ctx = sws_getContext(pCodecCtx->width,pCodecCtx->height,pCodecCtx->pix_fmt,pCodecCtx->width,
           pCodecCtx->height,PIX_FMT_YUV420P,SWS_BILINEAR,NULL,NULL,NULL);
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:before_while");

     int count=0;
     while(av_read_frame(pFormatCtx, &amp;packet)>=0) {
           __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "entered while: %d   %d   %d\n", packet.duration,packet.stream_index,packet.size);

         if(packet.stream_index==videoStream) {
             // Decode video frame
             //break;
             avcodec_decode_video2(pCodecCtx, pFrame, &amp;frameFinished,&amp;packet);
             __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:in_while");
             if(frameFinished) {
                 __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:gng_out_of_while");
                   break;
             }
         }

         // Free the packet that was allocated by av_read_frame
         av_free_packet(&amp;packet);
         if(++count>1000)
            return -2; //infinite while loop
     }
     __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:after_while");

     // Free the YUV frame
     av_free(pFrame);
     // Close the codec
     avcodec_close(pCodecCtx);
     // Close the video file
     avformat_close_input(&amp;pFormatCtx);

     return 0;

    }
  • how to read data using ffmpeg in c ?

    24 octobre 2018, par Dilchun Dev

    I have followed this tutorial :http://dranger.com/ffmpeg/tutorial01.html for using ffmpeg in android studio using android NDK.
    I have made some minor correction as some functions used here are depreciated now.Here’s my code can anyone point out whats wrong with my code as i am getting errorand couldn’t find out what’s wrong

    #include
    #include
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libavutil></libavutil>imgutils.h>
    void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame);
    JNICALL
    JNIEXPORT jstring
    Java_com_viralsam_root_tester_MainActivity_trtest(JNIEnv *env, jobject obj , jint argc,
                                                     jstring argv_){
       const char *name;
       int i,videostream;
       name= (*env)->GetStringUTFChars(env, argv_,0);
       AVFormatContext *pFormatctx=NULL;
       if (avformat_open_input(&amp;pFormatctx,name,NULL,NULL)!=0){
           return (*env)->NewStringUTF(env,"a");
       }
       if(pFormatctx==NULL){
           return (*env)->NewStringUTF(env,"b");
       }
       if(avformat_find_stream_info(pFormatctx,NULL)&lt;0){
           return (*env)->NewStringUTF(env,"c");
       }
       av_dump_format(pFormatctx, 0, name, 0);
       videostream=-1;
       AVCodecContext *pCodecCtxOrig = NULL;
       AVCodecContext *pCodecCtx = NULL;
       for (i=0;inb_streams;i++){
           if((pFormatctx->streams[i]->codecpar->codec_type)==AVMEDIA_TYPE_VIDEO){
               videostream=i;
               break;
           }
       }
       if(videostream==-1){
           return (*env)->NewStringUTF(env,"d");
       }
       pCodecCtx=pFormatctx->streams[videostream]->codecpar;
       AVCodec *pCodec = NULL;
       pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
       if(pCodec==NULL){
           return (*env)->NewStringUTF(env,"e");
       }
       pCodecCtx=avcodec_alloc_context3(pCodec);
       if(avcodec_open2(pCodecCtx,pCodec,NULL)&lt;0){
           return (*env)->NewStringUTF(env,"g");
       }
       AVFrame *pFrame = NULL,*pFrameRBG=NULL;

       pFrame=av_frame_alloc();
       pFrameRBG=av_frame_alloc();
       if(pFrameRBG==NULL){
           return (*env)->NewStringUTF(env,"h");
       }
       uint8_t *buffer=NULL;
       int numBytes;
       numBytes=av_image_get_buffer_size(AV_PIX_FMT_RGB24,pCodecCtx->width,pCodecCtx->height,1);
       buffer=(uint8_t *)av_malloc(numBytes* sizeof(uint8_t));
       av_image_fill_arrays(pFrameRBG->data,pFrameRBG->linesize,buffer,AV_PIX_FMT_RGB24,pCodecCtx->width,pCodecCtx->height,1);
       struct SwsContext *sws_ctx = NULL;
       int frameFinished;
       AVPacket *packet=av_packet_alloc();
       sws_ctx=sws_getContext(pCodecCtx->width,pCodecCtx->height,pCodecCtx->pix_fmt,pCodecCtx->width,pCodecCtx->height,AV_PIX_FMT_RGB24,SWS_BILINEAR,NULL,NULL,NULL);
       i=0;
       while(av_read_frame(pFormatctx,&amp;packet)>=0){

           if(packet->stream_index==videostream){
               int used=avcodec_send_packet(pCodecCtx,&amp;packet);
               used=avcodec_receive_frame(pCodecCtx,pFrame);
               if (used &lt; 0 &amp;&amp; used != AVERROR(EAGAIN) &amp;&amp; used != AVERROR_EOF){
                   break;

               } else{

                   if (used == AVERROR(EAGAIN) || used == AVERROR_EOF){
                       break;
                   }
               }

               sws_scale(sws_ctx,(uint8_t const * const *)pFrame->data,pFrame->linesize,0,pCodecCtx->height,pFrameRBG->data,pFrameRBG->linesize);
               if(++i&lt;=5){
                   SaveFrame(pFrameRBG,pCodecCtx->width,pCodecCtx->height,i);
               }


           }
           av_packet_free(&amp;packet);

       }
       char blubuk[50];
       sprintf(blubuk,"%d",buffer);
       av_free(buffer);
       av_frame_free(&amp;pFrameRBG);
       av_frame_free(&amp;pFrame);
       avcodec_close(pCodecCtx);
       avcodec_close(pCodecCtxOrig);
       avformat_close_input(&amp;pFormatctx);

       return (*env)->NewStringUTF(env,blubuk);

    }
    void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame){
       FILE *pFile;
       char szFilename[32];
       int  y;
       sprintf(szFilename, "frame%d.ppm", iFrame);
       pFile=fopen(szFilename,"wb");
       if(pFile==NULL){
           return;
       }
       fprintf(pFile, "P6\n%d %d\n255\n", width, height);
       for(y=0; ydata[0]+y*pFrame->linesize[0], 1, width*3, pFile);
       }
       fclose(pFile);

    }

    UPDATE :
    I am getting "-22" from "int used=avcodec_send_packet(pCodecCtx,packet) ;".Can’t figure out where i went wrong.