I've spent a few weeks going through and testing all the answers on here for lossless cutting using FFMPEG on Android. No matter what I try I always get loss. In the app we're building we need to be millisecond precise.
I've tried so many variations of the command with a lot of them being more than half a second off. This is for both copy and re-encoding. With this i have tried the -ss before and after as well as in both positions but I don't see any difference. These are the two commands that have worked the best be still not close enough:
//copy
"-ss $startTime -t $endTime -i $input -f segment -c copy $output"
//encode
"-i $input -ss $startTime -c:v libx264 -crf 12 -preset ultrafast -t $endTime $output"
Has anyone used a command or even other library that has given more accurate results?
After looking for days the closest I've come to millisecond precise trimming in FFMPEG is with the following command:
This command is precise to about a 20th of a millisecond with a 30fps clip but this will all depend on the frame rate of your video. I hope this helps others out. Here's an explanation of what each component does: