Recherche avancée

Médias (1)

Mot : - Tags -/publicité

Autres articles (50)

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur

    8 février 2011, par

    La visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
    Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
    Configuration de la boite multimédia
    Dès (...)

Sur d’autres sites (3019)

  • Write seekable AAC audio stream into MP4 file with FFMPEG

    18 avril 2016, par lex82

    I’m trying to write an AAC audio stream into an mp4 file using the FFMPEG libraries. I am using a custom IO context that writes directly to a socket so I have to set ioContext->seekable = 0. To make this work I had to add the "movflags" empty_moov and frag_keyframe when writing the header.

    After writing the output to a file on the other end of the socket, I can play the file in VLC or Windows Media Player. However, seeking to a specific position in the file is not working properly in both players. WMP also does not show the total duration and VLC only flashes it shortly when reaching the end of the audio.

    Is there a way to add more metadata when muxing so the players are able to treat the file as if it was not written as a stream ? Transfer via the socket is not interrupted abruptly, so I could write metadata at the end of the file. I also know the total duration in advance, so I could add it to the header of the file if it was possible. I cannot use the faststart flag because this would require output to a seekable file before writing to the socket.

    Update : I learned that I can set the duration in AVFormatContext and I can set nb_frames and avg_frame_rate in AVStream. However, it doesn’t solve my problem. When I set the codecContext flag AV_CODEC_FLAG_QSCALE, VLC seems to be able to estimate the total time. However, seeking still doesn’t work.

  • ffmpeg does not decode some h264 streams

    12 janvier 2016, par Andrey

    I have some ip of cameras on the local network.I receive video stream with live555 library (I took testRtspClient as a basis) and decode frames with ffmpeg (avcodec_decode_video2). Everything perfectly works.
    Problems begin when I try to decode a stream from an internet.

    The first problem - some packets lost, so defects appears. But it’s not a problem. Problem - after stop and start video stream it is necessary to wait for about 5 minutes of streaming before ffmpeg is able to decode something from the same ip camera. If packets doesn’t lost then everithing ok.

    The second problem - there is camera which sends video with resolution 2048х1538. The frame of such resolution is sent by several packets. live555 normally brings together them but when the frame is transferred to the decoder, the decoder returns the packet length, but got frame always 0.

    Here some my code :

    #define RECEIVE_BUFFER_SIZE 1000000
    AVCodecContext* avCodecContext; //definition
    AVFrame *frame;  //definition
    ...
    //init code
    _fReceiveBuffer = new uint8_t[RECEIVE_BUFFER_SIZE+512]; //buffer to receive frame
    ZeroMemory(_fReceiveBuffer, RECEIVE_BUFFER_SIZE + 512); //zeros
    _bufferSize = RECEIVE_BUFFER_SIZE * sizeof(uint8_t); //buffer size

    static const  uint8_t startCode[4] = { 0x00, 0x00, 0x00, 0x01 }; //this is for 0 0 0 1
    //before frame will transfer to decoder
    memcpy(_fReceiveBuffer, (void*)startCode, sizeof(uint8_t)* 4);
    _fReceiveBuffer += sizeof(sizeof(uint8_t)* 4);
    _bufferSize -= sizeof(sizeof(uint8_t)* 4);

    AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_H264); //find codec

    avCodecContext = avcodec_alloc_context3(codec);
    avCodecContext->flags |= AV_PKT_FLAG_KEY;
    avcodec_open2(avCodecContext, codec, NULL);

    frame = av_frame_alloc();

    //frame
    void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes,
    struct timeval presentationTime, unsigned durationInMicroseconds) {

    if (strcmp(fSubsession.codecName(), "H264") == 0)
    {
       //code from onvif device manager
       static const uint8_t startCode3[] = { 0x00, 0x00, 0x01 };
       static const uint8_t startCode4[] = { 0x00, 0x00, 0x00, 0x01 };
       auto correctedFrameSize = frameSize;
       auto correctedBufferPtr = fPlObj->_fReceiveBuffer;
       if (frameSize < sizeof(startCode4) || memcmp(startCode4, correctedBufferPtr, sizeof(startCode4)) != 0){
           if (frameSize < sizeof(startCode3) || memcmp(startCode3, correctedBufferPtr, sizeof(startCode3)) != 0){
               correctedFrameSize += sizeof(uint8_t)* 4;
               correctedBufferPtr -= sizeof(uint8_t)* 4;
           }
       }

       ProcessFrame(correctedBufferPtr, correctedFrameSize, presentationTime, durationInMicroseconds);
    }
    continuePlaying();
    }

    void DummySink::ProcessFrame(unsigned char* framePtr, int frameSize, struct timeval presentationTime, unsigned duration)    {

    AVPacket avpkt;
    av_init_packet(&avpkt);
    avpkt.data = framePtr;
    avpkt.size = frameSize;
    while (avpkt.size > 0) {
       int got_frame = 0;

       int len = avcodec_decode_video2(avCodecContext, frame, &got_frame, &avpkt);
       if (len < 0) {
           //TODO: log error
           return;
       }
       else if (got_frame == 0)
       {
    //I tried this code, bacause "codecs which have the AV_CODEC_CAP_DELAY capability set have a delay between input and output"
    //but it didn't help
           /*AVPacket emptyPacket;
           av_init_packet(&emptyPacket);
           emptyPacket.data = NULL;
           emptyPacket.size = 0;
           emptyPacket.stream_index = avpkt.stream_index;
           len = avcodec_decode_video2(avCodecContext, frame, &got_frame, &emptyPacket);
           if ( got_frame == 1) goto next;*/
           return;
       }
    next:
       //... here code for view with DirectDraw - everithing ok with it
       avpkt.size -= len;
       avpkt.data += len;
    }
    }

    I alsa tried to send frame to decoder with sps and pps information :

    0 0 0 1 sps 0 0 0 1 pps 0 0 0 1 frame

    but it is not help.

    Interesting that avcodec_decode_video2 does not return frame with second problem (return all size of frame), but width and height in avCodecContext are set correctly. I can’t understart why it doesn’t return frame.

    Can anyone help with these problems ?

  • Safari on Mac and IOS 14 Won't Play HTML 5 MP4 Video

    10 mars 2021, par Glen Elkins

    So i have developed a chat application that uses node for the back-end. When a user selects a video on their iphone it usually is .mov format so when it's sent to the node server it's then converted to mp4 with ffmpeg. All that works fine, then if i load up my chat again in Chrome on my mac the video plays just fine as the mp4.

    


    enter image description here

    


    This screenshot shows the video embed is there, set to mp4 yet it won't play in Safari on my mac or my phone, in fact it just shows the video as 0 seconds long yet i can play it in chrome and also download the mp4 file by accessing the embed url directly.

    


    Any ideas ? I had it convert to mp4 to prevent things like this, but safari doesn't seem to even like mp4 files.

    


    The back-end part that serves the private file is in Symfony 4 (PHP) :

    


    /**
     * @Route("/private/files/download/{base64Path}", name="downloadFile")
     * @param string $base64Path
     * @param Request $request
     * @return Response
     */
    public function downloadFile(string $base64Path, Request $request) : Response
    {


        // get token
        if(!$token = $request->query->get('token')){
            return new Response('Access Denied',403);
        }



        /** @var UserRepository $userRepo */
        $userRepo = $this->getDoctrine()->getRepository(User::class);

        /** @var User $user */
        if(!$user = $userRepo->findOneBy(['deleted'=>false,'active'=>true,'systemUser'=>false,'apiKey'=>$token])){
            return new Response('Access Denied',403);
        }



        // get path
        if($path = base64_decode($base64Path)){

            // make sure the folder we need exists
            $fullPath = $this->getParameter('private_upload_folder') . '/' . $path;



            if(!file_exists($fullPath)){
                return new Response('File Not Found',404);
            }

        

            $response = new Response();
            $response->headers->set('Content-Type', mime_content_type($fullPath));
            $response->headers->set('Content-Disposition', 'inline; filename="' . basename($fullPath) . '"');
            $response->headers->set('Content-Length', filesize($fullPath));
            $response->headers->set('Pragma', "no-cache");
            $response->headers->set('Expires', "0");
            $response->headers->set('Content-Transfer-Encoding', "binary");

            $response->sendHeaders();

            $response->setContent(readfile($fullPath));

            return $response;
        }

        return new Response('Invalid Path',404);
    }


    


    This works fine everywhere except safari when trying to embed the video. It's done like this because the videos are not public and need an access token.

    


    UPDATE : Here is a test link of an mp4, you'll have to allow the insecure certificate as it's on a quick test sub domain. If you open it in chrome, you'll see a 3 second video of my 3d printer curing station, if you load the same link in safari, you'll see it doesn't work

    


    https://tester.nibbrstaging.com/private/files/download/Y2hhdC83Nzk1Y2U2MC04MDFmLTExZWItYjkzYy1lZjI4ZGYwMDhkOTMubXA0?token=6ab1720bfe922d44208c25f655d61032

    


    The server runs on cPanel with Apache and i think it might be something to do with the video needs streaming ?

    


    UPDATED CODE THAT WORKS IN SAFARI BUT NOW BROKEN IN CHROME :

    


    Chrome is now giving Content-Length : 0 but it's working fine in safari.

    


    public function downloadFile(string $base64Path, Request $request) : ?Response
    {

        ob_clean();

        // get token
        if(!$token = $request->query->get('token')){
            return new Response('Access Denied',403);
        }


        

        /** @var UserRepository $userRepo */
        $userRepo = $this->getDoctrine()->getRepository(User::class);

        /** @var User $user */
        if(!$user = $userRepo->findOneBy(['deleted'=>false,'active'=>true,'systemUser'=>false,'apiKey'=>$token])){
            return new Response('Access Denied',403);
        }



        // get path
        if($path = base64_decode($base64Path)){

            // make sure the folder we need exists
            $fullPath = $this->getParameter('private_upload_folder') . '/' . $path;



            if(!file_exists($fullPath)){
                return new Response('File Not Found',404);
            }


            $filesize = filesize($fullPath);
            $mime = mime_content_type($fullPath);

            header('Content-Type: ' . $mime);

            if(isset($_SERVER['HTTP_RANGE'])){

                // Parse the range header to get the byte offset
                $ranges = array_map(
                    'intval', // Parse the parts into integer
                    explode(
                        '-', // The range separator
                        substr($_SERVER['HTTP_RANGE'], 6) // Skip the `bytes=` part of the header
                    )
                );



                // If the last range param is empty, it means the EOF (End of File)
                if(!$ranges[1]){
                    $ranges[1] = $filesize - 1;
                }

                header('HTTP/1.1 206 Partial Content');
                header('Accept-Ranges: bytes');
                header('Content-Length: ' . ($ranges[1] - $ranges[0])); // The size of the range

                // Send the ranges we offered
                header(
                    sprintf(
                        'Content-Range: bytes %d-%d/%d', // The header format
                        $ranges[0], // The start range
                        $ranges[1], // The end range
                        $filesize // Total size of the file
                    )
                );

                // It's time to output the file
                $f = fopen($fullPath, 'rb'); // Open the file in binary mode
                $chunkSize = 8192; // The size of each chunk to output

                // Seek to the requested start range
                fseek($f, $ranges[0]);

                // Start outputting the data
                while(true){
                    // Check if we have outputted all the data requested
                    if(ftell($f) >= $ranges[1]){
                        break;
                    }

                    // Output the data
                    echo fread($f, $chunkSize);

                    // Flush the buffer immediately
                    @ob_flush();
                    flush();
                }
            }else{

                // It's not a range request, output the file anyway
                header('Content-Length: ' . $filesize);

                // Read the file
                @readfile($filesize);

                // and flush the buffer
                @ob_flush();
                flush();



            }

        }else {

            return new Response('Invalid Path', 404);
        }
    }


    


    I have notice in chrome that it's sending the range header like this :

    


    Range : bytes=611609-

    


    Where safari sends

    


    Range : bytes=611609-61160

    


    So for some reason chrome is missing the second range amount, that obviously means my code can't find a range number for the second one.

    


    Doesn’t matter what I do I can’t get it working in both chrome and safari. Safari wants the byte range part , chrome seems to request it then sends a new request for the full file but even the full file part of the code gives a 500 error. If I take out the byte range bit then it works fine in chrome but not safari.

    


    UPDATE :

    


    Here is some strange things going on in chrome :

    


    For the video i am testing with it makes 3 range requests :

    


    REQUEST 1 HEADERS - asking for bytes 0- (to the end of the file)

    


    GET /private/files/download/Y2hhdC83Nzk1Y2U2MC04MDFmLTExZWItYjkzYy1lZjI4ZGYwMDhkOTMubXA0?token=6ab1720bfe922d44208c25f655d61032 HTTP/1.1

Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36
Accept-Encoding: identity;q=1, *;q=0
Accept: */*
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: no-cors
Sec-Fetch-Dest: video
Referer: https://gofollow.vip/
Accept-Language: en-US,en;q=0.9
Range: bytes=0-


    


    RESPONSE GIVES IT BACK ALL THE BYTES IN THE FILE AS THAT'S WHAT WAS ASKED FOR BY CHROME :

    


    HTTP/1.1 206 Partial Content
Date: Wed, 10 Mar 2021 12:35:54 GMT
Server: Apache
Accept-Ranges: bytes
Content-Length: 611609
Content-Range: bytes 0-611609/611610
Vary: User-Agent
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: video/mp4


    


    SECOND REQUEST HEADERS : NOW IT'S ASKING FOR 589824 to the end of the file :

    


    Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36
Accept-Encoding: identity;q=1, *;q=0
Accept: */*
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: no-cors
Sec-Fetch-Dest: video
Referer: https://gofollow.vip/
Accept-Language: en-US,en;q=0.9
Range: bytes=589824-


    


    RESPONSE OBLIGES :

    


    HTTP/1.1 206 Partial Content
