Recherche avancée

Médias (2)

Mot : - Tags -/doc2img

Autres articles (55)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

Sur d’autres sites (5413)

  • ffmpeg avcodec_encode_video2 hangs when using Quick Sync h264_qsv encoder

    9 juin 2020, par Mike Simpson

    When I use the mpeg4 or h264 encoders, I am able to successfully encode images to make a valid AVI file using the API for ffmpeg 3.1.0. However, when I use the Quick Sync encoder (h264_qsv), avcodec_encode_video2 will hang some of the time. I found that when using images that are 1920x1080, it was rare that avcodec_encode_video2 would hang. When using 256x256 images, it was very likely that the function would hang.

    



    I have created the test code below that demonstrates the hang of avcodec_encode_video2. The code will create a 1000 frame, 256x256 AVI with a bit rate of 400000. The frames are simply allocated, so the output video should just be green frames.

    



    The problem was observed using Windows 7 and Windows 10, using the 32-bit or 64-bit test application.

    



    If anyone has any idea on how I can avoid the avcodec_encode_video2 hang I would be very grateful ! Thanks in advance for any assistance.

    



    extern "C"&#xA;{&#xA;#ifndef __STDC_CONSTANT_MACROS&#xA;#define __STDC_CONSTANT_MACROS&#xA;#endif&#xA;#include "avcodec.h"&#xA;#include "avformat.h"&#xA;#include "swscale.h"&#xA;#include "avutil.h"&#xA;#include "imgutils.h"&#xA;#include "opt.h"&#xA;#include &#xA;}&#xA;&#xA;#include <iostream>&#xA;&#xA;&#xA;// Globals&#xA;AVCodec* m_pCodec = NULL;&#xA;AVStream *m_pStream = NULL;&#xA;AVOutputFormat* m_pFormat = NULL;&#xA;AVFormatContext* m_pFormatContext = NULL;&#xA;AVCodecContext* m_pCodecContext = NULL;&#xA;AVFrame* m_pFrame = NULL;&#xA;int m_frameIndex;&#xA;&#xA;// Output format&#xA;AVPixelFormat m_pixType = AV_PIX_FMT_NV12;&#xA;// Use for mpeg4&#xA;//AVPixelFormat m_pixType = AV_PIX_FMT_YUV420P;&#xA;&#xA;// Output frame rate&#xA;int m_frameRate = 30;&#xA;// Output image dimensions&#xA;int m_imageWidth = 256;&#xA;int m_imageHeight = 256;&#xA;// Number of frames to export&#xA;int m_frameCount = 1000;&#xA;// Output file name&#xA;const char* m_fileName = "c:/test/test.avi";&#xA;// Output file type&#xA;const char* m_fileType = "AVI";&#xA;// Codec name used to encode&#xA;const char* m_encoderName = "h264_qsv";&#xA;// use for mpeg4&#xA;//const char* m_encoderName = "mpeg4";&#xA;// Target bit rate&#xA;int m_targetBitRate = 400000;&#xA;&#xA;void addVideoStream()&#xA;{&#xA;    m_pStream = avformat_new_stream( m_pFormatContext, m_pCodec );&#xA;    m_pStream->id = m_pFormatContext->nb_streams - 1;&#xA;    m_pStream->time_base = m_pCodecContext->time_base;&#xA;    m_pStream->codec->pix_fmt = m_pixType;&#xA;    m_pStream->codec->flags = m_pCodecContext->flags;&#xA;    m_pStream->codec->width = m_pCodecContext->width;&#xA;    m_pStream->codec->height = m_pCodecContext->height;&#xA;    m_pStream->codec->time_base = m_pCodecContext->time_base;&#xA;    m_pStream->codec->bit_rate = m_pCodecContext->bit_rate;&#xA;}&#xA;&#xA;AVFrame* allocatePicture( enum AVPixelFormat pix_fmt, int width, int height )&#xA;{&#xA;    AVFrame *frame;&#xA;&#xA;    frame = av_frame_alloc();&#xA;&#xA;    if ( !frame )&#xA;    {&#xA;        return NULL;&#xA;    }&#xA;&#xA;    frame->format = pix_fmt;&#xA;    frame->width  = width;&#xA;    frame->height = height;&#xA;&#xA;    int checkImage = av_image_alloc( frame->data, frame->linesize, width, height, pix_fmt, 32 );&#xA;&#xA;    if ( checkImage &lt; 0 )&#xA;    {&#xA;        return NULL;&#xA;    }&#xA;&#xA;    return frame;&#xA;}&#xA;&#xA;bool initialize()&#xA;{&#xA;    AVRational frameRate;&#xA;    frameRate.den = m_frameRate;&#xA;    frameRate.num = 1;&#xA;&#xA;    av_register_all();&#xA;&#xA;    m_pCodec = avcodec_find_encoder_by_name(m_encoderName);&#xA;&#xA;    if( !m_pCodec )&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    m_pCodecContext = avcodec_alloc_context3( m_pCodec );&#xA;    m_pCodecContext->width = m_imageWidth;&#xA;    m_pCodecContext->height = m_imageHeight;&#xA;    m_pCodecContext->time_base = frameRate;&#xA;    m_pCodecContext->gop_size = 0;&#xA;    m_pCodecContext->pix_fmt = m_pixType;&#xA;    m_pCodecContext->codec_id = m_pCodec->id;&#xA;    m_pCodecContext->bit_rate = m_targetBitRate;&#xA;&#xA;    av_opt_set( m_pCodecContext->priv_data, "&#x2B;CBR", "", 0 );&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;bool startExport()&#xA;{&#xA;    m_frameIndex = 0;&#xA;    char fakeFileName[512]; &#xA;    int checkAllocContext = avformat_alloc_output_context2( &amp;m_pFormatContext, NULL, m_fileType, fakeFileName );&#xA;&#xA;    if ( checkAllocContext &lt; 0 )&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    if ( !m_pFormatContext ) &#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    m_pFormat = m_pFormatContext->oformat;&#xA;&#xA;    if ( m_pFormat->video_codec != AV_CODEC_ID_NONE ) &#xA;    {&#xA;        addVideoStream();&#xA;&#xA;        int checkOpen = avcodec_open2( m_pCodecContext, m_pCodec, NULL );&#xA;&#xA;        if ( checkOpen &lt; 0 )&#xA;        {&#xA;            return false;&#xA;        }&#xA;&#xA;        m_pFrame = allocatePicture( m_pCodecContext->pix_fmt, m_pCodecContext->width, m_pCodecContext->height );                &#xA;        if( !m_pFrame ) &#xA;        {&#xA;            return false;&#xA;        }&#xA;        m_pFrame->pts = 0;&#xA;    }&#xA;&#xA;    int checkOpen = avio_open( &amp;m_pFormatContext->pb, m_fileName, AVIO_FLAG_WRITE );&#xA;    if ( checkOpen &lt; 0 )&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    av_dict_set( &amp;(m_pFormatContext->metadata), "title", "QS Test", 0 );&#xA;&#xA;    int checkHeader = avformat_write_header( m_pFormatContext, NULL );&#xA;    if ( checkHeader &lt; 0 )&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;int processFrame( AVPacket&amp; avPacket )&#xA;{&#xA;    avPacket.stream_index = 0;&#xA;    avPacket.pts = av_rescale_q( m_pFrame->pts, m_pStream->codec->time_base, m_pStream->time_base );&#xA;    avPacket.dts = av_rescale_q( m_pFrame->pts, m_pStream->codec->time_base, m_pStream->time_base );&#xA;    m_pFrame->pts&#x2B;&#x2B;;&#xA;&#xA;    int retVal = av_interleaved_write_frame( m_pFormatContext, &amp;avPacket );&#xA;    return retVal;&#xA;}&#xA;&#xA;bool exportFrame()&#xA;{&#xA;    int success = 1;&#xA;    int result = 0;&#xA;&#xA;    AVPacket avPacket;&#xA;&#xA;    av_init_packet( &amp;avPacket );&#xA;    avPacket.data = NULL;&#xA;    avPacket.size = 0;&#xA;&#xA;    fflush(stdout);&#xA;&#xA;    std::cout &lt;&lt; "Before avcodec_encode_video2 for frame: " &lt;&lt; m_frameIndex &lt;&lt; std::endl;&#xA;    success = avcodec_encode_video2( m_pCodecContext, &amp;avPacket, m_pFrame, &amp;result );&#xA;    std::cout &lt;&lt; "After avcodec_encode_video2 for frame: " &lt;&lt; m_frameIndex &lt;&lt; std::endl;&#xA;&#xA;    if( result )&#xA;    { &#xA;        success = processFrame( avPacket );&#xA;    }&#xA;&#xA;    av_packet_unref( &amp;avPacket );&#xA;&#xA;    m_frameIndex&#x2B;&#x2B;;&#xA;    return ( success == 0 );&#xA;}&#xA;&#xA;void endExport()&#xA;{&#xA;    int result = 0;&#xA;    int success = 0;&#xA;&#xA;    if (m_pFrame)&#xA;    {&#xA;        while ( success == 0 )&#xA;        {&#xA;            AVPacket avPacket;&#xA;            av_init_packet( &amp;avPacket );&#xA;            avPacket.data = NULL;&#xA;            avPacket.size = 0;&#xA;&#xA;            fflush(stdout);&#xA;            success = avcodec_encode_video2( m_pCodecContext, &amp;avPacket, NULL, &amp;result );&#xA;&#xA;            if( result )&#xA;            { &#xA;                success = processFrame( avPacket );&#xA;            }&#xA;            av_packet_unref( &amp;avPacket );&#xA;&#xA;            if (!result)&#xA;            {&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    if (m_pFormatContext)&#xA;    {&#xA;        av_write_trailer( m_pFormatContext );&#xA;&#xA;        if( m_pFrame )&#xA;        {&#xA;            av_frame_free( &amp;m_pFrame );&#xA;        }&#xA;&#xA;        avio_closep( &amp;m_pFormatContext->pb );&#xA;        avformat_free_context( m_pFormatContext );&#xA;        m_pFormatContext = NULL;&#xA;    }&#xA;}&#xA;&#xA;void cleanup()&#xA;{&#xA;    if( m_pFrame || m_pCodecContext )&#xA;    {&#xA;        if( m_pFrame )&#xA;        {&#xA;            av_frame_free( &amp;m_pFrame );&#xA;        }&#xA;&#xA;        if( m_pCodecContext )&#xA;        {&#xA;            avcodec_close( m_pCodecContext );&#xA;            av_free( m_pCodecContext );&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;int main()&#xA;{&#xA;    bool success = true;&#xA;    if (initialize())&#xA;    {&#xA;        if (startExport())&#xA;        {&#xA;            for (int loop = 0; loop &lt; m_frameCount; loop&#x2B;&#x2B;)&#xA;            {&#xA;                if (!exportFrame())&#xA;                {&#xA;                    std::cout &lt;&lt; "Failed to export frame\n";&#xA;                    success = false;&#xA;                    break;&#xA;                }&#xA;            }&#xA;            endExport();&#xA;        }&#xA;        else&#xA;        {&#xA;            std::cout &lt;&lt; "Failed to start export\n";&#xA;            success = false;&#xA;        }&#xA;&#xA;        cleanup();&#xA;    }&#xA;    else&#xA;    {&#xA;        std::cout &lt;&lt; "Failed to initialize export\n";&#xA;        success = false;&#xA;    }&#xA;&#xA;    if (success)&#xA;    {&#xA;        std::cout &lt;&lt; "Successfully exported file\n";&#xA;    }&#xA;    return 1;&#xA;}&#xA;</iostream>

    &#xA;

  • avformat_open_input() error -1330794744 : Could not open input

    22 mai 2014, par Navid

    When I run my code on unix (postproc removed) :

    FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber("https://.../ec769038-22d9-4da9-a7bf-dd4647f97964-353.mp4?__h__=1400667080_dfb4fabf293d258cd501ab4978419392");
    IplImage capturedImage = null;

    try {
       frameGrabber.start();
       long lengthInTime = frameGrabber.getLengthInTime();
       long i = 0;
       while(i &lt; lengthInTime) {
           frameGrabber.setTimestamp(i);
           capturedImage = frameGrabber.grab();
           // if capturedImage is null ... error
           if(capturedImage == null)
               break;
           LOG.info("frame: " + i + "  " + capturedImage.depth());
           i += 10 * 1000 * 1000; // microseconds
       }
       frameGrabber.stop();
       frameGrabber.release();
    } catch (Exception e) {
       LOG.error(e.getMessage());
    }

    I get this error :

    avformat_open_input() error -1330794744: Could not open input "https://.../ec769038-22d9-4da9-a7bf-dd4647f97964-353.mp4?__h__=1400667080_dfb4fabf293d258cd501ab4978419392". (Has setFormat() been called?)

    I am running the program in Red Hat Same code works with local file path.
    I know URL works because the same code (but postproc not excluded) works in Windows.
    I am using Javacv 0.5 both in Red Hat and Windows (that’s the only choice I have at work)

  • How to burn in subtitles onto a webm video with ffmpeg ?

    7 mai 2014, par IcanFLY

    I am trying to set up a livestream with ffserver and ffmpeg. The problem is I am using webm, and I need to burn in subtitles, which are located in a mkv. I am not quite sure how to do this, but here is my ffmpeg config (ffstream.sh) that I am using :

    #Livestream script for FFMpeg/FFServer
    FPS=24                                          # Stream FPS.
    GOP=48                                          # GOP Should be double of FPS.
    THREADS=4                                       # How many threads.
    DEADLINE=realtime                               # Speed preset, realtime is fastest.
    FRAMELAG=16                                     # How many frames to seek ahead (max 25)
    QMAX=52                                         # More = less quality.
    QMIN=10                                         # Less = more quality.
    VBITRATE=1M                                     # Target Bitrate.
    BITRATE=3000k                                   # Bitrate.
    AUDIBR=48k                                      # Audio Bitrate.
    SERVER=<myserver>:8090/feed.ffm                 # Server stream endpoint.
    LOGLEVEL=verbose                                # Logging verbosity level.

    for f in $@; do ffmpeg -re -i $f\
           -vf subtitles=$f\
           -g $GOP -loglevel $LOGLEVEL\
           -c:v:0 libvpx  -threads $THREADS -b:v $BITRATE -vb $VBITRATE -bufsize $BITRATE\
           -qmax $QMAX -qmin $QMIN -deadline $DEADLINE -lag-in-frames $FRAMELAG\
           -c:a libvorbis -b:a $AUDIBR\
           "http://$SERVER"
    done
    </myserver>

    Everything connects fine and I can get audio and video to play, however I cannot seem to get the subtitles to show up. Here is my output (I quit out of it) :

    Stream mapping:
     Stream #0:1 -> #0:0 (flac -> libvorbis)
     Stream #0:0 -> #0:1 (h264 -> libvpx)
    Press [q] to stop, [?] for help
    [output stream 0:0 @ 0x1e77dc0] 100 buffers queued in output stream 0:0, something may be wrong.
    frame=  232 fps= 23 q=0.0 Lsize=     816kB time=00:00:09.67 bitrate= 690.8kbits/s
    video:758kB audio:41kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: 2.113806%
    Input file #0 (<file>.mkv):
     Input stream #0:0 (video): 242 packets read (3343775 bytes); 242 frames decoded;
     Input stream #0:1 (audio): 118 packets read (391060 bytes); 118 frames decoded (483328 samples);
     Input stream #0:2 (audio): 8 packets read (20480 bytes);
     Input stream #0:3 (subtitle): 1 packets read (182 bytes);
     Input stream #0:4 (subtitle): 1 packets read (52 bytes);
     Input stream #0:5 (attachment): 0 packets read (0 bytes);
     Total: 370 packets (3755549 bytes) demuxed
    Output file #0 (http://<myserver>/feed.ffm):
     Output stream #0:0 (audio): 3233 frames encoded (206912 samples); 406 packets muxed (41937 bytes);
     Output stream #0:1 (video): 232 frames encoded; 232 packets muxed (776350 bytes);
     Total: 638 packets (818287 bytes) muxed
    Received signal 2: terminating.
    </myserver></file>

    Also here is my ffserver config, not sure if there is something in here stopping the subtitles from showing up :

    Port 8090
    BindAddress 0.0.0.0
    MaxHTTPConnections 2000
    MaxClients 1000
    MaxBandwidth 10000
    CustomLog -

    <feed>
       File /path/to/folder/tmp/feed.ffm
       FileMaxSize 100M
       #Allow localhost
       ACL allow 127.0.0.1
       ACL allow <myip>
       #It might be a good idea to add your stream source here.
    </myip></feed>


    <stream>
       Feed feed.ffm
       Format webm
       VideoSize hd720 #Must be set here, all input files will be scaled to fit.
       AVOptionVideo flags +global_header
       AVOptionAudio flags +global_header
       StartSendOnKey
    </stream>

    <stream>
       Format status
       ACL allow localhost
    </stream>

    # Redirect index.html to the appropriate site
    <redirect>
       URL http://<myserver>
    </myserver></redirect>

    Any help on how to do this, would be grateful.