Recherche avancée

Médias (0)

Mot : - Tags -/masques

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (49)

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

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (7880)

  • Use Named Pipe (C++) to send images to FFMPEG

    28 août 2015, par user1829136

    I have the following code in C++ :

    #include <iostream>
    #include
    #include <iostream>     // std::cout
    #include <fstream>      // std::ifstream
    #include <vector>
    #include

    using namespace std;

    int main(int argc, const char **argv)
    {
       wcout &lt;&lt; "Creating an instance of a named pipe..." &lt;&lt; endl;

       // Create a pipe to send data
       HANDLE pipe = CreateNamedPipe(
           L"\\\\.\\pipe\\my_pipe", // name of the pipe
           PIPE_ACCESS_OUTBOUND, // 1-way pipe -- send only
           PIPE_TYPE_BYTE, // send data as a byte stream
           1, // only allow 1 instance of this pipe
           0, // no outbound buffer
           0, // no inbound buffer
           0, // use default wait time
           NULL // use default security attributes
       );

       if (pipe == NULL || pipe == INVALID_HANDLE_VALUE) {
           wcout &lt;&lt; "Failed to create outbound pipe instance.";
           // look up error code here using GetLastError()
           system("pause");
           return 1;
       }

       wcout &lt;&lt; "Waiting for a client to connect to the pipe..." &lt;&lt; endl;

       // This call blocks until a client process connects to the pipe
       BOOL result = ConnectNamedPipe(pipe, NULL);
       if (!result) {
           wcout &lt;&lt; "Failed to make connection on named pipe." &lt;&lt; endl;
           // look up error code here using GetLastError()
           CloseHandle(pipe); // close the pipe
           system("pause");
           return 1;
       }

       wcout &lt;&lt; "Sending data to pipe..." &lt;&lt; endl;

       //opening file
       ifstream infile;
       infile.open("E:/xmen.jpg",std::ios::binary);
       ofstream out("E:/lelel.jpg",std::ios::binary);

       infile.seekg(0,std::ios::end);
       size_t file_size_in_byte = infile.tellg();
       vector<char> file_vec;

       file_vec.resize(file_size_in_byte);

       infile.seekg(0,std::ios::beg);
       infile.read(&amp;file_vec[0],file_size_in_byte);

       out.write(&amp;file_vec[0],file_vec.size());

       wcout&lt;/ This call blocks until a client process reads all the data
       DWORD numBytesWritten = 0;
       result = WriteFile(
           pipe, // handle to our outbound pipe
           &amp;file_vec[0], // data to send
           61026, // length of data to send (bytes)
           &amp;numBytesWritten, // will store actual amount of data sent
           NULL // not using overlapped IO
       );


       if (result) {
           wcout &lt;&lt; "Number of bytes sent: " &lt;&lt; numBytesWritten &lt;&lt; endl;
       } else {
           wcout &lt;&lt; "Failed to send data." &lt;&lt; endl;
           // look up error code here using GetLastError()
       }

       // Close the pipe (automatically disconnects client too)
       CloseHandle(pipe);

       wcout &lt;&lt; "Done." &lt;&lt; endl;

       system("pause");
       return 0;
    }
    </char></vector></fstream></iostream></iostream>

    Which I use to create a named pipe \.\pipe\my_pipe, to which FFMPEG connects to, using the following command :

    64-static\bin\Video>ffmpeg.exe -loop 1 -s 4cif -f image2 -y -i \\.\pipe\\my_pipe

    -r 25 -vframes 250 -vcodec rawvideo -an eaeew.mov

    Output :

    ffmpeg version N-54233-g86190af Copyright (c) 2000-2013 the FFmpeg developers
     built on Jun 27 2013 16:49:12 with gcc 4.7.3 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib  libavutil      52. 37.101 / 52. 37.101
     libavcodec     55. 17.100 / 55. 17.100
     libavformat    55. 10.100 / 55. 10.100
     libavdevice    55.  2.100 / 55.  2.100
     libavfilter     3. 77.101 /  3. 77.101
     libswscale      2.  3.100 /  2.  3.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  3.100 / 52.  3.100
    [image2 @ 0000000003ee04a0] Could find no file with with path '\\.\pipe\\my_pipe
    ' and index in the range 0-4
    \\.\pipe\\my_pipe: No such file or directory

    I can see on my console that my C++ app received a connection, but I get the error above in FFMPEG. Can someone please advise ?

    EDIT 1
    Using the command below

    ffmpeg.exe -s 4cif -i \\.\pipe\my_pipe -r 25 -vframes 250 -vcodec rawvideo -an tess.mov

    I get the following output

    ffmpeg version N-54233-g86190af Copyright (c) 2000-2013 the FFmpeg developers
     built on Jun 27 2013 16:49:12 with gcc 4.7.3 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
     libavutil      52. 37.101 / 52. 37.101
     libavcodec     55. 17.100 / 55. 17.100
     libavformat    55. 10.100 / 55. 10.100
     libavdevice    55.  2.100 / 55.  2.100
     libavfilter     3. 77.101 /  3. 77.101
     libswscale      2.  3.100 /  2.  3.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  3.100 / 52.  3.100
    \\.\pipe\my_pipe: Invalid data found when processing input

    So, now it seems it was able to connect to the pipe but is not able to process the input.

  • Uploading video to Twitter sometimes doesn't work

    22 juillet 2021, par K-s S-k

    I have a very difficult situation. I've already spent 2 days and couldn't find a solution. Project on Laravel. I want to upload videos to Twitter using the Twitter API endpoints. But sometimes I am getting this error :

    &#xA;

    &#xA;

    file is currently unsupported

    &#xA;

    &#xA;

    I did everything as recommended in the official documentation Video specifications and recommendations. I get an error when I set an audio codec is aac in my video file, despite the fact that it is recommended in the official documentation, but when I set the audio codec to mp3, the video is uploaded, but the sound quality is very poor, and sometimes there is no sound at all. Please forgive me if this is awkward to read, but I want to provide all of my code. Because I don't know how to solve this anymore and I think it might help.

    &#xA;

    &lt;?php&#xA;&#xA;namespace App\Jobs;&#xA;&#xA;use App\Models\PublishedContent;&#xA;use Atymic\Twitter\Facades\Twitter;&#xA;use GuzzleHttp\Client as GuzzleClient;&#xA;use GuzzleHttp\Exception\GuzzleException;&#xA;use Illuminate\Bus\Queueable;&#xA;use Illuminate\Support\Facades\Log;&#xA;use Illuminate\Support\Facades\File;&#xA;use Illuminate\Queue\SerializesModels;&#xA;use Illuminate\Queue\InteractsWithQueue;&#xA;use Illuminate\Contracts\Queue\ShouldQueue;&#xA;use Illuminate\Foundation\Bus\Dispatchable;&#xA;use Illuminate\Support\Str;&#xA;&#xA;&#xA;class PublishToTwitter implements ShouldQueue&#xA;{&#xA;    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;&#xA;&#xA;    /**&#xA;     * @var&#xA;     */&#xA;    protected $publishingData;&#xA;&#xA;    /**&#xA;     * Create a new job instance.&#xA;     *&#xA;     * @param $publishingData&#xA;     */&#xA;    public function __construct($publishingData)&#xA;    {&#xA;        $this->publishingData = $publishingData;&#xA;    }&#xA;&#xA;    /**&#xA;     * Execute the job.&#xA;     *&#xA;     * @return void&#xA;     */&#xA;    public function handle()&#xA;    {&#xA;        $publishingData = $this->publishingData;&#xA;&#xA;        if (is_array($publishingData)) {&#xA;            $publishingResult = $this->publishing(...array_values($publishingData));&#xA;            sendNotification($publishingResult[&#x27;message&#x27;], $publishingResult[&#x27;status&#x27;], &#x27;Twitter&#x27;, $publishingResult[&#x27;link&#x27;], $publishingData[&#x27;post_name&#x27;], $publishingData[&#x27;user&#x27;]);&#xA;        } else {&#xA;            $scheduledData = processingScheduledPost($publishingData);&#xA;            $postName = $scheduledData[&#x27;scheduleData&#x27;][&#x27;post_name&#x27;];&#xA;            $postContent = $scheduledData[&#x27;scheduleData&#x27;][&#x27;post_content&#x27;];&#xA;            $userToken = json_decode($publishingData->user_token,true);&#xA;            $requestToken = [&#xA;                &#x27;token&#x27;  => $userToken[&#x27;oauth_token&#x27;],&#xA;                &#x27;secret&#x27; => $userToken[&#x27;oauth_token_secret&#x27;],&#xA;            ];&#xA;            $publishingResult = $this->publishing($scheduledData[&#x27;file&#x27;], $postName, $postContent, $requestToken);&#xA;            $publishingResult[&#x27;status&#x27;] &amp;&amp; PublishedContent::add($scheduledData[&#x27;craft&#x27;], $scheduledData[&#x27;file&#x27;], "twitter_share");&#xA;            sendResultToUser($publishingData, $scheduledData[&#x27;user&#x27;], $publishingResult[&#x27;message&#x27;], $postName, $publishingResult[&#x27;link&#x27;], $publishingResult[&#x27;publishing_status&#x27;], $scheduledData[&#x27;social_media&#x27;]);&#xA;            sendNotification($publishingResult[&#x27;message&#x27;], $publishingResult[&#x27;status&#x27;], &#x27;Twitter&#x27;, $publishingResult[&#x27;link&#x27;], $postName, $scheduledData[&#x27;user&#x27;]);&#xA;        }&#xA;    }&#xA;&#xA;    /**&#xA;     * @param $file&#xA;     * @param $postName&#xA;     * @param $postContent&#xA;     * @param $requestToken&#xA;     * @return array&#xA;     */&#xA;    private function publishing($file, $postName, $postContent, $requestToken): array&#xA;    {&#xA;        $result = [&#xA;            &#x27;status&#x27; => false,&#xA;            &#x27;link&#x27; => null,&#xA;            &#x27;message&#x27; => &#x27;Your content can\&#x27;t successfully published on Twitter. This file is not supported for publishing.&#x27;,&#xA;            &#x27;publishing_status&#x27; => &#x27;error&#x27;&#xA;        ];&#xA;&#xA;        if ((($file->refe_type !== &#x27;text&#x27;) || $file->refe_file_path) &amp;&amp; !checkIfFileExist($file->refe_file_path)) {&#xA;            $result[&#x27;message&#x27;] = &#x27;Missing or invalid file.&#x27;;&#xA;            return $result;&#xA;        }&#xA;&#xA;        $filePath = $file->refe_file_path;&#xA;        $fileSize = $file->content_length;&#xA;        $tempFileName = &#x27;temp-&#x27; . $file->refe_file_name;&#xA;        $ext = $file->file_type;&#xA;        $mediaCategory = &#x27;tweet_&#x27; . $file->refe_type;&#xA;        $mediaType = $file->refe_type . &#x27;/&#x27; . $ext;&#xA;        $remoteFile = file_get_contents($filePath);&#xA;        $tempFolder = public_path(&#x27;/storage/uploads/temp&#x27;);&#xA;&#xA;        if (!file_exists($tempFolder)) {&#xA;            mkdir($tempFolder, 0777, true);&#xA;        }&#xA;&#xA;        $tempFile = public_path(&#x27;/storage/uploads/temp/&#x27; . $tempFileName);&#xA;        File::put($tempFile, $remoteFile);&#xA;        $convertedFileName = &#x27;converted-&#x27; . $file->refe_file_name;&#xA;        $convertedFile = public_path(&#x27;/storage/uploads/temp/&#x27; . $convertedFileName);&#xA;        $command = &#x27;ffmpeg -y -i &#x27;.$tempFile.&#x27; -b:v 5000k -b:a 380k -c:a aac -profile:a aac_low -threads 1 &#x27;.$convertedFile.&#x27;&#x27;;&#xA;        exec($command);&#xA;        @File::delete($tempFile);&#xA;&#xA;        try {&#xA;            $twitter = Twitter::usingCredentials($requestToken[&#x27;token&#x27;], $requestToken[&#x27;secret&#x27;]);&#xA;            if ($file->refe_type === &#x27;text&#x27;) {&#xA;                $twitter->postTweet([&#xA;                    &#x27;status&#x27; => urldecode($postContent),&#xA;                    &#x27;format&#x27; => &#x27;json&#x27;,&#xA;                ]);&#xA;&#xA;                $result[&#x27;link&#x27;] = &#x27;https://twitter.com/home&#x27;;&#xA;                $result[&#x27;status&#x27;] = true;&#xA;                $result[&#x27;message&#x27;] = &#x27;Your content successfully published on Twitter. You can visit to Twitter and check it.&#x27;;&#xA;                $result[&#x27;publishing_status&#x27;] = &#x27;done&#x27;;&#xA;            } else if ($file->refe_type === &#x27;video&#x27; || $file->refe_type === &#x27;image&#x27;) {&#xA;                if ($file->refe_type === &#x27;video&#x27;) {&#xA;                    $duration = getVideoDuration($file->refe_file_path);&#xA;&#xA;                    if ($duration > config(&#x27;constant.sharing_configs.max_video_duration.twitter&#x27;)) {&#xA;                        throw new \Exception(&#x27;The duration of the video file must not exceed 140 seconds.&#x27;);&#xA;                    }&#xA;                }&#xA;&#xA;                $isFileTypeSupported = checkPublishedFileType(&#x27;twitter&#x27;, $file->refe_type, strtolower($ext));&#xA;                $isFileSizeSupported = checkPublishedFileSize(&#x27;twitter&#x27;, $file->refe_type, $fileSize, strtolower($ext));&#xA;&#xA;                if (!$isFileTypeSupported) {&#xA;                    throw new \Exception(&#x27;Your content can\&#x27;t successfully published on Twitter. This file type is not supported for publishing.&#x27;);&#xA;                }&#xA;&#xA;                if (!$isFileSizeSupported) {&#xA;                    throw new \Exception(&#x27;Your content can\&#x27;t successfully published on Twitter. The file size is exceeded.&#x27;);&#xA;                }&#xA;&#xA;                if ($file->refe_type === &#x27;video&#x27;) $fileSize = filesize($convertedFile);&#xA;&#xA;                if (strtolower($ext) === &#x27;gif&#x27;) {&#xA;                    $initMedia = $twitter->uploadMedia([&#xA;                        &#x27;command&#x27; => &#x27;INIT&#x27;,&#xA;                        &#x27;total_bytes&#x27; => (int)$fileSize&#xA;                    ]);&#xA;                } else {&#xA;                    $initMedia = $twitter->uploadMedia([&#xA;                        &#x27;command&#x27; => &#x27;INIT&#x27;,&#xA;                        &#x27;media_type&#x27; => $mediaType,&#xA;                        &#x27;media_category&#x27; => $mediaCategory,&#xA;                        &#x27;total_bytes&#x27; => (int)$fileSize&#xA;                    ]);&#xA;                }&#xA;&#xA;                $mediaId = (int)$initMedia->media_id_string;&#xA;&#xA;                $fp = fopen($convertedFile, &#x27;r&#x27;);&#xA;                $segmentId = 0;&#xA;&#xA;                while (!feof($fp)) {&#xA;                    $chunk = fread($fp, 1048576);&#xA;&#xA;                    $twitter->uploadMedia([&#xA;                        &#x27;media_data&#x27; => base64_encode($chunk),&#xA;                        &#x27;command&#x27; => &#x27;APPEND&#x27;,&#xA;                        &#x27;segment_index&#x27; => $segmentId,&#xA;                        &#x27;media_id&#x27; => $mediaId&#xA;                    ]);&#xA;&#xA;                    $segmentId&#x2B;&#x2B;;&#xA;                }&#xA;&#xA;                fclose($fp);&#xA;&#xA;                $twitter->uploadMedia([&#xA;                    &#x27;command&#x27; => &#x27;FINALIZE&#x27;,&#xA;                    &#x27;media_id&#x27; => $mediaId&#xA;                ]);&#xA;&#xA;                if ($file->refe_type === &#x27;video&#x27;) {&#xA;                    $waits = 0;&#xA;&#xA;                    while ($waits &lt;= 4) {&#xA;                        // Authorizing header for Twitter API&#xA;                        $oauth = [&#xA;                            &#x27;command&#x27; => &#x27;STATUS&#x27;,&#xA;                            &#x27;media_id&#x27; => $mediaId,&#xA;                            &#x27;oauth_consumer_key&#x27; => config(&#x27;twitter.consumer_key&#x27;),&#xA;                            &#x27;oauth_nonce&#x27; => Str::random(42),&#xA;                            &#x27;oauth_signature_method&#x27; => &#x27;HMAC-SHA1&#x27;,&#xA;                            &#x27;oauth_timestamp&#x27; => time(),&#xA;                            &#x27;oauth_token&#x27; => $requestToken[&#x27;token&#x27;],&#xA;                            &#x27;oauth_version&#x27; => &#x27;1.0&#x27;&#xA;                        ];&#xA;&#xA;                        // Generate an OAuth 1.0a HMAC-SHA1 signature for an HTTP request&#xA;                        $baseInfo = $this->buildBaseString(&#x27;https://upload.twitter.com/1.1/media/upload.json&#x27;, &#x27;GET&#x27;, $oauth);&#xA;                        // Getting a signing key&#xA;                        $compositeKey = rawurlencode(config(&#x27;twitter.consumer_secret&#x27;)) . &#x27;&amp;&#x27; . rawurlencode($requestToken[&#x27;secret&#x27;]);&#xA;                        // Calculating the signature&#xA;                        $oauthSignature = base64_encode(hash_hmac(&#x27;sha1&#x27;, $baseInfo, $compositeKey, true));&#xA;                        $oauth[&#x27;oauth_signature&#x27;] = $oauthSignature;&#xA;                        $headers[&#x27;Authorization&#x27;] = $this->buildAuthorizationHeader($oauth);&#xA;&#xA;                        try {&#xA;                            $guzzle = new GuzzleClient([&#xA;                                &#x27;headers&#x27; => $headers&#xA;                            ]);&#xA;                            $response = $guzzle->request( &#x27;GET&#x27;, &#x27;https://upload.twitter.com/1.1/media/upload.json?command=STATUS&amp;media_id=&#x27; . $mediaId);&#xA;                            $uploadStatus = json_decode($response->getBody()->getContents());&#xA;                        } catch (\Exception | GuzzleException $e) {&#xA;                            dd($e->getMessage(), $e->getLine(), $e->getFile());&#xA;                        }&#xA;&#xA;                        if (isset($uploadStatus->processing_info->state)) {&#xA;                            switch ($uploadStatus->processing_info->state) {&#xA;                                case &#x27;succeeded&#x27;:&#xA;                                    $waits = 5; // break out of the while loop&#xA;                                    break;&#xA;                                case &#x27;failed&#x27;:&#xA;                                    File::delete($tempFile);&#xA;                                    Log::error(&#x27;File processing failed: &#x27; . $uploadStatus->processing_info->error->message);&#xA;                                    throw new \Exception(&#x27;File processing failed: &#x27; . $uploadStatus->processing_info->error->message);&#xA;                                default:&#xA;                                    sleep($uploadStatus->processing_info->check_after_secs);&#xA;                                    $waits&#x2B;&#x2B;;&#xA;                            }&#xA;                        } else {&#xA;                            throw new \Exception(&#x27;There was an unknown error uploading your file&#x27;);&#xA;                        }&#xA;                    }&#xA;                }&#xA;&#xA;                $twitter->postTweet([&#x27;status&#x27; => urldecode($postContent), &#x27;media_ids&#x27; => $initMedia->media_id_string]);&#xA;                @File::delete($convertedFile);&#xA;                $result[&#x27;link&#x27;] = &#x27;https://twitter.com/home&#x27;;&#xA;                $result[&#x27;status&#x27;] = true;&#xA;                $result[&#x27;message&#x27;] = &#x27;Your content successfully published on Twitter. You can visit to Twitter and check it.&#x27;;&#xA;                $result[&#x27;publishing_status&#x27;] = &#x27;done&#x27;;&#xA;            }&#xA;        } catch (\Exception $e) {&#xA;            dd($e->getMessage());&#xA;            $result[&#x27;message&#x27;] = $e->getMessage();&#xA;            return $result;&#xA;        }&#xA;&#xA;        return $result;&#xA;    }&#xA;&#xA;    /**&#xA;     * @param $baseURI&#xA;     * @param $method&#xA;     * @param $params&#xA;     * @return string&#xA;     *&#xA;     * Creating the signature base string&#xA;     */&#xA;    protected function buildBaseString($baseURI, $method, $params): string&#xA;    {&#xA;        $r = array();&#xA;        ksort($params);&#xA;        foreach($params as $key=>$value){&#xA;            $r[] = "$key=" . rawurlencode($value);&#xA;        }&#xA;        return $method . "&amp;" . rawurlencode($baseURI) . &#x27;&amp;&#x27; . rawurlencode(implode(&#x27;&amp;&#x27;, $r));&#xA;    }&#xA;&#xA;    /**&#xA;     * @param $oauth&#xA;     * @return string&#xA;     *&#xA;     * Collecting parameters&#xA;     */&#xA;    protected function buildAuthorizationHeader($oauth): string&#xA;    {&#xA;        $r = &#x27;OAuth &#x27;;&#xA;        $values = array();&#xA;        foreach($oauth as $key=>$value)&#xA;            $values[] = "$key=\"" . rawurlencode($value) . "\"";&#xA;        $r .= implode(&#x27;, &#x27;, $values);&#xA;        return $r;&#xA;    }&#xA;}&#xA;&#xA;

    &#xA;

    I would be very grateful if someone would help me.

    &#xA;

  • How can several .ts files be converted to one (non-fragmented) .mp4 file using ffmpeg ?

    23 juin 2021, par verified_tinker

    Problem Description

    &#xA;

    The video player I'm using doesn't support .ts files, but it does play .mp4 files, so I'd like to use ffmpeg to convert my .ts files to .mp4 files.

    &#xA;

    Goal Solution

    &#xA;

    Use ffmpeg to download several .ts segments and transcode them into an .mp4 file that I'd load into my video player. Rinse and repeat. It'd add a delay of 10-20 seconds, but that's fine.

    &#xA;

    The trick is to do the transcoding fast enough so, by the time one .mp4 file is finished playing, the next one is available ; in other words, the transcoding should take less than a second per second of footage. Ideally, it would take significantly less than that, to account for varying processing power on different devices.

    &#xA;

    To clarify, when I say .mp4, I don't mean fragmented .mp4 files.

    &#xA;


    &#xA;

    If transcoding to some other format is faster, that might be fine, too. For example, I know the .mkv format is playable. I'm still exploring the full range of available formats.

    &#xA;

    What I've Tried

    &#xA;

    I tested transcoding 1 .ts file into an .mp4 file, and unfortunately it took about 6 seconds when the file was about 4 seconds long. That was with ffmpeg-wasm. I was hoping the JavaScript bridge might be slowing it down and that batching several .ts segments in 1 call might help.

    &#xA;

    Command

    &#xA;

    ffmpeg -i test.ts test.mp4&#xA;

    &#xA;

    Log

    &#xA;

    [info] run FS.writeFile test.ts &lt;349304 bytes binary file>&#xA;log.js:15 [info] run ffmpeg command: -i test.ts test.mp4&#xA;log.js:15 [fferr] ffmpeg version v0.9.0-2-gb11e5c1495 Copyright (c) 2000-2020 the FFmpeg developers&#xA;log.js:15 [fferr]   built with emcc (Emscripten gcc/clang-like replacement) 2.0.8 (d059fd603d0b45b584f634dc2365bc9e9a6ec1dd)&#xA;log.js:15 [fferr]   configuration: --target-os=none --arch=x86_32 --enable-cross-compile --disable-x86asm --disable-inline-asm --disable-stripping --disable-programs --disable-doc --disable-debug --disable-runtime-cpudetect --disable-autodetect --extra-cflags=&#x27;-s USE_PTHREADS=1 -I/src/build/include -O3 --closure 1&#x27; --extra-cxxflags=&#x27;-s USE_PTHREADS=1 -I/src/build/include -O3 --closure 1&#x27; --extra-ldflags=&#x27;-s USE_PTHREADS=1 -I/src/build/include -O3 --closure 1 -L/src/build/lib&#x27; --pkg-config-flags=--static --nm=llvm-nm --ar=emar --ranlib=emranlib --cc=emcc --cxx=em&#x2B;&#x2B; --objcc=emcc --dep-cc=emcc --enable-gpl --enable-nonfree --enable-zlib --enable-libx264 --enable-libx265 --enable-libvpx --enable-libwavpack --enable-libmp3lame --enable-libfdk-aac --enable-libtheora --enable-libvorbis --enable-libfreetype --enable-libopus --enable-libwebp --enable-libass --enable-libfribidi&#xA;log.js:15 [fferr]   libavutil      56. 51.100 / 56. 51.100&#xA;log.js:15 [fferr]   libavcodec     58. 91.100 / 58. 91.100&#xA;log.js:15 [fferr]   libavformat    58. 45.100 / 58. 45.100&#xA;log.js:15 [fferr]   libavdevice    58. 10.100 / 58. 10.100&#xA;log.js:15 [fferr]   libavfilter     7. 85.100 /  7. 85.100&#xA;log.js:15 [fferr]   libswscale      5.  7.100 /  5.  7.100&#xA;log.js:15 [fferr]   libswresample   3.  7.100 /  3.  7.100&#xA;log.js:15 [fferr]   libpostproc    55.  7.100 / 55.  7.100&#xA;log.js:15 [fferr] Input #0, mpegts, from &#x27;test.ts&#x27;:&#xA;log.js:15 [fferr]   Duration: 00:00:04.00, start: 10.006000, bitrate: 698 kb/s&#xA;log.js:15 [fferr]   Program 1 &#xA;log.js:15 [fferr]     Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 23.98 tbr, 90k tbn, 1411200000.00 tbc&#xA;log.js:15 [fferr]     Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 130 kb/s&#xA;log.js:15 [fferr] Stream mapping:&#xA;log.js:15 [fferr]   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))&#xA;log.js:15 [fferr]   Stream #0:1 -> #0:1 (aac (native) -> aac (native))&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] using cpu capabilities: none!&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] profile High, level 3.1, 4:2:0, 8-bit&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;log.js:15 [fferr] Output #0, mp4, to &#x27;test.mp4&#x27;:&#xA;log.js:15 [fferr]   Metadata:&#xA;log.js:15 [fferr]     encoder         : Lavf58.45.100&#xA;log.js:15 [fferr]     Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720, q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc&#xA;log.js:15 [fferr]     Metadata:&#xA;log.js:15 [fferr]       encoder         : Lavc58.91.100 libx264&#xA;log.js:15 [fferr]     Side data:&#xA;log.js:15 [fferr]       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;log.js:15 [fferr]     Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s&#xA;log.js:15 [fferr]     Metadata:&#xA;log.js:15 [fferr]       encoder         : Lavc58.91.100 aac&#xA;log.js:15 [fferr] frame=    3 fps=0.0 q=0.0 size=       0kB time=00:00:00.38 bitrate=   1.0kbits/s dup=1 drop=0 speed=0.521x    &#xA;log.js:15 [fferr] frame=   47 fps= 27 q=0.0 size=       0kB time=00:00:02.09 bitrate=   0.2kbits/s dup=1 drop=0 speed=1.22x    &#xA;log.js:15 [fferr] frame=   57 fps= 25 q=28.0 size=       0kB time=00:00:02.51 bitrate=   0.2kbits/s dup=1 drop=0 speed=1.13x    &#xA;log.js:15 [fferr] frame=   67 fps= 24 q=28.0 size=       0kB time=00:00:02.96 bitrate=   0.1kbits/s dup=1 drop=0 speed=1.08x    &#xA;log.js:15 [fferr] frame=   77 fps= 23 q=28.0 size=       0kB time=00:00:03.37 bitrate=   0.1kbits/s dup=1 drop=0 speed=1.03x    &#xA;log.js:15 [fferr] frame=   89 fps= 23 q=28.0 size=       0kB time=00:00:03.96 bitrate=   0.1kbits/s dup=1 drop=0 speed=1.04x    &#xA;log.js:15 [fferr] frame=   96 fps= 15 q=-1.0 Lsize=      60kB time=00:00:04.01 bitrate= 122.8kbits/s dup=1 drop=0 speed=0.646x    &#xA;log.js:15 [fferr] video:55kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.249582%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] frame I:1     Avg QP:17.20  size: 31521&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] frame P:24    Avg QP:16.17  size:   735&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] frame B:71    Avg QP:27.68  size:    91&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] consecutive B-frames:  1.0%  0.0%  3.1% 95.8%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] mb I  I16..4: 26.2% 56.4% 17.4%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] mb P  I16..4:  0.1%  0.2%  0.0%  P16..4:  3.5%  0.4%  0.2%  0.0%  0.0%    skip:95.4%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.6%  0.0%  0.0%  direct: 0.0%  skip:98.3%  L0:31.0% L1:69.0% BI: 0.0%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] 8x8 transform intra:56.5% inter:59.4%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] coded y,uvDC,uvAC intra: 17.4% 15.4% 7.5% inter: 0.2% 0.4% 0.0%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] i16 v,h,dc,p: 29% 63%  1%  7%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 51% 31% 14%  0%  2%  1%  1%  0%  1%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 45% 11%  2%  3%  2%  4%  2%  4%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] i8c dc,h,v,p: 76% 17%  6%  1%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] Weighted P-Frames: Y:0.0% UV:0.0%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] ref P L0: 89.5%  1.6%  6.7%  2.3%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] ref B L0: 38.5% 60.9%  0.6%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] ref B L1: 97.7%  2.3%&#xA;log.js:15 [fferr] [libx264 @ 0x1f5f080] kb/s:111.08&#xA;log.js:15 [fferr] [aac @ 0x1f48100] Qavg: 65536.000&#xA;log.js:15 [ffout] FFMPEG_END&#xA;log.js:15 [info] run FS.readFile test.mp4&#xA;(index):38 Time elapsed: 6345 (This one&#x27;s my own code.)&#xA;[info] run FS.readFile test.mp4&#xA;

    &#xA;

    (I'm running this on the browser. For the purposes of this question, consider the HTML player unavailable for use.)

    &#xA;


    &#xA;

    I also tested feeding the HLS live-stream URL as input to ffmpeg and outputting a single .mp4 file, but I couldn't play it until I ended the live-stream and ffmpeg finished downloading it.

    &#xA;

    This one I ran on the (Windows) PC ; not the browser.

    &#xA;

    Command

    &#xA;

    ffmpeg -i https://stream.mux.com/lngMYGqNpHhYg2ZXqpH8WODVGzuenaZuhckdyunGpzU.m3u8 -acodec copy -bsf:a aac_adtstoasc -vcodec copy out.mp4&#xA;

    &#xA;

    Log

    &#xA;

    The log is too large and StackOverflow won't let me paste it here, so I uploaded it to PasteBin : https://pastebin.com/FqvPQ1DZ

    &#xA;