Recherche avancée

Médias (91)

Autres articles (33)

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
    sur le web 2.0 et dans les entreprises qui en vivent.
    Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
    Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
    le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
    Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

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

  • Decode frame produced by ffmpeg lib using webcodecs

    24 mars 2023, par mccat

    server side extracting frame from video using ffmpeg library. Here is code :

    


        AVFormatContext *pFormatContext = avformat_alloc_context();&#xA;    avformat_open_input(&amp;pFormatContext, "VID_20230219_171331_300.mp4.mov", NULL, NULL);&#xA;    avformat_find_stream_info(pFormatContext,  NULL);&#xA;&#xA;    const AVCodec *pCodec = NULL;&#xA;    AVCodecParameters *pCodecParameters =  NULL;&#xA;    int video_stream_index = -1;&#xA;&#xA;    // loop though all the streams and print its main information&#xA;    for (int i = 0; i &lt; pFormatContext->nb_streams; i&#x2B;&#x2B;)&#xA;    {&#xA;        AVCodecParameters *pLocalCodecParameters =  NULL;&#xA;        pLocalCodecParameters = pFormatContext->streams[i]->codecpar;&#xA;        const AVCodec *pLocalCodec = NULL;&#xA;        pLocalCodec = avcodec_find_decoder(pLocalCodecParameters->codec_id);&#xA;&#xA;        if(pLocalCodec==NULL)&#xA;            continue;&#xA;&#xA;        // when the stream is a video we store its index, codec parameters and codec&#xA;        if(pLocalCodecParameters->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;            if(video_stream_index == -1)&#xA;            {&#xA;                video_stream_index = i;&#xA;                pCodec = pLocalCodec;&#xA;                pCodecParameters = pLocalCodecParameters;&#xA;&#xA;                const char *buffer = reinterpret_cast <const> (pFormatContext->streams[i]->codecpar->extradata);&#xA;                QFile file("extradata.txt"); //!!!!!!!!!!!!!!!! storing extradata for browser visualization&#xA;                file.open(QIODevice::WriteOnly);&#xA;                QDataStream out(&amp;file);&#xA;                out.writeRawData(buffer, pFormatContext->streams[i]->codecpar->extradata_size);&#xA;                file.flush();&#xA;                file.close();&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    AVCodecContext *pCodecContext = avcodec_alloc_context3(pCodec);&#xA;    avcodec_parameters_to_context(pCodecContext, pCodecParameters);&#xA;    avcodec_open2(pCodecContext, pCodec, NULL);&#xA;&#xA;    AVFrame *pFrame = av_frame_alloc();&#xA;    AVPacket *pPacket = av_packet_alloc();&#xA;&#xA;    int response = 0;&#xA;    int how_many_packets_to_process = 800;&#xA;&#xA;    int frame_c = 0, counter = 0;&#xA;    while(true)&#xA;    {&#xA;        frame_c = av_read_frame(pFormatContext, pPacket);&#xA;&#xA;        if(frame_c &lt; 0)&#xA;            break;&#xA;&#xA;        if(pPacket->stream_index == video_stream_index)&#xA;        {&#xA;            const char *buffer = reinterpret_cast <const> (pPacket->data);&#xA;            response = decode_packet(pPacket, pCodecContext, pFrame);&#xA;&#xA;            if(response &lt; 0)&#xA;                break;&#xA;&#xA;            counter&#x2B;&#x2B;;&#xA;            if(--how_many_packets_to_process &lt;= 0) break;&#xA;&#xA;            if(counter > 1)&#xA;            {&#xA;                QFile file("frame.txt"); // !!!!!!!!!!!!!!!! storing single frame for browser visualization&#xA;                file.open(QIODevice::WriteOnly);&#xA;                QDataStream out(&amp;file);&#xA;                out.writeRawData(buffer, arr.size());&#xA;                file.flush();&#xA;                file.close();&#xA;                break;&#xA;            }&#xA;        }&#xA;&#xA;        av_packet_unref(pPacket);&#xA;    }&#xA;</const></const>

    &#xA;

    As the result i stored 2 txt files : 1 with extradata of codec and 2 with frame pixel data.&#xA;The next step is to decode this data in browser and display picture.&#xA;Here is how i try to do it :

    &#xA;

    <input type="file" />&#xA;<h3>Contents of the file:</h3>&#xA;<pre></pre>&#xA;&#xA;<input type="file" />&#xA;<h3>Contents of the file:</h3>&#xA;<pre></pre>&#xA;&#xA;<canvas width="720" height="1280">&#xA;Your browser does not support the HTML5 canvas tag.&#xA;</canvas>&#xA;&#xA;<code class="echappe-js">&lt;script&gt;&amp;#xA;&amp;#xA;let pendingFrames = [];&amp;#xA;let extraData = new Uint8Array;&amp;#xA;&amp;#xA;const init = {&amp;#xA;  output: handleFrame,&amp;#xA;  error: (e) =&gt; {&amp;#xA;  console.log(e.message);&amp;#xA;  },&amp;#xA;};&amp;#xA;&amp;#xA;const config = {&amp;#xA;  codec: &quot;avc1.64001E&quot;,&amp;#xA;  codedWidth:  720,&amp;#xA;  codedHeight: 1280,&amp;#xA;  description: extraData.buffer,&amp;#xA;};&amp;#xA;&amp;#xA;function handleFrame(frame) {&amp;#xA;  const canvas = document.getElementById(&quot;myCanvas&quot;);&amp;#xA;  const ctx = canvas.getContext(&quot;2d&quot;);&amp;#xA;  ctx.drawImage(frame, 0, 0);&amp;#xA;  frame.close();&amp;#xA;}&amp;#xA;&amp;#xA;function readSingleFile(e) {&amp;#xA;  var file = e.target.files[0];&amp;#xA;  if (!file) {&amp;#xA;    return;&amp;#xA;  }&amp;#xA;  var reader = new FileReader();&amp;#xA;  reader.onload = function(e) {&amp;#xA;    var contents = e.target.result;&amp;#xA;    displayContents(contents);&amp;#xA;  };&amp;#xA;  reader.readAsText(file);&amp;#xA;} //end&amp;#xA;&amp;#xA;function displayContents(contents) {&amp;#xA;  var element = document.getElementById(&amp;#x27;file-content&amp;#x27;);&amp;#xA;  element.textContent = contents;&amp;#xA;} // end&amp;#xA;&amp;#xA;const readFile = e =&gt; {&amp;#xA;  var file = e.target.files[0];&amp;#xA;  if (!file) {&amp;#xA;    return;&amp;#xA;  }&amp;#xA;&amp;#xA;  let reader = new FileReader();&amp;#xA;&amp;#xA;  reader.onload = function(e) {&amp;#xA;      let arrayBuffer = new Uint8Array(reader.result);&amp;#xA;      console.log(arrayBuffer);&amp;#xA;&amp;#xA;        const decoder = new VideoDecoder(init);&amp;#xA;        decoder.configure(config);&amp;#xA;        &amp;#xA;        const chunk = new EncodedVideoChunk({&amp;#xA;          timestamp: 20,&amp;#xA;          type: &quot;key&quot;,&amp;#xA;          data: arrayBuffer,&amp;#xA;        });&amp;#xA;&amp;#xA;        decoder.decode(chunk);&amp;#xA;  }&amp;#xA;&amp;#xA;  reader.readAsArrayBuffer(file);&amp;#xA;} //end&amp;#xA;&amp;#xA;const readFile2 = e =&gt; {&amp;#xA;  var file = e.target.files[0];&amp;#xA;  if (!file) {&amp;#xA;    return;&amp;#xA;  }&amp;#xA;&amp;#xA;  let reader = new FileReader();&amp;#xA;&amp;#xA;  reader.onload = function(e) {&amp;#xA;      extraData = new Uint8Array(reader.result);&amp;#xA;      console.log(extraData);&amp;#xA;  }&amp;#xA;&amp;#xA;  reader.readAsArrayBuffer(file);&amp;#xA;} //end&amp;#xA;&amp;#xA;document.getElementById(&amp;#x27;file-input&amp;#x27;)&amp;#xA;  .addEventListener(&amp;#x27;change&amp;#x27;, readFile, false);&amp;#xA;&amp;#xA;document.getElementById(&amp;#x27;file-input2&amp;#x27;)&amp;#xA;  .addEventListener(&amp;#x27;change&amp;#x27;, readFile2, false);&amp;#xA;&amp;#xA;&lt;/script&gt;&#xA;

    &#xA;

    file-input2 - is for extradata and file-input - for frame data.

    &#xA;

    After i run this code in browser i got following error message :&#xA;---> Failed to execute 'configure' on 'VideoDecoder' : description is detached.&#xA;Also i had another type of error messages such as something wrong with codec config (codec description)

    &#xA;

    Please help to find what im doing wrong =)&#xA;Thanks in advance.

    &#xA;

  • FFMPEG how to use https dynamic url as input for amovie filter

    2 juillet 2020, par Johny Sharma

    Basically what i am trying to do is to calling a dynamic php url which is generating a audio file for me and just want to use that file as an input for amovie filter.&#xA;I hope you have understand my question.

    &#xA;

    What i have done so far ?

    &#xA;

    I have a FFMPEG code which is :

    &#xA;

    ffmpeg-y -i &#x27;bg-file.mp3&#x27; -c copy -map 0:0 -map 1:0 -filter_complex "amovie=&#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;:loop=999[sc][mix];[0:a][sc]sidechaincompress=threshold=0.100:ratio=20,volume=10dB:precision=fixed[bg], [bg][mix]amix=duration=first"  -c:a libmp3lame -ac 2  "save.mp3"&#xA;

    &#xA;

    This line is calling my dynamic url for generating the required song.

    &#xA;

    "amovie=&#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;&#xA;

    &#xA;

    Everything is working if i check them apart. but when i use them together the ffmpeg is giving the following error.

    &#xA;

    [22] => [Parsed_amovie_0 @ 0x1378140] Failed to avformat_open_input &#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;:loop=999&#x27;&#xA;[23] => [AVFilterGraph @ 0x1368ca0] Error initializing filter &#x27;amovie&#x27; with args &#x27;/auth.php?input=string&amp;l=hi&amp;f.mp3&#x27;:loop=999&#x27;&#xA;[24] => Error initializing complex filters.&#xA;[25] => No such file or directory&#xA;

    &#xA;

    I dont know is it possible to put a dynamically generated url as an input for amovie filter or not ?&#xA;if i open my dynamic url in browser its works like a mp3 file and play similar to any mp3 file.

    &#xA;

    using this code to play that mp3 :

    &#xA;

    header(&#x27;Content-Description: File Transfer&#x27;);&#xA;header(&#x27;Content-Type: application/octet-stream&#x27;);&#xA;header(&#x27;Content-Disposition: attachment; filename=&#x27;.basename($path));&#xA;header(&#x27;Content-Transfer-Encoding: binary&#x27;);&#xA;header(&#x27;Expires: 0&#x27;);&#xA;header(&#x27;Cache-Control: must-revalidate, post-check=0, pre-check=0&#x27;);&#xA;header(&#x27;Pragma: public&#x27;);&#xA;ob_clean();&#xA;flush();&#xA;readfile($path);&#xA;exit;&#xA;

    &#xA;

    This one looks similar to my query but slightly different and that's why i am still looking for a solution

    &#xA;

    How to use https input with ffmpeg "amovie" filter ?

    &#xA;

  • Java - send command to FFMPEG process to stop

    2 septembre 2022, par Varun Bali

    I am trying to integrate FFMPEG for screen capture in my program & when the time comes to stop the capture I have to pass 'q' in the commandline to stop the render & save the capture in MP4 file. Unfortunately I am not able to stop FFMPEG & it continues to run in the background. The screenshot below shows FFMPEG running when executed manually via terminal or CMD that q key needs to be passed to halt it.

    &#xA;

    enter image description here

    &#xA;

    Below is my code so far :

    &#xA;

    public static void main(String[] args) throws IOException&#xA;{&#xA;    var processBuilder = new ProcessBuilder();&#xA;    var file = new File("D:\\ffmpeg-5.1-essentials_build\\bin");&#xA;    processBuilder.directory(file);&#xA;    processBuilder.command("CMD", "/C", "ffmpeg.exe -f gdigrab -i desktop -c:v libx264 -b:v 6000K -minrate 6000K -maxrate 6000K -bufsize 6000K -pix_fmt yuv420p -r 60 -profile:v main -crf 12 -x264-params scenecut=0:open_gop=0:min-keyint=72:keyint=72 -y " &#x2B;&#xA;                    "D:\\Users\\vabali\\Documents\\Workspace\\Captures\\output.mp4");&#xA;    var process = processBuilder.start();&#xA;    Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> process.descendants().toList().size() > 1);&#xA;    System.out.println("FFMPEG PID = " &#x2B; process.descendants().toList().get(1).pid());&#xA;    var output = process.getOutputStream();&#xA;    output.write(KeyEvent.VK_Q);&#xA;    output.flush();&#xA;    System.out.println(process.descendants().toList().get(1).isAlive());&#xA;

    &#xA;

    }

    &#xA;

    I have tried output.write('q'), output.write("q".getBytes()) but nothing has worked so far. Using the destroy method terminates ffmpeg but abnormal termination corrupts the MP4 making it useless. The program has stop graciously. Can someone help me to figure out how to pass q to console to stop the render ?

    &#xA;