Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (20)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (5118)

  • 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 :

    


    


    file is currently unsupported

    


    


    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.

    


    <?php

namespace App\Jobs;

use App\Models\PublishedContent;
use Atymic\Twitter\Facades\Twitter;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\File;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Str;


class PublishToTwitter implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * @var
     */
    protected $publishingData;

    /**
     * Create a new job instance.
     *
     * @param $publishingData
     */
    public function __construct($publishingData)
    {
        $this->publishingData = $publishingData;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $publishingData = $this->publishingData;

        if (is_array($publishingData)) {
            $publishingResult = $this->publishing(...array_values($publishingData));
            sendNotification($publishingResult['message'], $publishingResult['status'], 'Twitter', $publishingResult['link'], $publishingData['post_name'], $publishingData['user']);
        } else {
            $scheduledData = processingScheduledPost($publishingData);
            $postName = $scheduledData['scheduleData']['post_name'];
            $postContent = $scheduledData['scheduleData']['post_content'];
            $userToken = json_decode($publishingData->user_token,true);
            $requestToken = [
                'token'  => $userToken['oauth_token'],
                'secret' => $userToken['oauth_token_secret'],
            ];
            $publishingResult = $this->publishing($scheduledData['file'], $postName, $postContent, $requestToken);
            $publishingResult['status'] && PublishedContent::add($scheduledData['craft'], $scheduledData['file'], "twitter_share");
            sendResultToUser($publishingData, $scheduledData['user'], $publishingResult['message'], $postName, $publishingResult['link'], $publishingResult['publishing_status'], $scheduledData['social_media']);
            sendNotification($publishingResult['message'], $publishingResult['status'], 'Twitter', $publishingResult['link'], $postName, $scheduledData['user']);
        }
    }

    /**
     * @param $file
     * @param $postName
     * @param $postContent
     * @param $requestToken
     * @return array
     */
    private function publishing($file, $postName, $postContent, $requestToken): array
    {
        $result = [
            'status' => false,
            'link' => null,
            'message' => 'Your content can\'t successfully published on Twitter. This file is not supported for publishing.',
            'publishing_status' => 'error'
        ];

        if ((($file->refe_type !== 'text') || $file->refe_file_path) && !checkIfFileExist($file->refe_file_path)) {
            $result['message'] = 'Missing or invalid file.';
            return $result;
        }

        $filePath = $file->refe_file_path;
        $fileSize = $file->content_length;
        $tempFileName = 'temp-' . $file->refe_file_name;
        $ext = $file->file_type;
        $mediaCategory = 'tweet_' . $file->refe_type;
        $mediaType = $file->refe_type . '/' . $ext;
        $remoteFile = file_get_contents($filePath);
        $tempFolder = public_path('/storage/uploads/temp');

        if (!file_exists($tempFolder)) {
            mkdir($tempFolder, 0777, true);
        }

        $tempFile = public_path('/storage/uploads/temp/' . $tempFileName);
        File::put($tempFile, $remoteFile);
        $convertedFileName = 'converted-' . $file->refe_file_name;
        $convertedFile = public_path('/storage/uploads/temp/' . $convertedFileName);
        $command = 'ffmpeg -y -i '.$tempFile.' -b:v 5000k -b:a 380k -c:a aac -profile:a aac_low -threads 1 '.$convertedFile.'';
        exec($command);
        @File::delete($tempFile);

        try {
            $twitter = Twitter::usingCredentials($requestToken['token'], $requestToken['secret']);
            if ($file->refe_type === 'text') {
                $twitter->postTweet([
                    'status' => urldecode($postContent),
                    'format' => 'json',
                ]);

                $result['link'] = 'https://twitter.com/home';
                $result['status'] = true;
                $result['message'] = 'Your content successfully published on Twitter. You can visit to Twitter and check it.';
                $result['publishing_status'] = 'done';
            } else if ($file->refe_type === 'video' || $file->refe_type === 'image') {
                if ($file->refe_type === 'video') {
                    $duration = getVideoDuration($file->refe_file_path);

                    if ($duration > config('constant.sharing_configs.max_video_duration.twitter')) {
                        throw new \Exception('The duration of the video file must not exceed 140 seconds.');
                    }
                }

                $isFileTypeSupported = checkPublishedFileType('twitter', $file->refe_type, strtolower($ext));
                $isFileSizeSupported = checkPublishedFileSize('twitter', $file->refe_type, $fileSize, strtolower($ext));

                if (!$isFileTypeSupported) {
                    throw new \Exception('Your content can\'t successfully published on Twitter. This file type is not supported for publishing.');
                }

                if (!$isFileSizeSupported) {
                    throw new \Exception('Your content can\'t successfully published on Twitter. The file size is exceeded.');
                }

                if ($file->refe_type === 'video') $fileSize = filesize($convertedFile);

                if (strtolower($ext) === 'gif') {
                    $initMedia = $twitter->uploadMedia([
                        'command' => 'INIT',
                        'total_bytes' => (int)$fileSize
                    ]);
                } else {
                    $initMedia = $twitter->uploadMedia([
                        'command' => 'INIT',
                        'media_type' => $mediaType,
                        'media_category' => $mediaCategory,
                        'total_bytes' => (int)$fileSize
                    ]);
                }

                $mediaId = (int)$initMedia->media_id_string;

                $fp = fopen($convertedFile, 'r');
                $segmentId = 0;

                while (!feof($fp)) {
                    $chunk = fread($fp, 1048576);

                    $twitter->uploadMedia([
                        'media_data' => base64_encode($chunk),
                        'command' => 'APPEND',
                        'segment_index' => $segmentId,
                        'media_id' => $mediaId
                    ]);

                    $segmentId++;
                }

                fclose($fp);

                $twitter->uploadMedia([
                    'command' => 'FINALIZE',
                    'media_id' => $mediaId
                ]);

                if ($file->refe_type === 'video') {
                    $waits = 0;

                    while ($waits <= 4) {
                        // Authorizing header for Twitter API
                        $oauth = [
                            'command' => 'STATUS',
                            'media_id' => $mediaId,
                            'oauth_consumer_key' => config('twitter.consumer_key'),
                            'oauth_nonce' => Str::random(42),
                            'oauth_signature_method' => 'HMAC-SHA1',
                            'oauth_timestamp' => time(),
                            'oauth_token' => $requestToken['token'],
                            'oauth_version' => '1.0'
                        ];

                        // Generate an OAuth 1.0a HMAC-SHA1 signature for an HTTP request
                        $baseInfo = $this->buildBaseString('https://upload.twitter.com/1.1/media/upload.json', 'GET', $oauth);
                        // Getting a signing key
                        $compositeKey = rawurlencode(config('twitter.consumer_secret')) . '&' . rawurlencode($requestToken['secret']);
                        // Calculating the signature
                        $oauthSignature = base64_encode(hash_hmac('sha1', $baseInfo, $compositeKey, true));
                        $oauth['oauth_signature'] = $oauthSignature;
                        $headers['Authorization'] = $this->buildAuthorizationHeader($oauth);

                        try {
                            $guzzle = new GuzzleClient([
                                'headers' => $headers
                            ]);
                            $response = $guzzle->request( 'GET', 'https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=' . $mediaId);
                            $uploadStatus = json_decode($response->getBody()->getContents());
                        } catch (\Exception | GuzzleException $e) {
                            dd($e->getMessage(), $e->getLine(), $e->getFile());
                        }

                        if (isset($uploadStatus->processing_info->state)) {
                            switch ($uploadStatus->processing_info->state) {
                                case 'succeeded':
                                    $waits = 5; // break out of the while loop
                                    break;
                                case 'failed':
                                    File::delete($tempFile);
                                    Log::error('File processing failed: ' . $uploadStatus->processing_info->error->message);
                                    throw new \Exception('File processing failed: ' . $uploadStatus->processing_info->error->message);
                                default:
                                    sleep($uploadStatus->processing_info->check_after_secs);
                                    $waits++;
                            }
                        } else {
                            throw new \Exception('There was an unknown error uploading your file');
                        }
                    }
                }

                $twitter->postTweet(['status' => urldecode($postContent), 'media_ids' => $initMedia->media_id_string]);
                @File::delete($convertedFile);
                $result['link'] = 'https://twitter.com/home';
                $result['status'] = true;
                $result['message'] = 'Your content successfully published on Twitter. You can visit to Twitter and check it.';
                $result['publishing_status'] = 'done';
            }
        } catch (\Exception $e) {
            dd($e->getMessage());
            $result['message'] = $e->getMessage();
            return $result;
        }

        return $result;
    }

    /**
     * @param $baseURI
     * @param $method
     * @param $params
     * @return string
     *
     * Creating the signature base string
     */
    protected function buildBaseString($baseURI, $method, $params): string
    {
        $r = array();
        ksort($params);
        foreach($params as $key=>$value){
            $r[] = "$key=" . rawurlencode($value);
        }
        return $method . "&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r));
    }

    /**
     * @param $oauth
     * @return string
     *
     * Collecting parameters
     */
    protected function buildAuthorizationHeader($oauth): string
    {
        $r = 'OAuth ';
        $values = array();
        foreach($oauth as $key=>$value)
            $values[] = "$key=\"" . rawurlencode($value) . "\"";
        $r .= implode(', ', $values);
        return $r;
    }
}



    


    I would be very grateful if someone would help me.

    


  • Compile FFmpeg with x264 for MacOS and Windows on Linux

    9 mars 2023, par RobinFrcd

    I successfully managed to compile a minimal standalone FFmpeg binary to create MP4 videos from JPG images encoded with x264. The binary is 100% functional and is 5.2MB.

    


    To do that, I used :

    


    ./configure \
--disable-everything \
--enable-decoder=mjpeg \
--enable-encoder=libx264 \
--enable-protocol=concat,file \
--enable-demuxer=image2 \
--enable-muxer=mp4 \
--enable-filter=scale \
--enable-gpl \
--enable-libx264 \
--extra-ldexeflags="-static" \
--pkg-config="pkg-config --static"


    


    I now would like to build the macOS and windows binaries directly from my Linux machine. I tried this repo and replaced the config args with mine, but the output exe is 30MB+. And I don't find anything about building for MacOS.

    


    Is there a solution to make this minimal build cross-platform compatible ?

    


  • ffmpeg use on iOS

    2 juillet 2015, par Chuck Mc Duran

    I understand that to use FFmpeg in an iOS app, you use the ./configure and make to generate the .a files, that you will add to the project.

    My question is, once the .a files show up in the project navigator and in the Link Binary With Libraries section, how do you actually use them in your classes ?, I see there is no "framework" to use in an #import statement, so I don’t know how to access the classes methods and properties.