rdp / screen-capture-recorder-to-video-windows-free

a free open source windows "screen capture" device and recorder (also allows VLC/ffmpeg and others to capture/stream desktop/audio)
https://github.com/rdp/screen-capture-recorder-to-video-windows-free/releases
Other
2.09k stars 458 forks source link

FFmpeg multithreaded encoding with SCR #49

Open andrasfuchs opened 9 years ago

andrasfuchs commented 9 years ago

I've tested some cases and it looks like ffmpeg can't use the multi-threaded encoding with screen-capture-recorder. It might be a problem with ffmpeg's way to handle dshow inputs, I don't know.

Did anyone else had the same experience? It tried to record a full-hd screen and could not get above the 25% CPU usage on my 4-core machine. I tried both 32 and 64 bit Zeranoe builds (http://ffmpeg.zeranoe.com/builds/).

rdp commented 9 years ago

what command lines did you use? if you're encoding to libx264 it should by default use multiple cores, AFAIK

On Thu, Nov 6, 2014 at 1:31 AM, Andras Fuchs notifications@github.com wrote:

I've tested some cases and it looks like ffmpeg can't use the multi-threaded encoding with screen-capture-recorder. It might be a problem with ffmpeg's way to handle dshow inputs, I don't know.

Did anyone else had the same experience? It tried to record a full-hd screen and could not get above the 25% CPU usage on my 4-core machine. I tried both 32 and 64 bit Zeranoe builds (http://ffmpeg.zeranoe.com/builds/ ).

— Reply to this email directly or view it on GitHub https://github.com/rdp/screen-capture-recorder-to-video-windows-free/issues/49 .

andrasfuchs commented 9 years ago

Yes, I also think it should, that's why I'm surprised. I tried to do the encoding with both x264 and x264rgb with the same results. The multi-core functionality worked fine when I selected a video file as an input though.

Here are my command lines: 1, ffmpeg -loglevel warning -f dshow -i video="screen-capture-recorder" -f dshow -i audio="Microphone (Samson Meteor Mic)" -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -vsync vfr -acodec libmp3lame -f mpegts - | ffmpeg -f mpegts -i - -c copy "test_x264_01.mp4"

max. 25% CPU

2, ffmpeg -loglevel warning -f dshow -i video="screen-capture-recorder" -f dshow -i audio="Microphone (Samson Meteor Mic)" -vcodec libx264rgb -preset ultrafast -crf 0 -pix_fmt rgb24 -s 1920x1080 -vsync vfr -acodec libmp3lame -ac 1 -ar 44100 -b:a 96k -f mpegts - | ffmpeg -f mpegts -i - -c copy "x264rgb_crf00_uf_rgb24.mp4"

Max 25% CPU

and

3, ffmpeg -loglevel warning -i x264rgb_crf00_uf_rgb24.mp4 -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -vsync vfr -acodec libmp3lame -f mpegts - | ffmpeg -f mpegts -i - -c copy "test_x264_01.mp4"

Max. 45% CPU

I used the latest (2014-11-05) Zeranoe 64 bit build for the tests...

rdp commented 9 years ago

my guess is that it's using multi-thread but that your system has enough CPU to keep up in realtime [?]

On Thu, Nov 6, 2014 at 6:34 AM, Andras Fuchs notifications@github.com wrote:

Yes, I also think it should, that's why I'm surprised. I tried to do the encoding with both x264 and x264rgb with the same results. The multi-core functionality worked fine when I selected a video file as an input though.

Here are my command lines: 1, ffmpeg -loglevel warning -f dshow -i video="screen-capture-recorder" -f dshow -i audio="Microphone (Samson Meteor Mic)" -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -vsync vfr -acodec libmp3lame -f mpegts - | ffmpeg -f mpegts -i - -c copy "test_x264_01.mp4"

max. 25% CPU

2, ffmpeg -loglevel warning -f dshow -i video="screen-capture-recorder" -f dshow -i audio="Microphone (Samson Meteor Mic)" -vcodec libx264rgb -preset ultrafast -crf 0 -pix_fmt rgb24 -s 1920x1080 -vsync vfr -acodec libmp3lame -ac 1 -ar 44100 -b:a 96k -f mpegts - | ffmpeg -f mpegts -i - -c copy "x264rgb_crf00_uf_rgb24.mp4"

Max 25% CPU

and

3, ffmpeg -loglevel warning -i x264rgb_crf00_uf_rgb24.mp4 -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -vsync vfr -acodec libmp3lame -f mpegts - | ffmpeg -f mpegts -i - -c copy "test_x264_01.mp4"

Max. 45% CPU

I used the latest (2014-11-05) Zeranoe 64 bit build for the tests...

— Reply to this email directly or view it on GitHub https://github.com/rdp/screen-capture-recorder-to-video-windows-free/issues/49#issuecomment-61978947 .

mca64 commented 9 years ago

-preset ultrafast chnage to -preset slow

now you should have 100% :D

andrasfuchs commented 9 years ago

Oh, bloody hell, you're right, it's 70% now :D

But then, how come that I can't capture more than 15 fps in 1920x1080? (I've set the max fps in SCR to 100)

mca64 commented 9 years ago

you must set more for real time buffer. Like 400M

mca64 commented 9 years ago

ffmpeg -loglevel info -re -rtbufsize 400M -f dshow -i video="UScreenCapture" -f dshow -i audio= ...

mca64 commented 9 years ago

and dont use ultrafast never. Practicial use is veryfast preset for live capture

andrasfuchs commented 9 years ago

@mca64 Thanks for the tips!

The default parameters were the following: ffmpeg -loglevel warning -re -rtbufsize 10M -f dshow -i video="screen-capture-recorder" -f dshow -i audio="Microphone (Samson Meteor Mic)" -vcodec libx264rgb -preset veryfast -crf 1 -pix_fmt rgb24 -s 1920x1080 -vsync vfr -acodec libmp3lame -ac 1 -ar 44100 -b:a 96k -f mpegts - | ffmpeg -f mpegts -i - -c copy "test_x264rgb_scr_re_rtbs010M.mp4"

I've made some tests:

@rdp Is it possible the SCR can't feed the data fast enough for FFmpeg?

mca64 commented 9 years ago

did you disabled Windows Aero on Windows 7? On Windows 8 you cant do that without little hack. What OS do you have?

mca64 commented 9 years ago

btw this is painful libmp3lame -ac 1 -ar 44100 -b:a 96k use something like this libmp3lame -q:a 2 -ar 44100 or -q:a 0 (MP3 V0) or even CBR 320. MP3 V2 is close to audio transparent. Preserve quality! ;)

andrasfuchs commented 9 years ago

Probably not, I have Win 8.1. I'll try again after disabling Aero.

You're right, the above settings are for testing only. SCR uses 44kHz, 2 chan, CBR 128 by default, I think.

mca64 commented 9 years ago

so you cant use it for higher framerate on Windows 8. Unless you will sespend there winlogon.exe process, kill explorer.exe and dwm.exe

mca64 commented 9 years ago

RDP please add support for fast Windows 8 desktop capture here you can see how they did it in OBS https://github.com/jp9000/OBS/blob/master/Source/DesktopImageSource.cpp

andrasfuchs commented 9 years ago

@mca64 Wow, this OBS is awesome! :+1:

rdp commented 9 years ago

someday I might even own windows 8 LOL

On Thu, Nov 6, 2014 at 9:56 AM, mca64 notifications@github.com wrote:

did you disabled Windows Aero on Windows 7? On Windows you cant do that without little hack. What OS do you have?

— Reply to this email directly or view it on GitHub https://github.com/rdp/screen-capture-recorder-to-video-windows-free/issues/49#issuecomment-62011961 .

Walkman100 commented 9 years ago

@rdp Nah, Windows 7 FTW.