I have an MXF file with lots of metadata, which is quite long and big in size. I want to cut 30-40 seconds of it while preserving the said metadata. Is there any way I can do it with FFmpeg?
Hi Reena,
FFmpeg provides two parameters for trimming the video. -ss option allows you to seek video at a particular position it takes value in HH:MM: SSstrong text format or in absolute seconds. -t options allow you to read a specified number of seconds from the video which also takes value in the same format as -ss. So with the combination of both -ss and -t you can trim a video.
For mapping metadata, you can use the -map_metadata parameter provided by FFmpeg. This parameter with 0 strong textas its value will copy all the metadata from the source to the target video file. If you have only metadata types in your source video file then you have to map them individually.
Don’t forget to read about SAR and DAR metadata in FFmpeg
This will help you to understand more about this concept.
Thanks, Gurupal!
So, can give me an FFmpeg command example for your answer?
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
One more question, how can I map metadata for a particular stream with the FFmpeg command in the above example?
You can map metadata for a particular stream using the -map_metadata option with an index of the stream from which you want to copy the metadata. For example, if you want to copy metadata from only a video stream then you can use the following command
ffmpeg -i source.mp4 -map 0:v -map 0:a -map_metadata:s:v 0:s:v -c copy target.mp4
For more please visit this thread: How to trim videos with both ffmpeg and ffprobe?