
Recherche avancée
Médias (3)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
Autres articles (92)
-
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
Taille des images et des logos définissables
9 février 2011, parDans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...) -
Pas question de marché, de cloud etc...
10 avril 2011Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
sur le web 2.0 et dans les entreprises qui en vivent.
Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)
Sur d’autres sites (3186)
-
How to speedup image processing (e.g. resizing, jpeg compress, encode) using ffmpeg command line utility from python on windows
28 mars 2020, par MSD PaulI am running ffmpeg commands to downsizing and jpeg compression of a 4K image using command prompt on windows 10. But its taking a long time. To downsize, jpeg compress and finally encode to a video file it takes more than 500 ms.
I can’t do the processing on images on batch but I have tried -hwaccel and -threads option (also -loglevel quiet for suppressing the logs being printed) in order to speedup the ffmpeg processing. Can someone please guide me towards how can I possibly speedup the ffmpeg command processing.
Is it possible to pass the image files already read into memory using read() API to the ffmpeg command ?
Please also let me know if there exists any other possible speedup techniques.
Updated log :
ffmpeg -i pic_1_org.png -vf scale=960 :-1 -q:v 80 -c:v libx264 -qp 25 -y temp_1.mp4*
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.0 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[png_pipe @ 00000000001e7920] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, png_pipe, from 'pic_1_org.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgb24(pc), 3840x2160 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 000000000260dcc0] -qscale is ignored, -crf is recommended.
[libx264 @ 000000000260dcc0] using SAR=1/1
[libx264 @ 000000000260dcc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 000000000260dcc0] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 000000000260dcc0] 264 - core 148 r2762 90a61ec - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=17 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=25 ip_ratio=1.40 pb_ratio=1.30 aq=0
Output #0, mp4, to 'temp_1.mp4':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 960x540 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=22.0 Lsize= 135kB time=00:00:00.00 bitrate=14197538.5kbits/s speed=0.000451x
video:134kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.594442%
[libx264 @ 000000000260dcc0] frame I:1 Avg QP:22.00 size:136966
[libx264 @ 000000000260dcc0] mb I I16..4: 13.4% 32.1% 54.5%
[libx264 @ 000000000260dcc0] 8x8 transform intra:32.1%
[libx264 @ 000000000260dcc0] coded y,u,v intra: 80.3% 59.0% 55.2%
[libx264 @ 000000000260dcc0] i16 v,h,dc,p: 5% 70% 5% 19%
[libx264 @ 000000000260dcc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 5% 38% 14% 4% 5% 4% 14% 3% 14%
[libx264 @ 000000000260dcc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 8% 24% 10% 5% 6% 4% 26% 3% 14%
[libx264 @ 000000000260dcc0] kb/s:27393.20
time needed to execute : 478.073120 ms*
-
Running ffmpeg on cmd works, but integrating it with PHP gives out an error
11 juin 2022, par digiboyRunning ffmpeg to covert files to mp4 works normally when ran from a command line prompt, but
upon trying to integrate it into a php code I keep getting errors and I am not sure why that is. The error says :


'-i' is not recognized as an internal or external command,
operable program or batch file.
Upload failed 



This is the function that is responsible for running ffmpeg code that converts the file :


public function convertVideoToMp4($tempFilePath, $finalFilePath) {
 $cmd = "$this->ffmpegPath -i $tempFilePath $finalFilePath 2>&1";

 $outputLog = array();
 exec($cmd, $outputLog, $returnCode);

 if($returnCode != 0) {
 //Command failed
 foreach($outputLog as $line) {
 echo $line . "<br />";
 }
 return false;
 }

 return true;
}



and since my code is returning an error pointing to a command line command being faulty, I am guessing it is triggering the
echo $line . "<br />";
from the function above.
However, right under this error output, I have an errorUpload failed

which points to a different function in the program, mainly the one responsible for the upload of the file itself :

if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {
 $finalFilePath = $targetDir . uniqid() . ".mp4";

 if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {
 echo "Insert query failed\n";
 return false;
 }

 if(!$this->convertVideoToMp4($tempFilePath, $finalFilePath)) {
 echo "Upload failed\n";
 return false;
 }

 if(!$this->deleteFile($tempFilePath)) {
 echo "Upload failed\n";
 return false;
 }

 if(!$this->generateThumbnails($finalFilePath)) {
 echo "Upload failed - could not generate thumbnails\n";
 return false;
 }

 }



But even though I get the output saying Upload failed, my file DOES get transfered into the folder that is dedicated as the "Upload folder" but the file is NOT converted from flv to mp4 before being uploaded, so I am left very confused.


For those who are wondering what the whole code looks like, this is VideoProcessor.php :


<?php
class VideoProcessor {

 private $con;
 private $sizeLimit = 500000000;
 private $allowedTypes = array("mp4", "flv", "webm", "mkv", "vob", "ogv", "ogg", "avi", "wmv", "mov", "mpeg", "mpg");

 private $ffmpegPath;

 private $ffprobePath;

 public function __construct($con) {
 $this->con = $con;
 $this->ffmpegPath = realpath("C:\Program Files\ffmpeg\bin\ffmpeg");
 $this->ffprobePath = realpath("C:\Program Files\ffmpeg\bin\ffprobe");

 }

 public function upload($videoUploadData) {

 $targetDir = "uploads/videos/";
 $videoData = $videoUploadData->videoDataArray;

 $tempFilePath = $targetDir . uniqid() . basename($videoData["name"]);
 $tempFilePath = str_replace(" ", "_", $tempFilePath);

 $isValidData = $this->processData($videoData, $tempFilePath);

 if(!$isValidData) {
 return false;
 }

 if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {
 $finalFilePath = $targetDir . uniqid() . ".mp4";

 if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {
 echo "Insert query failed\n";
 return false;
 }

 if(!$this->convertVideoToMp4($tempFilePath, $finalFilePath)) {
 echo "Upload failed\n";
 return false;
 }

 if(!$this->deleteFile($tempFilePath)) {
 echo "Upload failed\n";
 return false;
 }

 if(!$this->generateThumbnails($finalFilePath)) {
 echo "Upload failed - could not generate thumbnails\n";
 return false;
 }

 }
 }

 private function processData($videoData, $filePath) {
 $videoType = pathInfo($filePath, PATHINFO_EXTENSION);

 if(!$this->isValidSize($videoData)) {
 echo "File too large. Can't be more than " . $this->sizeLimit . " bytes";
 return false;
 }
 else if(!$this->isValidType($videoType)) {
 echo "Invalid file type";
 return false;
 }
 else if($this->hasError($videoData)) {
 echo "Error code: " . $videoData["error"];
 return false;
 }

 return true;
 }

 private function isValidSize($data) {
 return $data["size"] <= $this->sizeLimit;
 }

 private function isValidType($type) {
 $lowercased = strtolower($type);
 return in_array($lowercased, $this->allowedTypes);
 }

 private function hasError($data) {
 return $data["error"] != 0;
 }

 private function insertVideoData($uploadData, $filePath) {
 $query = $this->con->prepare("INSERT INTO videos(title, uploadedBy, description, privacy, category, filePath)
 VALUES(:title, :uploadedBy, :description, :privacy, :category, :filePath)");

 $query->bindParam(":title", $uploadData->title);
 $query->bindParam(":uploadedBy", $uploadData->uploadedBy);
 $query->bindParam(":description", $uploadData->description);
 $query->bindParam(":privacy", $uploadData->privacy);
 $query->bindParam(":category", $uploadData->category);
 $query->bindParam(":filePath", $filePath);

 return $query->execute();
 }

 public function convertVideoToMp4($tempFilePath, $finalFilePath) {
 $cmd = "$this->ffmpegPath -i $tempFilePath $finalFilePath 2>&1";

 $outputLog = array();
 exec($cmd, $outputLog, $returnCode);

 if($returnCode != 0) {
 //Command failed
 foreach($outputLog as $line) {
 echo $line . "<br />";
 }
 return false;
 }

 return true;
 }

 private function deleteFile($filePath) {
 if(!unlink($filePath)) {
 echo "Could not delete file\n";
 return false;
 }

 return true;
 }

 public function generateThumbnails($filePath) {

 $thumbnailSize = "210x118";
 $numThumbnails = 3;
 $pathToThumbnail = "uploads/videos/thumbnails";

 $duration = $this->getVideoDuration($filePath);

 echo "duration: $duration";
 }

 private function getVideoDuration($filePath) {
 return shell_exec("$this->ffprobePath -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $filePath");
 }
}
?>



-
Record Screen using ffmpeg doesn't work in tomcat server(Could not find codec parameters for stream 0)
4 septembre 2019, par Norhan MohamedI have the following problem,when I executed the below FFMPEG terminal command in command it prompt successfully.
C:\\ffmpeg\\bin\\ffmpeg.exe -f gdigrab -i desktop -c:v libx264 -analyzeduration 15M -probesize 15M -pix_fmt yuv420p -loglevel 99 C:\\ffmpeg\\bin\\video.mp4
but I have a problem while running a command from a java web application.I used
runtime.exec()
. It’s working fine at Netbeans. But not working at all after deploying on tomcat server.
Here is my code :String command = "C:\\ffmpeg\\bin\\"
+ "ffmpeg.exe -f gdigrab -i desktop -c:v libx264 -analyzeduration 15M -probesize 15M -pix_fmt yuv420p -loglevel 99 C:\\ffmpeg\\bin\\video.mp4";
System.out.println("command = " + command);
try {
Process p = Runtime.getRuntime().exec(command);
final InputStreamReader isr
= new InputStreamReader(p.getErrorStream());
Thread th = new Thread() {
public void run() {
try {
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (Exception ex) {
}
}
};
th.start();
} catch (IOException ex) {
System.out.println("Error 1 : " + ex.getMessage());
} catch (Exception ex) {
System.out.println("Error 2 : " + ex.getMessage());
}And here is log for error
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20190212
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'gdigrab'.
Reading option '-i' ... matched as input url with argument 'desktop'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'libx264'.
Reading option '-analyzeduration' ... matched as AVOption 'analyzeduration'
with argument '15M'.
Reading option '-probesize' ... matched as AVOption 'probesize' with argument '15M'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option 'C:\ffmpeg\bin\video.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument 99.
Successfully parsed a group of options.
Parsing a group of options: input url desktop.
Applying option f (force format) with argument gdigrab.
Successfully parsed a group of options.
Opening an input file: desktop.
[gdigrab @ 0000007c2a72ad00] Capturing whole desktop as 1024x768x32 at (0,0)
[gdigrab @ 0000007c2a72ad00] Failed to capture image (error 5)
[gdigrab @ 0000007c2a72ad00] stream 0: start_time: -9223372036854.775 duration: -9223372036854.775
[gdigrab @ 0000007c2a72ad00] format: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=754233 kb/s
[gdigrab @ 0000007c2a72ad00] Could not find codec parameters for stream 0 (Video: bmp, 1 reference frame, none, 754233 kb/s): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, gdigrab, from 'desktop':
Duration: N/A, bitrate: 754233 kb/s
Stream #0:0, 0, 1/1000000: Video: bmp, 1 reference frame, none, 754233 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: output url C:\ffmpeg\bin\video.mp4.
Applying option c:v (codec name) with argument libx264.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Successfully parsed a group of options.
Opening an output file: C:\ffmpeg\bin\video.mp4.
Output #0, mp4, to 'C:\ffmpeg\bin\video.mp4':
Output file #0 does not contain any streamCan anyone help me to get out of this issue.
Thanks in advance.