Recherche avancée

Médias (91)

Autres articles (34)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

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

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

Sur d’autres sites (3413)

  • FFMpeg video thumbnail frame extraction

    30 mars 2012, par Simone Margaritelli

    i'm trying to extract a thumbnail from a video with ffmpeg, therefore i'm using the command line :

    ffmpeg -i video.mp4 -vframes 1 -an -f image2 -y thumbmail.png 2>&1

    But in most cases, the first frame is completely black.
    So, what i'm doing is :

    for( $i = 1; $i < MAX_FRAME_CHECKING; $i++ )
    {
     $cmd = sprintf( 'ffmpeg -i video.mp4 -vframes 1 -an -vf select="eq(n\,%d)"-f image2 -y thumbmail.png 2>&1', $i );

     @exec( $cmd, $aOutput, $iReturnValue );

     if( self::isGoodKeyFrame( 'thumbmail.png' ) )
       break;
    }

    Where the isGoodKeyFrame method is defined as :

    private static function isGoodKeyFrame( $sImagePath )
    {
     if( class_exists('Imagick') )
     {
       $hImagick = new Imagick();

       try
       {
         if ( $hImagick->readImage($sImagePath) && $hImagick->valid() )
         {
           $hQuantized = @$hImagick->clone( );
           $hQuantized->quantizeImage( 255, Imagick::COLORSPACE_RGB, 0, TRUE, FALSE );

           return count( $hQuantized->getImageHistogram() ) > self::HISTOGRAM_SIZE_THRESHOLD;
         }
         else
           error_log( "'$sImagePath' is not a valid image." );
       }
       catch( Exception $e )
       {
         error_log( $e->getMessage() );
       }

       $hImagick->clear( );
       $hImagick->destroy( );

     }
     else
       error_log( 'Imagick not installed.' );

     return TRUE;
    }

    So basically what i'm doing is capture 1 to MAX_FRAME_CHECKING frames, check their color histogram and when i find something with much colors than my minimum threshold i break the loop and return that frame.

    Is there a way to do this natively with ffmpeg ?

    Thanks

  • how to decode wmp3 video using libavcodec ? (ffmpeg)

    13 mars 2012, par Renan Elias

    I'm developing an application that reads a live tv stream from the internet and I need to play it on my ipad application.

    I've compiled the ffmpeg into my ipad application to use the libavcodec lib, but I've not been able to use it in this lib...

    I know how to get the stream packets, read if it is an audio or video packet, but I don't know how to use the lib to convert the original packet codecs to h264 and mp3 codec...

    I need to convert an stream packet wmv3 to h264 and save it on a file.

    My code is below...

    AVFormatContext* pFormatCtx = avformat_alloc_context();
    int             i, videoStream, audioStream;
    AVCodecContext  *pCodecCtx;
    AVCodecContext *aCodecCtx;
    AVCodec         *pCodec;
    AVCodec         *aCodec;
    AVFrame         *pFrame;
    AVFrame         *pFrameRGB;
    AVPacket        packet;
    int             frameFinished;
    int             numBytes;
    uint8_t         *buffer;

    static struct SwsContext *img_convert_ctx;


    // Register all formats and codecs
    av_register_all();
    avcodec_register_all();
    avformat_network_init();

    // Open video file
    if(avformat_open_input(&pFormatCtx, [objURL cStringUsingEncoding:NSASCIIStringEncoding] ,NULL,NULL) != 0){
       return -1;
    }

    // Retrieve stream information
    if(avformat_find_stream_info(pFormatCtx, NULL)<0)
       return -1; // Couldn't find stream information

    // Dump information about file onto standard error
    av_dump_format(pFormatCtx, 0, [objURL cStringUsingEncoding:NSASCIIStringEncoding], 0);

    // Find the first video stream
    videoStream=-1;
    audioStream=-1;
    for(i=0; i < pFormatCtx->nb_streams; i++) {
       if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && videoStream < 0) {
           videoStream=i;
       }
       if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audioStream < 0) {
           audioStream=i;
       }
    }
    if(videoStream==-1)
       return -1; // Didn't find a video stream
    if(audioStream==-1)
       return -1;

    // Get a pointer to the codec context for the video stream
    pCodecCtx=pFormatCtx->streams[videoStream]->codec;

    // Find the decoder for the video stream
    pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
    if(pCodec==NULL) {
       fprintf(stderr, "Unsupported codec!\n");
       return -1; // Codec not found
    }

    // Open codec
    if(avcodec_open2(pCodecCtx, pCodec, NULL)<0)
       return -1; // Could not open codec

    // Get a pointer to the codec context for the audio stream
    aCodecCtx=pFormatCtx->streams[audioStream]->codec;

    // Find the decoder for the audio stream
    aCodec = avcodec_find_decoder(aCodecCtx->codec_id);
    if(!aCodec) {
       fprintf(stderr, "Unsupported codec!\n");
       return -1; // Codec not found
    }

    // Open codec
    if(avcodec_open2(aCodecCtx, aCodec, NULL)<0)
       return -1; // Could not open codec

    // Allocate video frame
    pFrame=avcodec_alloc_frame();

    // Allocate an AVFrame structure
    pFrameRGB=avcodec_alloc_frame();
    if(pFrameRGB==NULL)
       return -1;

    // Determine required buffer size and allocate buffer
    numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
                               pCodecCtx->height);
    buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

    // Assign appropriate parts of buffer to image planes in pFrameRGB
    // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
    // of AVPicture
    avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
                  pCodecCtx->width, pCodecCtx->height);

    // Read frames and save first five frames to disk
    i=0;
    while(av_read_frame(pFormatCtx, &packet)>=0) {
       // Is this a packet from the video stream?
       if(packet.stream_index==audioStream) {
           NSLog(@"Audio.. i'll solve the video first...");
       } else if(packet.stream_index==videoStream) {

           /// HOW CONVERT THIS VIDEO PACKET TO H264 and save on a file? :(
       }

       // Free the packet that was allocated by av_read_frame
       av_free_packet(&packet);
    }

    // Free the RGB image
    av_free(buffer);
    av_free(pFrameRGB);

    // Free the YUV frame
    av_free(pFrame);

    // Close the codec
    avcodec_close(pCodecCtx);

    // Close the video file
    avformat_close_input(&pFormatCtx);

    return 0;
  • ffmpeg - how does moving overlay / text command work ?

    7 mars 2015, par Stpn

    In Ffmpeg you can create moving text :

    ffmpeg -y -t 10 -s qcif -f rawvideo -pix_fmt rgb24 -s 1280x720 -i /dev/zero -g 1 -r 24 -vf drawtext="fontfile=~/fonts/Trebuchet_MS.ttf:text='thing crawls':fontsize=155:fontcolor=red:y=h-20*t" wow.mpg

    So this will give me a black frame with "thing crawls" slowly going from bottom up..

    If I know the length of the video (20 seconds) and want to, for example create "thing falls" that starts at the top of the screen at time 0 and goes to the bottom of the screen until 00:00:20, how do I do that ?

    Also can I create the situation where the text will start going from top to bottom, but stop at the middle of the screen ?