0

I'm using the media-autobuild_suite (on Windows 11). My installation is a week old. Tomorrow I will update it again.

I have one private video file. I wish to cut out two parts of it and then merge the two parts into a single result video file. I also wish to re-encode the video stream with -c:v libx265 -crf xx -preset veryslow, see here and the audio stream with -c:a libfdk_aac -b:a xxxk, see here. In addition I wish to delete all meta data in the result video file with -map_metadata -1 -metadata title="" -map_chapters -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact, see here. I wish to do my task in one run of FFmpeg, so I decided to use trim and concat, see here.

To demonstrate what I have done so far, I'm using a public test video from here.

For my case I adapted the solution from here. I done multiple test cases:

Case 1 (two source files, include meta data editing and full time stamps, for example 00.000:16.820):

ffmpeg -i source/BigBuckBunny.mp4 -i source/BigBuckBunny.mp4 -map_metadata -1 -metadata title="" -map_chapters -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -filter_complex "[0:v]trim=00.000:16.820,setpts=PTS-STARTPTS[v0]; [0:a]atrim=00.000:16.820,asetpts=PTS-STARTPTS[a0]; [1:v]trim=153.000:348.840,setpts=PTS-STARTPTS[v1]; [1:a]atrim=153.000:348.840,asetpts=PTS-STARTPTS[a1]; [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" -map "[v]" -c:v libx265 -crf 22 -preset veryslow -map "[a]" -c:a libfdk_aac -b:a 128k result/"BigBuckBunny".mkv.

Case 2 (only one source file, include meta data editing and short time stamps, for example 0:16.820):

ffmpeg -i source/BigBuckBunny.mp4 -map_metadata -1 -metadata title="" -map_chapters -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -filter_complex "[0:v]trim=0:16.820,setpts=PTS-STARTPTS[v0]; [0:a]atrim=0:16.820,asetpts=PTS-STARTPTS[a0]; [0:v]trim=153:348.840,setpts=PTS-STARTPTS[v1]; [0:a]atrim=153:348.840,asetpts=PTS-STARTPTS[a1]; [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" -map "[v]" -c:v libx265 -crf 22 -preset veryslow -map "[a]" -c:a libfdk_aac -b:a 128k result/"BigBuckBunny".mkv.

Case 3 (two source files, include meta data editing and short time stamps, see case 2):

ffmpeg -i source/BigBuckBunny.mp4 -i source/BigBuckBunny.mp4 -map_metadata -1 -metadata title="" -map_chapters -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -filter_complex "[0:v]trim=0:16.820,setpts=PTS-STARTPTS[v0]; [0:a]atrim=0:16.820,asetpts=PTS-STARTPTS[a0]; [1:v]trim=153:348.840,setpts=PTS-STARTPTS[v1]; [1:a]atrim=153:348.840,asetpts=PTS-STARTPTS[a1]; [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" -map "[v]" -c:v libx265 -crf 22 -preset veryslow -map "[a]" -c:a libfdk_aac -b:a 128k result/"BigBuckBunny".mkv.

Case 4 (two source files, without meta data editing and short time stamps, see case 2):

ffmpeg -i source/BigBuckBunny.mp4 -i source/BigBuckBunny.mp4 -filter_complex "[0:v]trim=0:16.820,setpts=PTS-STARTPTS[v0]; [0:a]atrim=0:16.820,asetpts=PTS-STARTPTS[a0]; [1:v]trim=153:348.840,setpts=PTS-STARTPTS[v1]; [1:a]atrim=153:348.840,asetpts=PTS-STARTPTS[a1]; [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" -map "[v]" -c:v libx265 -crf 22 -preset veryslow -map "[a]" -c:a libfdk_aac -b:a 128k result/"BigBuckBunny".mkv.

Case 5 (only one source file, without meta data editing and short time stamps, see case 2):

ffmpeg -i source/BigBuckBunny.mp4 -filter_complex "[0:v]trim=0:16.820,setpts=PTS-STARTPTS[v0]; [0:a]atrim=0:16.820,asetpts=PTS-STARTPTS[a0]; [1:v]trim=153:348.840,setpts=PTS-STARTPTS[v1]; [1:a]atrim=153:348.840,asetpts=PTS-STARTPTS[a1]; [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" -map "[v]" -c:v libx265 -crf 22 -preset veryslow -map "[a]" -c:a libfdk_aac -b:a 128k result/"BigBuckBunny".mkv.

The result of all five cases is always the same (except for the meta data). I get a result video file with a duration of 16.820 s, which means that only the first part from 0 s to 16.820 s is processed. If needed, I can provide for each case the output from the command line.

What am I doing wrong?

Thank you for your help and effort in advance!

Su-47
  • 139

0 Answers0