
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (72)
-
Le profil des utilisateurs
12 avril 2011, parChaque 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, parAccé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 2011MediaSPIP 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 JunanioI 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('video')){
 $file = $request->file('video');
 $filename = $file->getClientOriginalName();
 $path = public_path('translate/test/');
 }else{
 return 'No file uploaded';
 }
 
 
 if ($file->move($path, $filename)) {
 $video = 'translate/test/'.$filename;
 }else{
 return 'error file upload';
 }

 
 // $output = 'translate/output/image/'.time().'.png';
 $output = 'translate/output/image/'.time().'.bmp';
 // $output = 'translate/output/image/'.time().'.jpg';

 $cmd = 'ffmpeg -i '.$video.' -vframes 1 '.$output;
 shell_exec($cmd);


// $dimg = imagecreatefrompng($output);
 $dimg = imageCreateFromBmp($output);
 // $dimg = imagecreatefromjpeg($output);

 $extracted_color = array();

 for ($x=0; $x < 24 ; $x++) { 
 $extracted_color[]= imagecolorat($dimg, $x, 0);
 }

 echo "<br />Retrived colors:<pre>".print_r($extracted_color,1)."</pre>";

 imagedestroy($dimg);






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


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.


Can someone let me know if I miss anything here.


-
How does ffmpeg divide into frames EXACTLY
6 décembre 2022, par JFCorleoneI'm using this piece of code in python to split a video into frames.


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



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


ffmpeg(video_file, fps, 0, start=XXX,end=YYY)



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 ?


-
Is it possible to merge multiple FFMPEG commands (cuts, slow down, watermark) into one in order to increase performance ?
14 novembre 2022, par Nectarie PFI 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 :


- 

- crop the video to 1080 width/height




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



- 

- first second should run normally




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



- 

- the next two seconds will run at slow motion with a 2x factor




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>&1");



- 

- the next second will speed up at 4x factor




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>&1");



- 

- the next 2 seconds again slow motion




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>&1");



- 

- final second again normal speed




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



- 

- concatenate the above parts to achieve the modified clip




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



- 

- then append the resulting clip in reverse




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>&1");



- 

- add watermark




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>&1");



- 

- add audio (we can discard the original audio in any of the above steps)




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>&1");



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


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.


Thanks !


I was expecting this to run a little bit faster, ideally half the time it takes right now.
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.