Preventing real-time buffer error causing ffmpeg to drop frames in screencast
Facts - Other software technologies
Monday, 23 September 2013 07:15

The following note is related to ffmpeg version N-56553-g5dca837 built on Sep 21 2013 18:08:41 and VLC media player 2.0.8 Twoflower. Both programs have been installed on Windows 7.

To promote my dutch book on value investing I want to make some screencast presentations and put them on youtube. Making screencasts is not easy, at least not for me. First I tried to make screencasts with VLC media player. Unfortunately I did not manage to include sound from my microphone into my screencasts. So I looked for other software packages and I found ffmpeg.

ffmpeg was not so straightforward to install. In particular I found this long youtube video useful:

 

After installing ffmpeg and Screen Capturer Recorder I first made a list of my devices:

 
bash-3.2$ ffmpeg -list_devices true -f dshow -i dummy
.............
[dshow @ 00000000002ff560]  "screen-capture-recorder"
[dshow @ 00000000002ff560]  "Microphone (Realtek High Defini"

Then I tried to make a screencast with ffmpeg with the following command:

ffmpeg -f dshow -i video="screen-capture-recorder":audio="Microphone (Realtek High Defini" 
-r 30 -threads 0 test.mkv
.....................
[dshow @ 00000000028cdbe0] real-time buffer 97% full! frame dropped!
    Last message repeated 5 times

Unfortunately I saw lots of error messages like the one above. And the error could not be neglected: it seemed to drop so many videoframes that the sound got interrupted too much. Many words were not audible in the resulting screencast.

Too overcome this problem I tweaked the ffmpeg command:

ffmpeg -rtbufsize 1500M -f dshow -i video="screen-capture-recorder":audio="Microphone (Realtek High Defini" 
-r 40 -vcodec libx264 -threads 0 -crf 0 -preset ultrafast -tune zerolatency -acodec pcm_s161e test.flv

See also the ffmpeg streaming guide where I found part of this solution. Note that the output is flash. I could not get it working with mp4 output.