Screen capture WITH audio in ffmpeg

This works:

ffmpeg -f x11grab -video_size 1280x1024 -framerate 24 -i $DISPLAY -f alsa -i default -af \
acompressor=threshold=0.089:ratio=9:attack=200:release=1000 -vf scale=1280x720 -c:v h264_nvenc -g 24 \
-b:v 2M -preset fast -c:a aac -pix_fmt yuv420p -f otut.flv  

Taken from: Stream to Twitch with FFMPEG Y.T.


The solution seems to be to use both a different video and audio encoder. This line works:

FFmpeg/ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec aac -strict experimental output.flv

I couldn't get it to work without -acodec aac -strict experimental, contrary to the HOWTO on ffmpeg wiki.

The error message I'm getting is:

Output #0, flv, to 'output.flv':
    Stream #0:0: Video: flv1 (flv), yuv420p, 1024x768, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.34.100 flv
    Stream #0:1: Audio: adpcm_swf, 0 channels
    Metadata:
      encoder         : Lavc56.34.100 adpcm_swf
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> flv1 (flv))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> adpcm_swf (native))
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

Neither could I get this to work using:

FFmpeg/ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec copy output.mpeg

which contains -ac 2 probably in the right place. The error I'm getting repeatedly is:

[mp2 @ 0x7faffc007da0] Header missing

This most likely is a bug/regression.

To sum up, I've (probably) found 1 bug in ffmpeg and 1 bug in ffmpeg's wiki. And it looks like I'll have to buy the promised beer to myself ;)


version 4.2.2

get your audio

ffmpeg -list_devices true -f dshow -i dummy

then

ffmpeg -rtbufsize 1500M -f dshow -i audio="Microphone (Realtek High Definition Audio)" -f -y -rtbufsize 100M -f gdigrab -t 00:00:30 -framerate 30 -probesize 10M -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p "d:\ffmpeg_testing.mp4"