Recherche avancée

Médias (0)

Mot : - Tags -/serveur

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (47)

Sur d’autres sites (8267)

  • node.js - Error : ENOENT : no such file or directory, unlink

    10 août 2020, par necroface

    I have the function below to convert a .wav file to .mp3. As you can see, before using the ffmpeg module to convert the audio file, I already check if the file exists or not, then upon conversion, I only keep the new file and delete the old one. But occasionally the console throws me the error Error: ENOENT: no such file or directory, unlink, which means that I unlink (delete) a non-existing file. I cannot understand why, because I already have an existence check even before the conversion, so it is supposed to have existed to be unlinked.

    



    module.exports.convertAndMoveElastic = async (calllog) => {
    let { start, sip_uri, direction, source, destination } = calllog;
    const VNtimezoneOffset = 7 + new Date().getTimezoneOffset() / 60;
    const startTime = new Date(start + VNtimezoneOffset * 3600000 - 60000);
    const date = startTime.getDate() < 10 ? `0${startTime.getDate().toString()}` : startTime.getDate().toString();
    const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
    const month = months[startTime.getMonth()];
    const year = startTime.getFullYear().toString();
    sip_uri = sip_uri || (direction === 'outgoing' ? source : destination);
    const [extension, domain_name] = sip_uri.split("@");
    return new Promise(async (resolve, reject) => {
        const links = await getLinkWithElastic(calllog);
        if (!links) { return reject(); }
        let file_id, filepath;
        for (let link of links) {
            const { callid, sipCallid, uuid, record_path } = link._source;
            if (record_path) {
                let recordPathArr = record_path.split('/');
                file_id = recordPathArr[recordPathArr.length - 1].split('.')[0];
                filepath = path.resolve(base_directory, domain_name, 'archive', year, month, date, `${file_id}.wav`);
            }
            if (!file_id || !fs.existsSync(filepath)) {
                file_id = callid;
                filepath = path.resolve(base_directory, domain_name, 'archive', year, month, date, `${file_id}.wav`);
            }
            if (!file_id || !fs.existsSync(filepath)) {
                file_id = uuid;
                filepath = path.resolve(base_directory, domain_name, 'archive', year, month, date, `${file_id}.wav`);
            }
            if (fs.existsSync(filepath)) { break; }
        }
        if (!fs.existsSync(filepath)) { return reject(); }
        ffmpeg(filepath)
            .audioCodec('libmp3lame')
            .on('error', function (error) {
                reject(error);
            })
            .on('end', function () {
                resolve({ recordUrl: `${host}/record/download/${file_id}.mp3` });
                fs.unlinkSync(filepath);
            })
            .toFormat('mp3')
            .saveToFile(path.resolve(dest_directory, file_id + ".mp3"));
    });
};


    


  • Scaling Application for video decoding using ffmpeg

    6 juillet 2020, par jasoos

    I am building an application to read multiple IP camera streams (rtsp) and run different Machine Learning Algorithms over it in real time. For each camera stream,

    


      

    1. I spawn an ffmpeg process which continuously break the rtsp streams
into frames and store them as images (JPEG). The streams use H.264
encoding. I am taking 1 frame every second as output.
    2. 


    3. Message queues corresponding to models are given the message
containing location of the file.
    4. 


    5. Models keep on picking up the file and drawing inferences
    6. 


    


    The problem I am facing is the CPU usage by ffmpeg decoding process. For real time inference without any loss of frames, I have to beef up my server by a core for every 2 camera streams. Is there any optimization I am missing for ffmpeg ?

    


    I am using Intel Xeon Gold processor with Ubuntu 18.04 OS

    


  • Creating video from list of images using ffmpeg

    13 août 2019, par haseeb

    Summary

    From given code, second function taking UI values and passing to first one. from log, first two lines shows command list and command string.

    What’s irritating me is, if I copied second line from log (dos cmd) and paste it in a cmd prompt, it works successfully and produces video correctly. but running it via gui subprocess, errors out.

    Task Description

    Directory contains thousand of images each after few minutes of a construction project. I need to create a video from data (images) per day basis. I have successfully extracted list of images, etc, and have data.

    utils.py :

    def framesToVideoViaCount(srcFile,outputFile,start,count,rate):
       # ffmpeg -start_number 1 -i test_%04d.png -vframes 100 -vcodec mpeg4 test.mp4
       # "C:\\Users\\lalat\\Desktop\\03008427633\\output_%04d.png"
       # ffmpeg -start_number 50 -i "C:\\Users\\lalat\\Desktop\\03008427633\\output_%04d.png" -vframes 200 -vcodec mpeg4 "C:\\Users\\lalat\\Desktop\\day1.mp4"
       command = [ 'ffmpeg',
                   # '-loglevel', 'fatal',
                   '-r %d' %(rate),
                   '-start_number %d' %(start) ,
                   '-i "%s"' %(srcFile),
                   '-vframes %d' %(count),
                   '-vcodec mpeg4' ]
       # command.append ('fps=%d' % (fps))
       command.append (outputFile)
       print ("COMMAND: " , command)
       print ("DOS CMD: ", ' '.join(command))
       ffmpeg = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
       out, err = ffmpeg.communicate()
       if(err) : print('error',err); return None;
       print (out)

    Actual GUI function call in tk gui app :

    def approachByCount(self):
       tdate = datetime(year=int(self.fyear.get()), month=int(self.fmonth.get()), day=int(self.fdate.get()))
       # now = datetime.datetime.now()
       outputName = str(tdate.strftime("%Y%m%d")) + ".txt"
       outputVid = str(tdate.strftime("%Y%m%d")) + ".mp4"
       files = os.listdir(self.userDir)
       selected = []
       for afile in files:
           afile = os.path.join(self.userDir,afile)
           sdate = datetime.fromtimestamp(os.path.getmtime(afile))
           if sdate.date() == tdate.date():
               selected.append(afile)
       # get first file name
       srcfilename = os.path.basename(selected[0])
       srcfilename,ext = srcfilename.split(".")
       filename,pad = srcfilename.split("_")
       srcfilename = os.path.join(self.userDir,filename+"_%0"+str(len(pad))+"d."+ext)
       start = int(pad)
       count = len(selected)
       utils.framesToVideoViaCount(srcfilename,outputVid,start,count,25)

    ERROR log

    COMMAND:  ['ffmpeg', '-r 25', '-start_number 1', '-i "C:\\Users\\lalat\\Desktop\\03008427633\\output_%04d.png"', '-vframes 382', '-vcodec mpeg4', '20190810.mp4']
    DOC CMD:  ffmpeg -r 25 -start_number 1 -i "C:\Users\lalat\Desktop\03008427633\output_%04d.png" -vframes 382 -vcodec mpeg4 20190810.mp4

    error b"ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers\r\n
    built with gcc 8.2.1 (GCC) 20181017\r\n
    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\r\n
    libavutil      56. 22.100 / 56. 22.100\r\n
    libavcodec     58. 35.100 / 58. 35.100\r\n
    libavformat    58. 20.100 / 58. 20.100\r\n
    libavdevice    58.  5.100 / 58.  5.100\r\n
    libavfilter     7. 40.101 /  7. 40.101\r\n
    libswscale      5.  3.100 /  5.  3.100\r\n
    libswresample   3.  3.100 /  3.  3.100\r\n
    libpostproc    55.  3.100 / 55.  3.100\r\n
    Unrecognized option 'r 25'.\r\n
    Error splitting the argument list: Option not found\r\n"