Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques Split DirectShow Capture

  • Split DirectShow Capture

    Posted by Luana Black on January 4, 2012 at 3:21 pm

    I am currently using ffmpeg to capture video and audio from direcshow (windows 7):

    ffmpeg.exe -f dshow -i video=”V string”:audio=”A string” -r 25 -t 300 -n output.avi

    “-t 300” makes it to capture for 300 seconds (5 mins). But i would like to capure more time splitting the output file in chunks.

    For example make a 30 minute recording in 6 chunks of 5 minutes. I could do this in a batch file calling 6 times ffmpeg in a loop, but in this way i lose capture time between the loops (1 second more or less). I would like to do it without losing capture time.

    Any way i can make this to happen?
    Thanks

    Luana Black replied 14 years, 6 months ago 3 Members · 7 Replies
  • 7 Replies
  • Reuben Martin

    January 5, 2012 at 2:26 am
  • Luana Black

    January 5, 2012 at 4:39 am

    Thanks for your reply. I cant get it to work, i am probably doing something wrong.

    ffmpeg.exe -f dshow -s 352×288 -i video=”Video WebCam”:audio=”Micr¢fono (Realtek High Definit” -r 10 -f segment out%03d.avi
    ffmpeg version N-36088-gdd1fb65, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 22 2011 12:39:23 with gcc 4.6.2
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 51. 32.100 / 51. 32.100
    libavcodec 53. 47.100 / 53. 47.100
    libavformat 53. 28.100 / 53. 28.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 53. 0 / 2. 53. 0
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 5.100 / 0. 0.100
    libpostproc 51. 2.100 / 51. 2.100
    [dshow @ 003D8920] Estimating duration from bitrate, this may be inaccurate

    Seems stream 0 codec frame rate differs from container frame rate: 10000000.00 (10000000/1) -> 15.00 (15/1)
    Input #0, dshow, from 'video=Video WebCam:audio=Micrófono (Realtek High Definit':
    Duration: N/A, start: 140270.327000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 352x288, 15 tbr, 10000k tbn, 10000k tbc
    Stream #0:1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
    Output #0, segment, to 'out%03d.avi':
    Output file #0 does not contain any stream

    I also tried this:
    ffmpeg.exe -f dshow -s 352×288 -i video=”Video WebCam”:audio=”Micr¢fono (Realtek High Definit” -r 10 -f segment -time 10 out%03d.avi
    ffmpeg version N-36088-gdd1fb65, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 22 2011 12:39:23 with gcc 4.6.2
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 51. 32.100 / 51. 32.100
    libavcodec 53. 47.100 / 53. 47.100
    libavformat 53. 28.100 / 53. 28.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 53. 0 / 2. 53. 0
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 5.100 / 0. 0.100
    libpostproc 51. 2.100 / 51. 2.100
    [dshow @ 00268960] Estimating duration from bitrate, this may be inaccurate

    Seems stream 0 codec frame rate differs from container frame rate: 10000000.00 (10000000/1) -> 15.08 (181/12)
    Input #0, dshow, from 'video=Video WebCam:audio=Micrófono (Realtek High Definit':
    Duration: N/A, start: 139833.164000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 352x288, 15.08 tbr, 10000k tbn, 10000k tbc
    Stream #0:1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
    Unrecognized option 'time'
    Failed to set value '10' for option 'time'

    I put this just to show and compare how it works without segmenting.
    ffmpeg.exe” -f dshow -s 352×288 -i video=”Video WebCam”:audio=”Micr¢fono (Realtek High Definit” -r 10 out.avi
    ffmpeg version N-36088-gdd1fb65, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 22 2011 12:39:23 with gcc 4.6.2
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 51. 32.100 / 51. 32.100
    libavcodec 53. 47.100 / 53. 47.100
    libavformat 53. 28.100 / 53. 28.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 53. 0 / 2. 53. 0
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 5.100 / 0. 0.100
    libpostproc 51. 2.100 / 51. 2.100
    [dshow @ 01F28880] Estimating duration from bitrate, this may be inaccurate

    Seems stream 0 codec frame rate differs from container frame rate: 10000000.00 (10000000/1) -> 15.00 (15/1)
    Input #0, dshow, from 'video=Video WebCam:audio=Micrófono (Realtek High Definit':
    Duration: N/A, start: 139364.511000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 352x288, 15 tbr, 10000k tbn, 10000k tbc
    Stream #0:1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
    Incompatible pixel format 'yuyv422' for codec 'mpeg4', auto-selecting format 'yuv420p'
    [buffer @ 02F7FD00] w:352 h:288 pixfmt:yuyv422 tb:1/1000000 sar:0/1 sws_param:
    [buffersink @ 02FE4560] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
    [scale @ 02F083E0] w:352 h:288 fmt:yuyv422 -> w:352 h:288 fmt:yuv420p flags:0x4
    Output #0, avi, to 'out.avi':
    Metadata:
    ISFT : Lavf53.28.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 352x288, q=2-31, 200 kb/s, 10 tbn, 10 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, 2 channels, s16, 128 kb/s
    Stream mapping:
    Stream #0:0 -> #0:0 (rawvideo -> mpeg4)
    Stream #0:1 -> #0:1 (pcm_s16le -> libmp3lame)
    Press [q] to stop, [?] for help
    frame= 20 fps= 0 q=1.6 size= 90kB time=00:00:02.40 bitrate= 306.0kbits/s dup=0 drop=10
    frame= 25 fps= 23 q=1.6 size= 111kB time=00:00:02.89 bitrate= 313.2kbits/s dup=0 drop=13
    frame= 31 fps= 19 q=1.6 size= 132kB time=00:00:03.39 bitrate= 319.4kbits/s dup=0 drop=15
    frame= 36 fps= 17 q=1.6 size= 154kB time=00:00:03.91 bitrate= 322.5kbits/s dup=0 drop=18
    frame= 41 fps= 15 q=1.6 size= 176kB time=00:00:04.41 bitrate= 325.8kbits/s dup=0 drop=21

  • Reuben Martin

    January 5, 2012 at 10:25 pm

    Looks like their documentation is out of date. Try something more like this:

    ffmpeg.exe -f dshow -s 352x288 -i video="Video WebCam":audio="Micr¢fono (Realtek High Definit" -vcodec ffv1 -acodec pcm_s16le -map 0 -r 10 -f segment -segment_time 10 -container_format avi -segment_pattern %03d -segment_basename output dummy_out.avi

    change vcodec/acodec to whatever codec types you are aiming for.

    **This is for ver. 0.9.x

  • Luana Black

    January 8, 2012 at 6:23 am

    Thanks. I tried what you said but it still isnt working:
    ffmpeg.exe” -f dshow -s 320×240 -i video=”Video WebCam”:audio=”Micr¢fono (Realtek High Definit” -vcodec ffv1 -acodec pcm_s16le -map 0 -r 5 -f segment -segment_time 10 -container_format avi -segment_pattern %03d -segment_basename output dummy_out.avi

    ffmpeg version N-36492-g7f83db3, Copyright (c) 2000-2012 the FFmpeg developers
    built on Jan 5 2012 01:57:12 with gcc 4.6.2
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 51. 34.100 / 51. 34.100
    libavcodec 53. 53.100 / 53. 53.100
    libavformat 53. 29.100 / 53. 29.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 57.101 / 2. 57.101
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 5.100 / 0. 5.100
    libpostproc 51. 2.100 / 51. 2.100
    [dshow @ 02A51A60] Estimating duration from bitrate, this may be inaccurate
    Input #0, dshow, from 'video=Video WebCam:audio=Micrófono (Realtek High Definit':
    Duration: N/A, start: 13425.342000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 25 tbr, 10000k tbn, 10000k tbc
    Stream #0:1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
    Unrecognized option 'container_format'
    Failed to set value 'avi' for option 'container_format'

  • Luana Black

    January 8, 2012 at 10:07 pm

    I have been trying with older ffmpeg builds and i found that with this build it works:
    ffmpeg version N-35709-g7d531e8, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 12 2011 13:50:00 with gcc 4.6.2
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 51. 32. 0 / 51. 32. 0
    libavcodec 53. 43. 0 / 53. 43. 0
    libavformat 53. 24. 0 / 53. 24. 0
    libavdevice 53. 4. 0 / 53. 4. 0
    libavfilter 2. 53. 0 / 2. 53. 0
    libswscale 2. 1. 0 / 2. 1. 0
    libpostproc 51. 2. 0 / 51. 2. 0

    I would like to use last build of ffmpeg if possible, but it says “Unrecognized option ‘container_format'”. Did the segmenting option names change? Is there any way to use segmenting with last build?

    Thanks for your replies, i can work with it now.

  • Reuben Martin

    January 9, 2012 at 12:47 am

    The builds you are using are pulled directly from the git repo. Most likely they are coming from the tip of the development branch, which could have any number of undocumented changes. Furthermore, you don’t really know if that is pulled from the mainline git repo, or somebody’s private clone which could potentually also have changes in it that differ from the main development.

    Trying finding builds of release versions. I am using 0.9.1, which is the most recently tagged release. Unless you need some feature that has been added since the 0.9.x branch was created, you will probably have the benefit of better stability as well.

  • Luana Black

    January 10, 2012 at 6:12 am

    To close the issue, here can be seen the changes made to segment.c
    https://git.videolan.org/?p=ffmpeg.git;a=history;f=libavformat/segment.c;hb=HEAD

    On 2011-12-19 was when they changed the variable names to “segment_time”, “segment_format”…

    I am not using this last version because seems to work worse than 2011-10-17 version.
    I has a bug (or i am using it wrong) that if i want to encode a video segmented in 10 sec chunks, the first clip is 10 seconds long, the second 20 seconds long (only last 10 sec with video data), the third is 30 secs long (only last 10 sec with video data), and so on.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy