I am trimming the video using ffmpeg but the metadata position was founded at last in output video.
Is there any way to put metadata at beginning of output.mp4
I am trimming the video using ffmpeg but the metadata position was founded at last in output video.
Is there any way to put metadata at beginning of output.mp4
Use -movflags +faststart:
ffmpeg -ss 30 -i in.mp4 -t 00:02:34 -codec copy -movflags +faststart out.mp4
The -movflags +faststart option will relocate the moov atom from the end of the file to the beginning allowing playback to begin before the file is completely downloaded.
This example will skip the first 30 seconds (-ss 30) and the output will have a duration of 2 minutes and 34 seconds (-t 00:02:34).
Using -codec copy will use stream copy mode which will perform re-muxing instead of re-encoding; therefore preserving the quality.
You can add -map 0 if you want to include all streams from the input. Otherwise default stream selection will only include one stream per stream type (such as if your input contains more than one audio stream then by default only the stream with the most number of channels will be selected).
Make sure to use a recent ffmpeg since development is very active. See the FFmpeg Download page for options.