Question

I am cutting out segments from a long mp4 file and then rejoining parts of them. However, since FFMPEG apparently keeps the same MOOV atom for the trimmed files as the original, it looks to FFMPEG that the trimmed videos are all identical since they all have the same MOOV atom, and therefore only uses the first segment when trying to join the videos. Is there a way around this? Unfortunately since FFMPEG is embedded in an Android app, I can only use version 0.11. Edit:

This is a sample of the processes:

ffmpeg -i /sdcard/path/movie.mp4  -ss 00:00:06.000, -t  00:00:05.270, -c:a aac -c:v libx264 /sdcard/path/file1.mp4
ffmpeg -i /sdcard/path/movie.mp4  -ss 00:00:12.000, -t  00:00:04.370, -c:a aac -c:v libx264 /sdcard/path/file2.mp4
ffmpeg -i /sdcard/path/movie.mp4  -ss 00:00:23.000, -t  00:00:03.133, -c:a aac -c:v libx264 /sdcard/path/file3.mp4
ffmpeg -i "concat:/sdcard/path/file1.mp4|/sdcard/path/file2.mp4|/sdcard/path/file3.mp4" -c:a aac -c:v libx264 /sdcard/path/output.mp4

I've also tried using the copy codec option but that hasn't helped.

Was it helpful?

Solution

Can you try something like:

ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4

I hope this works with ffmpeg version 0.11. We need to make sure you can concat before applying the cut of file.

Also can you check the intermediary file*.mp4 works well? Can you try to put your video files on the same folder as ffmpeg I am not sure how the concat protocol reacts to /sdcard/path/file1.mp4|/sdcard/path/file2.mp4?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top