[FFmpeg-user] Hanging bat file and general encoding questions

dreeder quasareg.com dreeder at quasareg.com
Fri Sep 18 19:59:52 CEST 2015

Full disclosure, I am fairly unfamiliar with video codecs. I have 2 questions.

I'm trying to make something of a poor man's security camera DVR. I've created a
bat file, that basically loops infinitely and records chunks of time from an
rtsp stream from an ip camera in 1 hour blocks (although that time is

C:\...\ffmpeg\bin\ffmpeg -i rtsp:// -b:v 128k -vcodec
copy -r 30 -t 3600 -y "C:\...\TestRecord\Recording.avi"

As I have been lead to understand, this doesn't actually reencode, it just dumps
the stream into a file so there's minimal strain on the cpu. However I haven't
been able to 100% confirm that. I am concerned I'm going to build a machine
without hardware encoding and then try to record from 10 cameras simultaneously
and the cpu is going to melt trying to encode it all

My second question is related to my batch script.

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)

C:\...\ffmpeg\bin\ffmpeg -i rtsp:// -b:v 128k -vcodec
copy -r 30 -t 3600 -y "C:\...\%mydate%_%mytime%_Recording.avi"
goto :while

When I run this it will eventually hang at the cmd prompt. 


C:\...\Scripting>goto :while

C:\...\Scripting>For /F "tokens=2-4 delims=/ " %a in ('date /t') d
o (set mydate=%c-%a-%b )

C:\...\Scripting>(set mydate=2015-09-18 )

C:\...\Scripting>For /F "tokens=1-2 delims=/:" %a in ('time /t') d
o (set mytime=%a%b )

C:\...\Scripting>(set mytime=0141 PM )

in\ffmpeg -i rtsp:// -b:v 128k -vcodec copy -r 30 -t
10 -y "C:\...\TestRecord\2015-09-18_0141 PM_Recording.avi"
ffmpeg version N-75316-gcbbd906 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzli
b --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv
--enable-libass --enable-libblu
ray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype
--enable-libgme --enab
le-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame
--enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp
--enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --ena
ble-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavpack --en
able-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable-lzma --ena
ble-decklink --enable-zlib
libavutil 55. 2.100 / 55. 2.100
libavcodec 57. 2.100 / 57. 2.100
libavformat 57. 2.100 / 57. 2.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 4.100 / 6. 4.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100<----------------------------------------- I
have to use Ctrl-C or else it will hang here indefinitely.

Received Windows Signal 0 <----------------------------------------------I send
an interrupt

rtsp:// Invalid data found when processing input
Exiting normally, received signal 2.
Terminate batch job (Y/N)?


This happens about 10% of the time. Currently I suspect its just bad error
handling of a spotty internet connection(Currently I'm connecting to this camera
through wireless and a vpn to a remote facility) but this system would have to
be up pretty much 100%. If I were to actually implement it, the cameras would be
wired by ethernet to the DVR machine. Regardless, is there a solution that can
handle this issue more gracefully than manually sending an interrupt?


More information about the ffmpeg-user mailing list