How to trim a video while preserving the metadata?

Reena, you can use this command:
ffmpeg -i source.mp4 -ss 0 -t 40 -map 0:v -map 0:a -map_metadata 0 target.mp4I hope this will work for you!

Please go through this thread for more help: How to trim video using FFmpeg