Date: Wed, 10 Mar 2021 12:35:55 GMT
Server: Apache
Accept-Ranges: bytes
Content-Length: 21785
Content-Range: bytes 589824-611609/611610
Vary: User-Agent
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: video/mp4


    


    THEN IT'S MAKING THIS 3rd REQUEST THAT GIVES AN INTERNAL SERVER ERORR, THIS TIME IT'S LITERALLY ASKING FOR THE LAST BYTE :

    


    GET /private/files/download/Y2hhdC83Nzk1Y2U2MC04MDFmLTExZWItYjkzYy1lZjI4ZGYwMDhkOTMubXA0?token=6ab1720bfe922d44208c25f655d61032 HTTP/1.1

Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36
Accept-Encoding: identity;q=1, *;q=0
Accept: */*
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: no-cors
Sec-Fetch-Dest: video
Referer: https://gofollow.vip/
Accept-Language: en-US,en;q=0.9
Range: bytes=611609-


    


    RESPONSE - THE CONTENT LENGTH IS 0 BECAUSE THERE IS NO DIFFERENCE BETWEEN THE REQUESTED BYTES AND THE BYTES RETURNED :

    


    HTTP/1.1 500 Internal Server Error
Date: Wed, 10 Mar 2021 12:35:56 GMT
Server: Apache
Accept-Ranges: bytes
Cache-Control: max-age=0, must-revalidate, private
X-Frame-Options: DENY
X-XSS-Protection: 1
X-Content-Type-Options: nosniff
Referrer-Policy: origin
Strict-Transport-Security: max-age=31536000; includeSubDomains
Expires: Wed, 10 Mar 2021 12:35:56 GMT
Content-Length: 0
Content-Range: bytes 611609-611609/611610
Vary: User-Agent
Connection: close
Content-Type: text/html; charset=UTF-8