This is a way to download selective frame of the youtube video that you need rather than downloading the whole video and trim it locally.
The sample command below start downloading at 00:06:40.00 and for the duration of 40 secs then output it to a file with filename of out.mp4.
-f 22 is setting the resolution of the video to 720p. You can also use -f 18 for 360p mp4 resolution or -f 137 for 1080p mp4 resolution.
ffmpeg -ss 00:06:40.00 -t 40 -i $(youtube-dl -f 22 -g "https://www.youtube.com/watch?v=9QuapHtz9Ec") -acodec copy -vcodec copy -c copy out.mp4