Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • How to take a video of what's happening in selenium

    5 février 2019, par fabio

    I'm using Selenium 3 webdriver and Python 3 in Windows 7.

    I want to record a video of what's happening in my selenium tests.

    To do so I'm using FFmpeg and screen-capture-recorder but I can change programs.

    Here's my code:

    import unittest
    from selenium import webdriver
    from subprocess import Popen
    #from subprocess import call
    
    
    cmd = 'ffmpeg -y -rtbufsize 2000M -f dshow -i video="screen-capture-recorder" -r 10 -t 20 screen-capture.mp4'
    
    class SearchProductTest(unittest.TestCase):
        def setUp(self):
    
            # start the recording of movie
            self.videoRecording = Popen(cmd)
    
            # create a new Firefox session
            self.driver = webdriver.Firefox()
            self.driver.implicitly_wait(30)
            self.driver.maximize_window()
    
            # navigate to the application home page
            self.driver.get("http://demo-store.seleniumacademy.com/")
    
        def test_search_by_category(self):
            # get the search textbox
            search_field = self.driver.find_element_by_name("q")
            search_field.clear()
    
            # enter search keyword and submit
            search_field.send_keys("phones")
            search_field.submit()
    
            # get all the anchor elements which have product names displayed
            # currently on result page using find_elements_by_xpath method
            products = self.driver.find_elements_by_xpath(
                "//h2[@class='product-name']/a")
    
            # check count of products shown in results
            self.assertEqual(3, len(products))
            #self.videoRecording.terminate()
    
        def test_something_else(self):
            pass
    
        def tearDown(self):
            # close the browser window
            self.driver.quit()
    
            # Stop the recording
            self.videoRecording.terminate()
    
        #def terminate(process):
            #if process.poll() is None:
            #    call('taskkill /F /T /PID ' + str(process.pid))
    
    if __name__ == '__main__':
        unittest.main(verbosity=2)
    

    The problems are:

    1) the cmd gives a max time per the movie (20" in the example). If the test last more the movie is created and it works (but is incomplete, only 20").

    2) if the test last less the file is created but it doesn't work (the reader can't read it and it's just some bytes). This is the main error! I'm not sure about where to start the movie and where (and how) to stop it.

    3) If I have more than one test I would like to have only one movie for all of them (so I want to record all the tests in the same movie).

    4) if possible I would prefer to record the webdriver window (the one where my tests are running) and not my screen so meanwhile the tests go I can do something else (they are slow).

    Thanks you for the help.

  • Automation for Downloading, Encoding, Renaming and Uploading [on hold]

    5 février 2019, par Madara Uchiha

    How do I automate - downloading anime episodes from Torrent > Encode the videos with ffmpeg or gui > rename (with encoder tag) > upload to Google drive? Should work 24/7. Need help!

  • Laravel Spatie - Spatie\MediaLibrary\Jobs\PerformConversions Job Failed

    5 février 2019, par Tout Nu Les Chinois

    I have an issue with Laravel Spatie's media conversion OR Redis.

    I'm working in TDD, so all my test passed success, even conversion. For an input file sample.flv I have my files as expected..

    But when perform integration test my Jobs failed when they are queued.. (redis) And I have no logs.....

    Do you already have trouble with jobs and conversion ?

    job chained failed

    I am Using Laravel Spatie and Laravel-ffmpeg.

    The chained job

    ProcessPost::withChain([
                new AssociateMedias($post, $filenames),
                new AssociateTags($post, $tags, $user),
                new ActivatePost($post),
                new AttributeBadge('post', $user),
                new UpdateScore(100, $user)
            ])->dispatch($post)->allOnQueue('default');
    

    Here my Assoc Job

    public function handle()
        {
            array_map(function($name){
                $this->mediable->associate(UploadFiles::getTempDir() . $name);
            }, $this->filenames);
        }
    

    Here the assoc function in my Media trait

       /**
         * @param $path
         * @return Media
         * @throws DiskDoesNotExist
         * @throws FileDoesNotExist
         * @throws FileIsTooBig
         */
        public function associateVideo($path){
            $media = $this->addMedia($path)
                          ->toMediaCollection('videos');
    
            VideoConverter::toHls(
                'public',
                $media->originalPath(),
                $media->streamPath()
            );
    
            VideoConverter::toMp4(
                'public',
                $media->originalPath(),
                $media->downloadPath()
            );
    
            Storage::disk('public')->delete($media->originalPath());
    
            return $media;
        }
    

    And here my Conversion lib

    static function toMp4($disk, $path, $to) {
            $lowBitrateFormat = (new X264('aac'))->setKiloBitrate(500);
    
            FFMpeg::fromDisk($disk)
                ->open($path)
                ->addFilter(function ($filters) {
                    $filters->resize(new Dimension(960, 540));
                })
                ->export()
                ->inFormat($lowBitrateFormat)
                ->save($to);
        }
    
  • Is it possible to vertically rotate a showwaves (or showfreqs) overlay using ffmpeg ?

    5 février 2019, par Introspectre

    I wish to take a showwaves (or showfreqs) overlay and center it vertically using ffmpeg, e.g.

    ffmpeg -i input.mp3 -filter_complex "[0:a]showspectrum=color=fiery:saturation=2:slide=scroll:scale=log:win_func=gauss:overlap=1:s=960x1080,pad=1920:1080[vs]; [0:a]showspectrum=color=fiery:saturation=2:slide=rscroll:scale=log:win_func=gauss:overlap=1:s=960x1080[ss]; [0:a]showwaves=s=1920x540:colors=B80000|950000|690000:mode=p2p,inflate[sw]; [vs][ss]overlay=w[out]; [out][sw]overlay=0:(H-h)/2[out]" -map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a copy output.mkv
    

    enter image description here

    As shown above, the showwaves output is centered horizontally. But would it also be possible to have it centered vertically? Specifically, using a single -filter_complex command argument?

    I've looked through the ffmpeg manual and searched stackoverflow for an answer, but to no avail.

  • Adding Support for resuming download with FFMPEG ?

    5 février 2019, par INDIERs

    Currently i am using this to download hls streams with ffmpeg in android app

    ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "input.m3u8" -codec copy video.mp4

    it is working as it should.

    In case of network lost, the file will be downloaded from BEGINNING which is ofc not good at all.

    I did some research but didn't found anything great, just these never implemented ideas:

    First is get the duration of downloaded video file and then downloading the video from duration +0.1

    Result High chances of FrameLoss. Dropped.

    Second is to download all ts files one by one ofc using any downloader, using custom script, then concat them.

    Result: Okay but needs space double of origial filesize, Dropped.

    Third is to Download First segment Convert it to MP4 then download second segment convert to mp4 then concat with First Segment and so on... while Keeping records.

    Result: Nice One but repeating same task for more than 2000 time, will it be Okay ? .

    is there any better workaround for this ?

    I've already showed the logic i tried.