Recherche avancée

Médias (3)

Mot : - Tags -/plugin

Autres articles (92)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La 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, par

    Dans 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 2011

    Le 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 Paul

    I 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 digiboy

    Running 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) {&#xA;    $cmd = "$this->ffmpegPath -i $tempFilePath $finalFilePath 2>&amp;1";&#xA;&#xA;    $outputLog = array();&#xA;    exec($cmd, $outputLog, $returnCode);&#xA;&#xA;    if($returnCode != 0) {&#xA;        //Command failed&#xA;        foreach($outputLog as $line) {&#xA;            echo $line . "<br />";&#xA;        }&#xA;        return false;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;

    &#xA;

    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.&#xA;However, right under this error output, I have an error Upload failed&#xA;which points to a different function in the program, mainly the one responsible for the upload of the file itself :

    &#xA;

    if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {&#xA;        $finalFilePath = $targetDir . uniqid() . ".mp4";&#xA;&#xA;        if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {&#xA;            echo "Insert query failed\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        if(!$this->convertVideoToMp4($tempFilePath, $finalFilePath)) {&#xA;            echo "Upload failed\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        if(!$this->deleteFile($tempFilePath)) {&#xA;            echo "Upload failed\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        if(!$this->generateThumbnails($finalFilePath)) {&#xA;            echo "Upload failed - could not generate thumbnails\n";&#xA;            return false;&#xA;        }&#xA;&#xA;    }&#xA;

    &#xA;

    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.

    &#xA;

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

    &#xA;

    &lt;?php&#xA;class VideoProcessor {&#xA;&#xA;    private $con;&#xA;    private $sizeLimit = 500000000;&#xA;    private $allowedTypes = array("mp4", "flv", "webm", "mkv", "vob", "ogv", "ogg", "avi", "wmv", "mov", "mpeg", "mpg");&#xA;&#xA;    private $ffmpegPath;&#xA;&#xA;    private $ffprobePath;&#xA;&#xA;    public function __construct($con) {&#xA;        $this->con = $con;&#xA;        $this->ffmpegPath = realpath("C:\Program Files\ffmpeg\bin\ffmpeg");&#xA;        $this->ffprobePath = realpath("C:\Program Files\ffmpeg\bin\ffprobe");&#xA;&#xA;    }&#xA;&#xA;    public function upload($videoUploadData) {&#xA;&#xA;        $targetDir = "uploads/videos/";&#xA;        $videoData = $videoUploadData->videoDataArray;&#xA;&#xA;        $tempFilePath = $targetDir . uniqid() . basename($videoData["name"]);&#xA;        $tempFilePath = str_replace(" ", "_", $tempFilePath);&#xA;&#xA;        $isValidData = $this->processData($videoData, $tempFilePath);&#xA;&#xA;        if(!$isValidData) {&#xA;            return false;&#xA;        }&#xA;&#xA;        if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {&#xA;            $finalFilePath = $targetDir . uniqid() . ".mp4";&#xA;&#xA;            if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {&#xA;                echo "Insert query failed\n";&#xA;                return false;&#xA;            }&#xA;&#xA;            if(!$this->convertVideoToMp4($tempFilePath, $finalFilePath)) {&#xA;                echo "Upload failed\n";&#xA;                return false;&#xA;            }&#xA;&#xA;            if(!$this->deleteFile($tempFilePath)) {&#xA;                echo "Upload failed\n";&#xA;                return false;&#xA;            }&#xA;&#xA;            if(!$this->generateThumbnails($finalFilePath)) {&#xA;                echo "Upload failed - could not generate thumbnails\n";&#xA;                return false;&#xA;            }&#xA;&#xA;        }&#xA;    }&#xA;&#xA;    private function processData($videoData, $filePath) {&#xA;        $videoType = pathInfo($filePath, PATHINFO_EXTENSION);&#xA;&#xA;        if(!$this->isValidSize($videoData)) {&#xA;            echo "File too large. Can&#x27;t be more than " . $this->sizeLimit . " bytes";&#xA;            return false;&#xA;        }&#xA;        else if(!$this->isValidType($videoType)) {&#xA;            echo "Invalid file type";&#xA;            return false;&#xA;        }&#xA;        else if($this->hasError($videoData)) {&#xA;            echo "Error code: " . $videoData["error"];&#xA;            return false;&#xA;        }&#xA;&#xA;        return true;&#xA;    }&#xA;&#xA;    private function isValidSize($data) {&#xA;        return $data["size"] &lt;= $this->sizeLimit;&#xA;    }&#xA;&#xA;    private function isValidType($type) {&#xA;        $lowercased = strtolower($type);&#xA;        return in_array($lowercased, $this->allowedTypes);&#xA;    }&#xA;&#xA;    private function hasError($data) {&#xA;        return $data["error"] != 0;&#xA;    }&#xA;&#xA;    private function insertVideoData($uploadData, $filePath) {&#xA;        $query = $this->con->prepare("INSERT INTO videos(title, uploadedBy, description, privacy, category, filePath)&#xA;                                        VALUES(:title, :uploadedBy, :description, :privacy, :category, :filePath)");&#xA;&#xA;        $query->bindParam(":title", $uploadData->title);&#xA;        $query->bindParam(":uploadedBy", $uploadData->uploadedBy);&#xA;        $query->bindParam(":description", $uploadData->description);&#xA;        $query->bindParam(":privacy", $uploadData->privacy);&#xA;        $query->bindParam(":category", $uploadData->category);&#xA;        $query->bindParam(":filePath", $filePath);&#xA;&#xA;        return $query->execute();&#xA;    }&#xA;&#xA;    public function convertVideoToMp4($tempFilePath, $finalFilePath) {&#xA;        $cmd = "$this->ffmpegPath -i $tempFilePath $finalFilePath 2>&amp;1";&#xA;&#xA;        $outputLog = array();&#xA;        exec($cmd, $outputLog, $returnCode);&#xA;&#xA;        if($returnCode != 0) {&#xA;            //Command failed&#xA;            foreach($outputLog as $line) {&#xA;                echo $line . "<br />";&#xA;            }&#xA;            return false;&#xA;        }&#xA;&#xA;        return true;&#xA;    }&#xA;&#xA;    private function deleteFile($filePath) {&#xA;        if(!unlink($filePath)) {&#xA;            echo "Could not delete file\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        return true;&#xA;    }&#xA;&#xA;    public function generateThumbnails($filePath) {&#xA;&#xA;        $thumbnailSize = "210x118";&#xA;        $numThumbnails = 3;&#xA;        $pathToThumbnail = "uploads/videos/thumbnails";&#xA;&#xA;        $duration = $this->getVideoDuration($filePath);&#xA;&#xA;        echo "duration: $duration";&#xA;    }&#xA;&#xA;    private function getVideoDuration($filePath) {&#xA;        return shell_exec("$this->ffprobePath -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $filePath");&#xA;    }&#xA;}&#xA;?>&#xA;

    &#xA;

  • Record Screen using ffmpeg doesn't work in tomcat server(Could not find codec parameters for stream 0)

    4 septembre 2019, par Norhan Mohamed

    I 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 stream

    Can anyone help me to get out of this issue.

    Thanks in advance.