Click here to Skip to main content
15,905,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
I am trying to cut the video accurately by giving the start and end time of the video using ffmpeg command line tool. I have the sample of the command which will cut the video in fraction of seconds. Here is the code: [E:\> ffmpeg -i "input.mp4" -ss 00:00:03 -t 00:00:15 -acodec copy -vcodec copy "output.mp4"] but the problem is the video was not cut at the correct starting time. Alternatively i have another sample code [E:\> ffmpeg -i "input.mp4" -ss 00:00:03 -t 00:00:15 -acodec libx264 -vcodec ac3 "output.mp4"] in this code the video cutting at the correct time but its taking more time to cut the video. I am searching for the exact command which will cut the video accurately and faster, i will be more happy if anyone help me to get solution for this.

Thanks & regards,
J.Surjith Kumar
Posted

1 solution

Your first command is just a straight copy of the audio and video codecs so ffmpeg is no doing any transcoding, and if that is the case, maybe it is more dependent on the timestamps that are in the stream. Your "cutting" accuracy may depend on the frequency of the timestamps in the source file. If the timestamps are every 2 seconds, then that is your accuracy. Your second command may be causing transcoding to happen, and in this case ffmpeg may has more control over timing marks, and in fact, may be setting it's own default. The solution may be to increase your timestamp frequency in your source video. If your timestamp setting in the source is say 300, and you are at 30 frames/second, your accuracy will be 10 seconds.
 
Share this answer
 
v2
Comments
J.Surjith Kumar 23-Aug-13 12:13pm    
Thank you for your solution. I hope you have an experience with working in ffmpeg, can you tell me how to check out the time stamp frequency in the source video and how to increase the frequency of it. Do you have any direct command to execute this!?
onemorecoke 23-Aug-13 12:36pm    
You can use the command ffmpeg -i "input.mp4" to get info on the file. It will show the timestamp rate. I am not sure where you are getting your source video, but when the video is rendered from editing you should be able to set the timestamp frequency, which is usually a timestamp per X amount of frames. I would get a new file with a timestamp every 1 second and see if the accuracy of your cropping with that first ffmpeg instruction you specified. Good luck!
J.Surjith Kumar 26-Aug-13 8:43am    
The video was cutting at every 5th second even though i try to cut in the middle. For example if i give 3rd second as the starting position to cut the video its cutting the video from the 5th second like wise if i give 8th second as the starting position its cutting the video from the 10th second. I don't know why it is happening. can you help me!
onemorecoke 26-Aug-13 10:45am    
The information you gave is more evidence that the timestamps in the original video are set at 5 seconds and the fast ffmpeg method will only be able to break at those positions. The only solution to use the faster ffmpeg command is to have more frequent timestamps in your source video. If you are not able to do that then you will only be able to use the second slower method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900