
Recherche avancée
Médias (91)
-
Spitfire Parade - Crisis
15 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Wired NextMusic
14 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
-
Sintel MP4 Surround 5.1 Full
13 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (100)
-
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...) -
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)
Sur d’autres sites (9939)
-
How to process video frames faster in nodejs using ffmpeg [closed]
28 juin 2024, par AviatoI am working on a video editing application in which user can upload a video and I want to perform some frame manipulation on top of the video, and thus I want to extract the video frames and draw them over a canvas api in nodejs and edit them accordingly. I used to do video manipulations using
opencv
and there was a functioncv2.VideoCapture(inputFilePath)
which would read video frames one at a time and we can perform our manipulations on the frame. The processing was very fast and I had tried processing big video files and it works really fast.

However, I was trying to replicate the same process in nodejs and thought about using ffmpeg to do that, now instead of loading all the frames first in the memory and loop through them, I wanted a way to load each frame one at a time and be able to process them fast, so after researching a lot on the internet, I came up with this solution :-


const fs = require('fs');
const { spawn } = require('child_process');

const width = 1920;
const height = 1080;
const bytesPerPixel = 3;
const frameSize = width * height * bytesPerPixel;

const spawnProcess = spawn('ffmpeg', [
 '-i', 'test.mp4',
 '-vcodec', 'rawvideo',
 '-pix_fmt', 'rgb24',
 '-f', 'rawvideo',
 '-s', `${width}x${height}`, // size of one frame
 'pipe:1'
]);

let buffer = Buffer.alloc(0);
let frameCount = 0;

spawnProcess.stdout.on('data', (data) => {
 buffer = Buffer.concat([buffer, data]);

 while (buffer.length >= frameSize) {
 const frameBuffer = buffer.slice(0, frameSize);
 buffer = buffer.slice(frameSize);

 const outputPath = `frame-${frameCount++}.png`;
 saveFrameAsPNG(frameBuffer, width, height, outputPath);
 }
});

function saveFrameAsPNG(frameBuffer, width, height, outputPath) {
 const { PNG } = require('pngjs');

 const png = new PNG({
 width: width,
 height: height
 });

 // Copy the frame buffer to the PNG data
 for (let y = 0; y < height; y++) {
 for (let x = 0; x < width; x++) {
 const idx = (y * width + x) * 3;
 const pngIdx = (y * width + x) * 4;

 png.data[pngIdx] = frameBuffer[idx]; // Red
 png.data[pngIdx + 1] = frameBuffer[idx + 1]; // Green
 png.data[pngIdx + 2] = frameBuffer[idx + 2]; // Blue
 png.data[pngIdx + 3] = 255; // Alpha
 }
 }

 png.pack().pipe(fs.createWriteStream(outputPath));
}

spawnProcess.stderr.on('data', (data) => {
 console.error(`stderr: ${data}`);
});

spawnProcess.on('close', (code) => {
 console.log(`child process exited with code ${code}`);
});




I first input the video in the
ffmpeg
running in the child processes andstdout
the buffer data and used a function to determine the value of one frame and extract that one frame and save that in the filesystem.
However, the processing of the frames is extremely slow, it takes about 1 minute to process a 5 second long video with 60fps which is very inefficient as compared to pythonopencv


I am really confused between which approach should I continue with :-


- 

- I could figure out a way to process the video using python opencv and pipe the frames buffer / save them individually in the filesystem and the nodejs would watch for any file save in the directory and keep processing them and deleting them simultaneously
- Or I could keep trying to find a way to make the read frame processing faster in the nodejs






Any help with code would be greatly appreciated :)


