Recherche avancée

Médias (0)

Mot : - Tags -/navigation

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

Autres articles (64)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 avril 2011, par

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (5727)

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

    


  • FFMpeg C++ encoder fails with hardware acceleration quick sync intel

    28 août 2022, par teals

    I am trying to debug an issue I have with a simple C++ encoder using FFMmpeg. The following code below works correctly on these other hardware acceleration systems/platforms :

    


      

    • Mac/VideoToolbox,
    • 


    • Cuda/NVEnc
    • 


    • Raspberry pi/h264_v4l2m2m.
    • 


    


    It fails on intel quick sync at avcodec_open2. I'm using Ubuntu 22.04. I built FFMpeg from source with the Intel Media SDK installed and configured. I verified that the QuickSync install works. I also have a corresponding decoder implementation that works correctly using intel quick sync. So I know everything properly installed. I am also running this on an 11th Gen Intel CPU.

    


    [hevc_qsv @ 0x564b0d34f0c0] Low power mode is unsupported (This sometimes shows up)
[hevc_qsv @ 0x563691234000] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height


    


    This is the only error that I get and I haven't found any helpful resources. I tried playing around with different parameters but nothing seems to work. Any help or insight would be extremely helpful.

    


    bool VideoEncoder::create() {&#xA;    char const* outfile = filePath.c_str();&#xA;&#xA;     // open output format context&#xA;    int ret = avformat_alloc_output_context2(&amp;ofctx, nullptr, nullptr, outfile);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avformat_alloc_output_context2(" &lt;&lt; outfile &lt;&lt; "): ret=" &lt;&lt; ret;&#xA;        return false;&#xA;    }&#xA;&#xA;    // create new video stream&#xA;    const AVCodec* codec = avcodec_find_encoder_by_name(encoderName.c_str());&#xA;    vstrm = avformat_new_stream(ofctx, codec);&#xA;    if (!vstrm) {&#xA;        std::cerr &lt;&lt; "fail to avformat_new_stream";&#xA;        return false;&#xA;    }&#xA;&#xA;    // open video encoder&#xA;    cctx = avcodec_alloc_context3(codec);&#xA;    if (!vstrm) {&#xA;        std::cerr &lt;&lt; "fail to avcodec_alloc_context3";&#xA;        return false;&#xA;    }&#xA;    const AVRational dst_fps = {fps, 1};&#xA;    cctx->width = width;&#xA;    cctx->height = height;&#xA;    if(pixel_format != AV_PIX_FMT_NONE) {&#xA;        cctx->pix_fmt = pixel_format;&#xA;    }&#xA;    else {&#xA;        cctx->pix_fmt = codec->pix_fmts[0];&#xA;    }&#xA;    cctx->time_base = av_inv_q(dst_fps);&#xA;    cctx->framerate = dst_fps;&#xA;    cctx->bit_rate = bitrate * 1000000;&#xA;&#xA;&#xA;    AVDictionary* options = nullptr;&#xA;    if(gpu_id >= 0) {&#xA;        av_dict_set_int(&amp;options, "gpu", gpu_id, 0);&#xA;    }&#xA;&#xA;    &#xA;    if (ofctx->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        cctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    ret = avcodec_open2(cctx, codec, &amp;options);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avcodec_open2: ret=" &lt;&lt; ret;&#xA;        return false;&#xA;    }&#xA;    avcodec_parameters_from_context(vstrm->codecpar, cctx);&#xA;&#xA;    //For mac/quicktime we need to add hvc1 tag.&#xA;    if (encoderName.find("hevc") != std::string::npos) {&#xA;        vstrm->codecpar->codec_tag = MKTAG(&#x27;h&#x27;, &#x27;v&#x27;, &#x27;c&#x27;, &#x27;1&#x27;);&#xA;    }&#xA;&#xA;    /*&#xA;    std::cout&#xA;        &lt;&lt; "outfile: " &lt;&lt; outfile &lt;&lt; "\n"&#xA;        &lt;&lt; "format:  " &lt;&lt; ofctx->oformat->name &lt;&lt; "\n"&#xA;        &lt;&lt; "vcodec:  " &lt;&lt; codec->name &lt;&lt; "\n"&#xA;        &lt;&lt; "size:    " &lt;&lt; width &lt;&lt; &#x27;x&#x27; &lt;&lt; height &lt;&lt; "\n"&#xA;        &lt;&lt; "fps:     " &lt;&lt; av_q2d(cctx->framerate) &lt;&lt; "\n"&#xA;        &lt;&lt; "pixfmt:  " &lt;&lt; av_get_pix_fmt_name(cctx->pix_fmt) &lt;&lt; "\n"&#xA;        &lt;&lt; std::flush;*/&#xA;&#xA;    // initialize sample scaler&#xA;    swsCtx = sws_getContext(&#xA;        width, height, AV_PIX_FMT_BGR24,&#xA;        width, height, cctx->pix_fmt,&#xA;        SWS_BILINEAR, nullptr, nullptr, nullptr);&#xA;    if (!swsCtx) {&#xA;        std::cerr &lt;&lt; "fail to sws_getContext";&#xA;        return false;&#xA;    }&#xA;&#xA;    // allocate frame buffer for encoding&#xA;    frame = av_frame_alloc();&#xA;    frame->width = width;&#xA;    frame->height = height;&#xA;    frame->format = static_cast<int>(cctx->pix_fmt);&#xA;    ret = av_frame_get_buffer(frame, 32);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to av_frame_get_buffer: ret=" &lt;&lt; ret;&#xA;        return false;&#xA;    }&#xA;&#xA;    // allocate packet to retrive encoded frame&#xA;    pkt = av_packet_alloc();&#xA;    // open output IO context&#xA;    ret = avio_open2(&amp;ofctx->pb, outfile, AVIO_FLAG_WRITE, nullptr, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avio_open2: ret=" &lt;&lt; ret;&#xA;        return false;&#xA;    }&#xA;&#xA;    // write media container header (if any)&#xA;    ret = avformat_write_header(ofctx, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "fail to avformat_write_header: ret=" &lt;&lt; ret;&#xA;        return false;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;</int>

    &#xA;

  • Trolls in trouble

    6 juin 2013, par Mans — Law and liberty

    Life as a patent troll is hopefully set to get more difficult. In a memo describing patent trolls as a “drain on the American economy,” the White House this week outlined a number of steps it is taking to stem this evil tide. Chiming in, the Chief Judge of the Court of Appeals for the Federal Circuit (where patent cases are heard) in a New York Times op-ed laments the toll patent trolling is taking on the industry, and urges judges to use powers already at their disposal to make the practice less attractive. However, while certainly a step in the right direction, these measures all fail to address the more fundamental properties of the patent system allowing trolls to exist in the first place.

    System and method for patent trolling

    Most patent trolling operations comprise the same basic elements :

    1. One or more patents with broad claims.
    2. The patents of (1) acquired by an otherwise non-practising entity (troll).
    3. The entity of (2) filing numerous lawsuits alleging infringement of the patents of (1).
    4. The lawsuits of (3) targeting end users or retailers.
    5. The lawsuits of (3) listing as plaintiffs difficult to trace shell companies.

    The recent legislative actions all take aim at the latter entries in this list. In so doing, they will no doubt cripple the trolls, but the trolls will remain alive, ready to resume their wicked ways once a new loophole is found in the system.

    To kill a patent troll

    As Judge Rader and his co-authors point out in the New York Times, “the problem stems largely from the fact that, [...] trolls have an important strategic advantage over their adversaries : they don’t make anything.” This is the heart of the troll, and this is where the blow should be struck. Our weapon shall be the mightiest judicial sword of all, the Constitution.

    The United States Constitution contains (in Article I, Section 8) the foundation for the patent system (emphasis mine) :

    The Congress shall have Power [...] To promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries.

    Patent trolls are typically not inventors. They are merely hoarders of other people’s discarded inventions, and that allowing others to reap the benefits of an inventor’s work would somehow promote progress should be a tough argument. Indeed, it is the dissociation between investment and reward which has allowed the patent trolls to rise and prosper.

    In light of the above, the solution to the troll menace is actually strikingly simple : make patents non-transferable.

    Having the inventor retain the rights to his or her inventions (works for hire still being recognised), would render the establishment of non-practising entities, which most trolls are, virtually impossible. The original purpose of patents, to protect the investment of inventors, would remain unaffected, if not strengthened, by such a change.

    Links