Recherche avancée

Médias (91)

Autres articles (51)

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

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

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

Sur d’autres sites (7621)

  • Get video resolution in nodejs

    24 août 2016, par tgdn

    I have been trying to get an answer to this without really finding any. Excuse me if this sounds stupid or obvious.

    I have a nodejs application and basically I would like to simply get the resolution of a video. Imagine I have film stored on disk and I would like to be able to know if it is in 720p or 1080p or anything else.

    I understood that I might need to use ffmpeg to do so, but then I also understood that ffmpeg was mostly used to "record, convert and stream audio and video files".
    That does not mean retrieve video resolution.

    Thank you for your help

    Edit 1 :
    The node.js app is a desktop app and needs to be portable to Linux, windows and OS X. If possible a portable answer would be more appreciated but of course any answer is welcome.

  • avcodec/rv30 : fix switching back to the original resolution

    17 août 2015, par Michael Niedermayer
    avcodec/rv30 : fix switching back to the original resolution
    

    Fixes part of Ticket1388

    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavcodec/rv30.c
    • [DH] libavcodec/rv34.h
  • Screenrecorder application output video resolution issues [closed]

    23 juin 2022, par JessieK

    Using Github code for ScreenRecorder on Linux&#xA;Everything works fine, besides the resolution of output video.&#xA;Tried to play with setting, quality has significantly improved, but still no way to change resolution.&#xA;I need to get output video with the same size as input video

    &#xA;

    using namespace std;&#xA;&#xA;    /* initialize the resources*/&#xA;    ScreenRecorder::ScreenRecorder()&#xA;    {&#xA;    &#xA;        av_register_all();&#xA;        avcodec_register_all();&#xA;        avdevice_register_all();&#xA;        cout&lt;&lt;"\nall required functions are registered successfully";&#xA;    }&#xA;    &#xA;    /* uninitialize the resources */&#xA;    ScreenRecorder::~ScreenRecorder()&#xA;    {&#xA;    &#xA;        avformat_close_input(&amp;pAVFormatContext);&#xA;        if( !pAVFormatContext )&#xA;        {&#xA;            cout&lt;&lt;"\nfile closed sucessfully";&#xA;        }&#xA;        else&#xA;        {&#xA;            cout&lt;&lt;"\nunable to close the file";&#xA;            exit(1);&#xA;        }&#xA;    &#xA;        avformat_free_context(pAVFormatContext);&#xA;        if( !pAVFormatContext )&#xA;        {&#xA;            cout&lt;&lt;"\navformat free successfully";&#xA;        }&#xA;        else&#xA;        {&#xA;            cout&lt;&lt;"\nunable to free avformat context";&#xA;            exit(1);&#xA;        }&#xA;    &#xA;    }&#xA;    &#xA;    /* function to capture and store data in frames by allocating required memory and auto deallocating the memory.   */&#xA;    int ScreenRecorder::CaptureVideoFrames()&#xA;    {&#xA;        int flag;&#xA;        int frameFinished;//when you decode a single packet, you still don&#x27;t have information enough to have a frame [depending on the type of codec, some of them //you do], when you decode a GROUP of packets that represents a frame, then you have a picture! that&#x27;s why frameFinished will let //you know you decoded enough to have a frame.&#xA;    &#xA;        int frame_index = 0;&#xA;        value = 0;&#xA;    &#xA;        pAVPacket = (AVPacket *)av_malloc(sizeof(AVPacket));&#xA;        av_init_packet(pAVPacket);&#xA;    &#xA;        pAVFrame = av_frame_alloc();&#xA;        if( !pAVFrame )&#xA;        {&#xA;         cout&lt;&lt;"\nunable to release the avframe resources";&#xA;         exit(1);&#xA;        }&#xA;    &#xA;        outFrame = av_frame_alloc();//Allocate an AVFrame and set its fields to default values.&#xA;        if( !outFrame )&#xA;        {&#xA;         cout&lt;&lt;"\nunable to release the avframe resources for outframe";&#xA;         exit(1);&#xA;        }&#xA;    &#xA;        int video_outbuf_size;&#xA;        int nbytes = av_image_get_buffer_size(outAVCodecContext->pix_fmt,outAVCodecContext->width,outAVCodecContext->height,32);&#xA;        uint8_t *video_outbuf = (uint8_t*)av_malloc(nbytes);&#xA;        if( video_outbuf == NULL )&#xA;        {&#xA;            cout&lt;&lt;"\nunable to allocate memory";&#xA;            exit(1);&#xA;        }&#xA;    &#xA;        // Setup the data pointers and linesizes based on the specified image parameters and the provided array.&#xA;        value = av_image_fill_arrays( outFrame->data, outFrame->linesize, video_outbuf , AV_PIX_FMT_YUV420P, outAVCodecContext->width,outAVCodecContext->height,1 ); // returns : the size in bytes required for src&#xA;        if(value &lt; 0)&#xA;        {&#xA;            cout&lt;&lt;"\nerror in filling image array";&#xA;        }&#xA;    &#xA;        SwsContext* swsCtx_ ;&#xA;    &#xA;        // Allocate and return swsContext.&#xA;        // a pointer to an allocated context, or NULL in case of error&#xA;        // Deprecated : Use sws_getCachedContext() instead.&#xA;        swsCtx_ = sws_getContext(pAVCodecContext->width,&#xA;                            pAVCodecContext->height,&#xA;                            pAVCodecContext->pix_fmt,&#xA;                            outAVCodecContext->width,&#xA;                    outAVCodecContext->height,&#xA;                            outAVCodecContext->pix_fmt,&#xA;                            SWS_BICUBIC, NULL, NULL, NULL);&#xA;    &#xA;    &#xA;    int ii = 0;&#xA;    int no_frames = 100;&#xA;    cout&lt;&lt;"\nenter No. of frames to capture : ";&#xA;    cin>>no_frames;&#xA;    &#xA;        AVPacket outPacket;&#xA;        int j = 0;&#xA;    &#xA;        int got_picture;&#xA;    &#xA;        while( av_read_frame( pAVFormatContext , pAVPacket ) >= 0 )&#xA;        {&#xA;        if( ii&#x2B;&#x2B; == no_frames )break;&#xA;            if(pAVPacket->stream_index == VideoStreamIndx)&#xA;            {&#xA;                value = avcodec_decode_video2( pAVCodecContext , pAVFrame , &amp;frameFinished , pAVPacket );&#xA;                if( value &lt; 0)&#xA;                {&#xA;                    cout&lt;&lt;"unable to decode video";&#xA;                }&#xA;    &#xA;                if(frameFinished)// Frame successfully decoded :)&#xA;                {&#xA;                    sws_scale(swsCtx_, pAVFrame->data, pAVFrame->linesize,0, pAVCodecContext->height, outFrame->data,outFrame->linesize);&#xA;                    av_init_packet(&amp;outPacket);&#xA;                    outPacket.data = NULL;    // packet data will be allocated by the encoder&#xA;                    outPacket.size = 0;&#xA;    &#xA;                    avcodec_encode_video2(outAVCodecContext , &amp;outPacket ,outFrame , &amp;got_picture);&#xA;    &#xA;                    if(got_picture)&#xA;                    {&#xA;                        if(outPacket.pts != AV_NOPTS_VALUE)&#xA;                            outPacket.pts = av_rescale_q(outPacket.pts, video_st->codec->time_base, video_st->time_base);&#xA;                        if(outPacket.dts != AV_NOPTS_VALUE)&#xA;                            outPacket.dts = av_rescale_q(outPacket.dts, video_st->codec->time_base, video_st->time_base);&#xA;                    &#xA;                        printf("Write frame %3d (size= %2d)\n", j&#x2B;&#x2B;, outPacket.size/1000);&#xA;                        if(av_write_frame(outAVFormatContext , &amp;outPacket) != 0)&#xA;                        {&#xA;                            cout&lt;&lt;"\nerror in writing video frame";&#xA;                        }&#xA;    &#xA;                    av_packet_unref(&amp;outPacket);&#xA;                    } // got_picture&#xA;    &#xA;                av_packet_unref(&amp;outPacket);&#xA;                } // frameFinished&#xA;    &#xA;            }&#xA;        }// End of while-loop&#xA;

    &#xA;

    One part of two parts is above...Actually original app seem to record video of same size as does my application, but still it has not any use

    &#xA;


    &#xA;

    Second part of the code

    &#xA;

    av_free(video_outbuf);&#xA;&#xA;}&#xA;&#xA;/* establishing the connection between camera or screen through its respective folder */&#xA;int ScreenRecorder::openCamera()&#xA;{&#xA;&#xA;    value = 0;&#xA;    options = NULL;&#xA;    pAVFormatContext = NULL;&#xA;&#xA;    pAVFormatContext = avformat_alloc_context();//Allocate an AVFormatContext.&#xA;/*&#xA;&#xA;X11 video input device.&#xA;To enable this input device during configuration you need libxcb installed on your system. It will be automatically detected during configuration.&#xA;This device allows one to capture a region of an X11 display. &#xA;refer : https://www.ffmpeg.org/ffmpeg-devices.html#x11grab&#xA;*/&#xA;    /* current below is for screen recording. to connect with camera use v4l2 as a input parameter for av_find_input_format */ &#xA;    pAVInputFormat = av_find_input_format("x11grab");&#xA;    value = avformat_open_input(&amp;pAVFormatContext, ":0.0&#x2B;10,250", pAVInputFormat, NULL);&#xA;    if(value != 0)&#xA;    {&#xA;       cout&lt;&lt;"\nerror in opening input device";&#xA;       exit(1);&#xA;    }&#xA;&#xA;    /* set frame per second */&#xA;    value = av_dict_set( &amp;options,"framerate","30",0 );&#xA;    if(value &lt; 0)&#xA;    {&#xA;      cout&lt;&lt;"\nerror in setting dictionary value";&#xA;       exit(1);&#xA;    }&#xA;&#xA;    value = av_dict_set( &amp;options, "preset", "medium", 0 );&#xA;    if(value &lt; 0)&#xA;    {&#xA;      cout&lt;&lt;"\nerror in setting preset values";&#xA;      exit(1);&#xA;    }&#xA;&#xA;//  value = avformat_find_stream_info(pAVFormatContext,NULL);&#xA;    if(value &lt; 0)&#xA;    {&#xA;      cout&lt;&lt;"\nunable to find the stream information";&#xA;      exit(1);&#xA;    }&#xA;&#xA;    VideoStreamIndx = -1;&#xA;&#xA;    /* find the first video stream index . Also there is an API available to do the below operations */&#xA;    for(int i = 0; i &lt; pAVFormatContext->nb_streams; i&#x2B;&#x2B; ) // find video stream posistion/index.&#xA;    {&#xA;      if( pAVFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO )&#xA;      {&#xA;         VideoStreamIndx = i;&#xA;         break;&#xA;      }&#xA;&#xA;    } &#xA;&#xA;    if( VideoStreamIndx == -1)&#xA;    {&#xA;      cout&lt;&lt;"\nunable to find the video stream index. (-1)";&#xA;      exit(1);&#xA;    }&#xA;&#xA;    // assign pAVFormatContext to VideoStreamIndx&#xA;    pAVCodecContext = pAVFormatContext->streams[VideoStreamIndx]->codec;&#xA;&#xA;    pAVCodec = avcodec_find_decoder(pAVCodecContext->codec_id);&#xA;    if( pAVCodec == NULL )&#xA;    {&#xA;      cout&lt;&lt;"\nunable to find the decoder";&#xA;      exit(1);&#xA;    }&#xA;&#xA;    value = avcodec_open2(pAVCodecContext , pAVCodec , NULL);//Initialize the AVCodecContext to use the given AVCodec.&#xA;    if( value &lt; 0 )&#xA;    {&#xA;      cout&lt;&lt;"\nunable to open the av codec";&#xA;      exit(1);&#xA;    }&#xA;}&#xA;&#xA;/* initialize the video output file and its properties  */&#xA;int ScreenRecorder::init_outputfile()&#xA;{&#xA;    outAVFormatContext = NULL;&#xA;    value = 0;&#xA;    output_file = "../media/output.mp4";&#xA;&#xA;    avformat_alloc_output_context2(&amp;outAVFormatContext, NULL, NULL, output_file);&#xA;    if (!outAVFormatContext)&#xA;    {&#xA;        cout&lt;&lt;"\nerror in allocating av format output context";&#xA;        exit(1);&#xA;    }&#xA;&#xA;/* Returns the output format in the list of registered output formats which best matches the provided parameters, or returns NULL if there is no match. */&#xA;    output_format = av_guess_format(NULL, output_file ,NULL);&#xA;    if( !output_format )&#xA;    {&#xA;     cout&lt;&lt;"\nerror in guessing the video format. try with correct format";&#xA;     exit(1);&#xA;    }&#xA;&#xA;    video_st = avformat_new_stream(outAVFormatContext ,NULL);&#xA;    if( !video_st )&#xA;    {&#xA;        cout&lt;&lt;"\nerror in creating a av format new stream";&#xA;        exit(1);&#xA;    }&#xA;&#xA;    outAVCodecContext = avcodec_alloc_context3(outAVCodec);&#xA;    if( !outAVCodecContext )&#xA;    {&#xA;        cout&lt;&lt;"\nerror in allocating the codec contexts";&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* set property of the video file */&#xA;    outAVCodecContext = video_st->codec;&#xA;    outAVCodecContext->codec_id = AV_CODEC_ID_MPEG4;// AV_CODEC_ID_MPEG4; // AV_CODEC_ID_H264 // AV_CODEC_ID_MPEG1VIDEO&#xA;    outAVCodecContext->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    outAVCodecContext->pix_fmt  = AV_PIX_FMT_YUV420P;&#xA;    outAVCodecContext->bit_rate = 2500000; // 2500000&#xA;    outAVCodecContext->width = 1920;&#xA;    outAVCodecContext->height = 1080;&#xA;    outAVCodecContext->gop_size = 3;&#xA;    outAVCodecContext->max_b_frames = 2;&#xA;    outAVCodecContext->time_base.num = 1;&#xA;    outAVCodecContext->time_base.den = 30; // 15fps&#xA;&#xA;    {&#xA;     av_opt_set(outAVCodecContext->priv_data, "preset", "slow", 0);&#xA;    }&#xA;&#xA;    outAVCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);&#xA;    if( !outAVCodec )&#xA;    {&#xA;     cout&lt;&lt;"\nerror in finding the av codecs. try again with correct codec";&#xA;    exit(1);&#xA;    }&#xA;&#xA;    /* Some container formats (like MP4) require global headers to be present&#xA;       Mark the encoder so that it behaves accordingly. */&#xA;&#xA;    if ( outAVFormatContext->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;    {&#xA;        outAVCodecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;    value = avcodec_open2(outAVCodecContext, outAVCodec, NULL);&#xA;    if( value &lt; 0)&#xA;    {&#xA;        cout&lt;&lt;"\nerror in opening the avcodec";&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* create empty video file */&#xA;    if ( !(outAVFormatContext->flags &amp; AVFMT_NOFILE) )&#xA;    {&#xA;     if( avio_open2(&amp;outAVFormatContext->pb , output_file , AVIO_FLAG_WRITE ,NULL, NULL) &lt; 0 )&#xA;     {&#xA;      cout&lt;&lt;"\nerror in creating the video file";&#xA;      exit(1);&#xA;     }&#xA;    }&#xA;&#xA;    if(!outAVFormatContext->nb_streams)&#xA;    {&#xA;        cout&lt;&lt;"\noutput file dose not contain any stream";&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* imp: mp4 container or some advanced container file required header information*/&#xA;    value = avformat_write_header(outAVFormatContext , &amp;options);&#xA;    if(value &lt; 0)&#xA;    {&#xA;        cout&lt;&lt;"\nerror in writing the header context";&#xA;        exit(1);&#xA;    }&#xA;&#xA;&#xA;    cout&lt;&lt;"\n\nOutput file information :\n\n";&#xA;    av_dump_format(outAVFormatContext , 0 ,output_file ,1);&#xA;

    &#xA;

    Github link https://github.com/abdullahfarwees/screen-recorder-ffmpeg-cpp

    &#xA;