-
writeImages and renaming the images using PHP
3 mai 2015, par Kiran Kumar DashI am working on a multimedia project. So, I am having a case where I am producing a sequence of images from a string input using he code below :
<?php
/*** a new Imagick object ***/
$aniGif = new Imagick();
/*** set the image format to gif ***/
$aniGif->setFormat( "gif" );
/*** a new ImagickPixel object for the colors ***/
$color = new ImagickPixel( "white" );
/*** set color to white ***/
$color->setColor( "white" );
$colorarray =array("white", "red", "blue" , "aqua", "fuchsia", "gray", "lime", "maroon", "navy", "orange", "purple", "silver", "teal", "yellow", "green", "maroon", "green", "olive");
/*** the text for the image ***/
$string = "Hello Kiran Kumar";
/*** a new draw object ***/
$draw = new ImagickDraw();
/*** set the draw font to helvetica ***/
$draw->setFont( "./SociaLAnimaL.ttf" );
/*** set the draw font to helvetica ***/
$draw->setFontSize( "100" );
/*** loop over the text ***/
for ( $i = 0; $i <= strlen( $string ); $i++ )
{
/*** grab a character ***/
$part = substr( $string, 0, $i );
/*** a new ImagickPixel object for the colors ***/
$color = new ImagickPixel( "white" );
/*Generate random number for random color*/
$randomNumber = rand(0,16);
/*** create a new gif frame ***/
$aniGif->newImage( 1920, 1200, $colorarray[$randomNumber] );
/*** add the character to the image ***/
$aniGif->annotateImage( $draw, 960, 600, 0, $part );
/*** set the frame delay to 30 ***/
$aniGif->setImageDelay( 30 );
}
/*** write the file ***/
$aniGif->writeImages($directory.'kiran.jpg', $out);
echo 'all done';
?>Now the problem is the writeimages object is generating images as kiran-0.jpg, kiran-1.jpg, kiran-2.jpg and so on. but what I am expecting is kiran001.jpg, kiran002.jpg, kiran003.jpg...and so on so that I can create a video out of it in while maintaining the sequence.Here is the code for video creation :
<?php
$ffmpeg= "/home/kiran/bin/ffmpeg";
echo exec("$ffmpeg -f image2 -framerate 2/1 -pattern_type glob -i \"/var/www/html/fftest/getthumbnail/tmp/animate/est/*.jpg\" -i \"/var/www/html/fftest/getthumbnail/audios/audio1.mp3\" -c:v libx264 -c:a copy -shortest -s 1920x1080 -r 60 -vf \"format=yuv420p\" \"/var/www/html/fftest/getthumbnail/output/animatedaudiocolor21.avi\" 2>&1" , $output, $return);
?>As you can see I am using -pattern type glob to select all the images, but this is getting confused with he naming sequence of kiran-0, kiran-1.
So, what I am expecting here is how can I use writeimage object o name my images as the way mentioned above. so that I can use kiran%03d.jpg in my ffmpeg command instead of *.jpg.
Or if any one can help me providing a code so that I can rename all the images in the expected manner.I tried the below code to rename all images :
<?php
$fileFolder="/fftest/getthumbnail/tmp/animate/test";
$directory = $_SERVER['DOCUMENT_ROOT'].$fileFolder.'/';
$i = 001;
$handler = opendir($directory);
while ($file = readdir($handler)) {
if ($file != "." && $file != "..") {
$newName = 'kiran'.$i ;
rename($directory.$file, $directory.$newName); // here; prepended a $directory
$i++;
}
}
closedir($handler);
?>But the code is unable to rename the images in sequence.
Help please...
-
How to display print statement from a function on GUI in Tkinter
12 février 2021, par amarykya_ishtmellaI am writing a GUI that takes videos and downsamples them.


I have three buttons
1.Input for getting the input directory
2.Output for getting the directory to write the output files
3.Downsample : For downsampling function.


I want to print "Done downsampling" after the downsampling process is over on the GUI display.


I was using a label, but it's not working. Can anyone help me out with this ?




from tkinter import *
from tkinter import ttk
import mttkinter
from tkinter.filedialog import *
import tkinter as tk

froot = Tk() 
froot.title('GHC')
froot.iconbitmap()
froot.geometry('500x500') 


n = ttk.Notebook(froot)
n.pack(pady=10) #pady is giving the space at the bottom
f1 = tk.Frame(n,width=500,height=500,bg = "blue")
f2 = tk.Frame(n,width=500,height=500, bg = "red")
f1.pack(fill="both",expand=1)
f2.pack(fill="both",expand=1)

n.add(f1, text='Downsample')
n.add(f2, text='Analyze')


### button to get input path to folder

#directory = None
def open_file(): 
 file = askdirectory() 
 if file is not None:
 global directory
 directory =file
 print (directory)
btn = Button(f1, text ='Input folder', command = lambda:open_file())
btn.pack(side = TOP, pady = 10) 



### button to get output folder
#directory2 = None
def output_file(): 
 file2 = askdirectory() 
 if file2 is not None:
 global directory2
 directory2 =file2
 print (directory2)
btn2 = Button(f1, text ='Output folder', command = lambda:output_file())
btn2.pack(side=BOTTOM,pady = 10) 


root=str(directory)
outputpath=str(directory2)

btn2 = Button(f1, text ='Downsample', command =lambda:downsamplevideos(root,outputpath))
btn2.pack(pady = 10)
#####

def get_videos (root):

 files = []

 for f in os.listdir(root):

 joined = root + '/' + f

 if os.path.isdir(root + '/' + f):

 files += get_videos(joined)

 else:

 # if f.split('.')[-1] == mp4

 files += [joined]

 return files

def downsamplevideos(root,ouputpath):
 for files in get_videos(root):
 dirpath=files.split('/')[-2]
 filename=files.split('/')[-1]
 outputvideofile= dirpath +filename
 process=( 
 ffmpeg
 .input(files)
 .filter_('scale', 532, 300)
 .output(os.path.join(outputpath,"{}".format(outputvideofile))
 .overwrite_output()
 .run(capture_stdout=True, capture_stderr=False)
 )
 global labelprint
 labelprint=ttk.Label(f1,text="Downsampling Done") ##also tried here Label(), tk.Label()...did not work
 labelprint.pack()

#########



I am getting the following error :



 File "", line 85
 labelprint=ttk.Label(f1,text="Downsampling Done")
 ^
SyntaxError: invalid syntax