Recording a demo
Whilst in game, you can pull up your console and type /record demoname
You will see a little counter at bottom left of your screen showing you the recording kbs counting up.
To stop recording, open console again and type /stoprecord
A much easier way to do this is to add the following code to your config_mp.cfg file found in your player profile folder.
Playing back a recorded demo
Unfortunately, the guys at IW haven't made a good job of developing this function in CoD4
Recorded demos are stored in "C:Program FilesActivisionCall of Duty 4 - Modern Warfaremaindemos" folder
However, you will need to cut/paste your demos from this folder and paste them into:
"C:Program FilesActivisionCall of Duty 4 - Modern WarfareModsModWarfaredemos"
If the demos folder doesn't exist, simply create it.
With that done, run cod4 multiplayer and select 'Mods' then 'Modwarefare'
Open up console and type /demo demoname
This will play your recorded demo