Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (72)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (7549)

  • Reading colors encoded in image at a position changes its value after decoded from video using php and ffmpeg

    29 novembre 2022, par Jeenus Junanio

    I created a piece of code to encode unique color on image and converted the image to PNG so that it would be lossless. After This I created a video with the frame using this image using the ffmpeg in php shellexec(). After saving this video I reopened it to extract the frmae image added and tried to read those values from the image. Now the values on the image are a bit changed.

    


    Here is the code that I tried to create the video :

    


    $canvas = imagecreatefromjpeg('translate/first_frame.jpg');
        // create a random color
        $rand = str_pad(dechex(rand(0x000000, 0xFFFFFF)), 6, 0, STR_PAD_LEFT);
        $dec_color= hexdec($rand);

        // add the new color to image

        for ($i=0; $i < 24; $i++) { 
           imagesetpixel($canvas,$i,0,$dec_color);
        }

        // store the image and close the file opened

        // $filename = 'translate/test/output.png'; 
        $filename = 'translate/test/output.bmp'; 

        // imagepng($canvas, $filename);
        imagebmp($canvas, $filename);

        imagedestroy($canvas);

        $frame      = $filename; // an image(png,gif,etc)
        $audio      = 'translate/output/audio/abcdefghijklmnopqrstuvwxya.mp3';
        $output     = 'translate/output/video/'.time().'.mp4';   

        $cmd = 'ffmpeg -loop 1 -y -i '.$frame.' -i '.$audio.' -c:v libx264 -tune stillimage -c:a copy -shortest '.$output;
        shell_exec($cmd);


    


    This above code is creating the video with the image.

    


    Now I tried to extract the image video and color from image, the colors are a bit changed.

    


    if($request->hasFile(&#x27;video&#x27;)){&#xA;            $file = $request->file(&#x27;video&#x27;);&#xA;            $filename = $file->getClientOriginalName();&#xA;            $path = public_path(&#x27;translate/test/&#x27;);&#xA;        }else{&#xA;            return &#x27;No file uploaded&#x27;;&#xA;        }&#xA;        &#xA;        &#xA;        if ($file->move($path, $filename)) {&#xA;            $video = &#x27;translate/test/&#x27;.$filename;&#xA;        }else{&#xA;            return &#x27;error file upload&#x27;;&#xA;        }&#xA;&#xA;       &#xA;        // $output = &#x27;translate/output/image/&#x27;.time().&#x27;.png&#x27;;&#xA;        $output = &#x27;translate/output/image/&#x27;.time().&#x27;.bmp&#x27;;&#xA;        // $output = &#x27;translate/output/image/&#x27;.time().&#x27;.jpg&#x27;;&#xA;&#xA;        $cmd = &#x27;ffmpeg -i &#x27;.$video.&#x27; -vframes 1 &#x27;.$output;&#xA;        shell_exec($cmd);&#xA;&#xA;&#xA;// $dimg = imagecreatefrompng($output);&#xA;        $dimg = imageCreateFromBmp($output);&#xA;        // $dimg = imagecreatefromjpeg($output);&#xA;&#xA;        $extracted_color = array();&#xA;&#xA;        for ($x=0; $x &lt; 24 ; $x&#x2B;&#x2B;) { &#xA;          $extracted_color[]= imagecolorat($dimg, $x, 0);&#xA;        }&#xA;&#xA;        echo "<br />Retrived colors:<pre>".print_r($extracted_color,1)."</pre>";&#xA;&#xA;        imagedestroy($dimg);&#xA;&#xA;&#xA;&#xA;

    &#xA;

    The color added was 44743072 but the colors retrieved are 4539914,4474121,4408072,4408326 from x=0,y=0 to x=24,y=0.

    &#xA;

    In both PNG and BMP I am loosing the added pixels. You can clearly see in my code i have commented the code for png to read the image as bmp.

    &#xA;

    Can someone let me know if I miss anything here.

    &#xA;

  • How does ffmpeg divide into frames EXACTLY

    6 décembre 2022, par JFCorleone

    I'm using this piece of code in python to split a video into frames.

    &#xA;

        def ffmpeg(self, video_file, fps, start_number, **trim_kwargs):&#xA;        ffmpeg.input(video_file) \&#xA;            .filter(&#x27;fps&#x27;, fps=fps) \&#xA;            .trim(**trim_kwargs) \&#xA;            .output(os.path.join(self._output_dir, f"%0{NAME_PADDING}d.JPG"),&#xA;                    **{&#x27;qscale:v&#x27;: 1, &#x27;vsync&#x27;: &#x27;drop&#x27;, &#x27;start_number&#x27;: start_number}) \&#xA;            .run()&#xA;

    &#xA;

    I sometimes use also trimming options more or less like this :

    &#xA;

    ffmpeg(video_file, fps, 0, start=XXX,end=YYY)&#xA;

    &#xA;

    Additionally, I have a list with timestamps (starting from point zero) with some additional metadata at certain points. I'm trying to figure out what are the mechanics of ffmpeg of using fps for dividing into frames (for example fps = 1), because when I try to jump through my timestamped log manually with the same "fps", I often get less entries than ffmpeg by 1. It's like ffmpeg always took first and last frame or something. Can someone explain to me how it's done exactly, so I could match metadata with generate frames in the best manner ?

    &#xA;

  • Is it possible to merge multiple FFMPEG commands (cuts, slow down, watermark) into one in order to increase performance ?

    14 novembre 2022, par Nectarie PF

    I wrote a small piece of software in PHP, using FFMPEG commands via shell exec. The final purpose is to take a 7 seconds MP4 file from a GoPro and transform it in order to achieve a sort of boomerang effect :

    &#xA;

      &#xA;
    • crop the video to 1080 width/height
    • &#xA;

    &#xA;

    ffmpeg -i ./files/video_small/$latestVideo -filter:v \"crop=1080:1080:420:0\" ./files/video_small/outcrop_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • first second should run normally
    • &#xA;

    &#xA;

    ffmpeg.exe -t 1 -i ./files/video_small/outcrop_$cod.mp4 ./files/video_small/out1_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • the next two seconds will run at slow motion with a 2x factor
    • &#xA;

    &#xA;

    ffmpeg.exe -ss 00:00:01 -t 2 -i ./files/video_small/outcrop_$cod.mp4 -filter_complex \"[0:v]setpts=2*PTS[v]\" -map \"[v]\" ./files/video_small/out2_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • the next second will speed up at 4x factor
    • &#xA;

    &#xA;

    ffmpeg.exe -ss 00:00:03 -t 1 -i ./files/video_small/outcrop_$cod.mp4 -filter_complex \"[0:v]setpts=0.25*PTS[v]\" -map \"[v]\" ./files/video_small/out3_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • the next 2 seconds again slow motion
    • &#xA;

    &#xA;

    ffmpeg.exe -ss 00:00:04 -t 2 -i ./files/video_small/outcrop_$cod.mp4 -filter_complex \"[0:v]setpts=2*PTS[v]\" -map \"[v]\" ./files/video_small/out4_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • final second again normal speed
    • &#xA;

    &#xA;

    ffmpeg.exe -ss 00:00:06 -i ./files/video_small/outcrop_$cod.mp4 ./files/video_small/out5_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • concatenate the above parts to achieve the modified clip
    • &#xA;

    &#xA;

    ffmpeg.exe -f concat -i ./files/video_small/files_$cod.txt -c copy  ./files/video_small/output1_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • then append the resulting clip in reverse
    • &#xA;

    &#xA;

    ffmpeg -i ./files/video_small/output1_$cod.mp4 -filter_complex \"[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]\" -map \"[v]\" ./files/video_small/output2_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • add watermark
    • &#xA;

    &#xA;

    ffmpeg -i ./files/video_small/output2_$cod.mp4 -i ./files/watermark-video1080.png -filter_complex \"[0:v][1:v]overlay=(W-w)/2:10[outv]\" -map [outv] -c:v libx264 -crf 22 -preset veryfast ./files/video_small/output3_$cod.mp4 2>&amp;1");&#xA;

    &#xA;

      &#xA;
    • add audio (we can discard the original audio in any of the above steps)
    • &#xA;

    &#xA;

    ffmpeg -i ./files/video_small/output3_$cod.mp4 -i ./files/video_small/sound-hip-hop.mp3 -map 0 -map 1:a -c:v copy -shortest ./files/video_small/output_final_$latestVideo 2>&amp;1");&#xA;

    &#xA;

    Right now it runs ok, but I have a problem with performance, the whole process lasts about 50 seconds on my 8th gen i7.

    &#xA;

    I am very new to the capabilities of ffmpeg and I was wondering if any of the below commands can be optimized or if any of the steps can be merged into one, as I can see the syntax is quite powerful.

    &#xA;

    Thanks !

    &#xA;

    I was expecting this to run a little bit faster, ideally half the time it takes right now.&#xA;As far as I have observed, the longest part is appending the resulting clip in reverse, perhaps I am adding something too heavy and unnecessary in the reverse filter.

    &#xA;