Find the answer to your Linux question:
Results 1 to 5 of 5
Hi Guys! I was able to make some video capture using ffmpeg the code of which I posted below. My question is, would it be possible for me to make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272

    Help Needed in FFMPEG Tweaking Please.


    Hi Guys!

    I was able to make some video capture using ffmpeg the code of which I posted below.

    My question is, would it be possible for me to make ffmpeg take shots every 3 seconds or so instead of a continues video? Thanks!

    Code:
    jun@jun:~$ ffmpeg -t 00:00:30  -f video4linux2 -s 128x96 -r ntsc -i /dev/video0 -f alsa -ac 2 -i pulse -qscale 3 sample_output.avi
    nujinini
    Linux User #489667

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    i don't know much about ffmpeg, but you could do it with a bash loop, i think. something like this:
    Code:
    #!/bin/bash
    
    # how long to run (in seconds)
    max=30
    
    # how frequently to take a picture
    int=3
    
    declare -i x=1
    until [ $x -gt $max ]; do
      imgfile="test_$(printf "%02d" $x).png"
      ffmpeg -f video4linux2 -i /dev/video0 -vframes 1 $imgfile
      sleep $int
      x+=$int
    done
    i left out the other ffmpeg options, you can add in what you need, but some of those options won't work w/writing to an image file. i don't have a video device, btw, so i can't test this code. i could only do an x11grab to take a video screen capture of my X11 display, but it won't let me do snaps for some reason.

  3. #3
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272
    Thanks atreyu!

    When I try

    #! /bin/bash

    It just returns me to the prompt and nothing else happens fyi.
    nujinini
    Linux User #489667

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by nujinini View Post
    Thanks atreyu!

    When I try

    #! /bin/bash

    It just returns me to the prompt and nothing else happens fyi.
    sorry, nujinini, i should have explained a little further. you want to put all that code into a script then execute that script.

    so if your editor is nedit, you could do:
    Code:
    nedit ~/ffmpeg-screencap.sh
    then cut-and-paste the code I posted into the editor, then save and quit.

    then make it executable:
    Code:
    chmod +x ~/ffmpeg-screencap.sh
    then run it:
    Code:
    ~/ffmpeg-screencap.sh

  5. #5
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    Location
    City of Salt
    Posts
    185
    try
    Code:
    bash ~/ffmpeg-screencap.sh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •