How to record an RSTP stream from an IP camera to a file using FFmpeg?

I want to record a video stream generated by an IP camera and put it in a file for each day. Is there any way I can do it using FFmpeg?

Recording IP camera video stream into a file using FFmpeg is quite easy. Usually, IP cameras generate RSTP stream which you can consume in your FFmpeg and produce output MP4 with the following command
ffmpeg -i rstp_url -c copy -f mp4 output.mp4

Thanks, Uma!

I have one more question, can you tell me how can I split a video stream recorded using an IP camera into multiple mp4 files?
Currently, MP4 files generated by the above FFmpeg command are quite large in terms of file size (20-25 GB per day). Is there any way I can split them into multiple mp4 files?

You can do one thing as the FFmpeg can save files in arbitrary segments at fixed intervals with the -segment_time option. In this example, we save a new file at 10-second intervals, but the value for segment_time can be any positive integer. Consider the following example.
ffmpeg -i rstp_url -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -c copy -map 0 output_%d.mp4