[FFmpeg-user] Cutting part of four files and concatenating

amindfv at mailbox.org amindfv at mailbox.org
Thu May 26 21:10:20 EEST 2022


On Thu, May 26, 2022 at 06:31:58PM +0200, Cecil Westerhof via ffmpeg-user wrote:
> I have to cut a part from four files and concatenate them together.
> At the moment I am doing that in the following way:
>     time ffmpeg -i 00250.MTS -i Pictures/reiger.jpg                                         \
>                 -ss 00:19 -to 02:41                                                         \
>                 -filter_complex "[0:v][1:v] overlay=W-w-10:10:enable='between(t, 73, 106)'" \
>                 -pix_fmt yuv420p -acodec copy -vcodec libx264 -preset veryfast -crf 26      \
>         hetOnmogelijkeDoen.mp4
>     time ffmpeg -y -i 00264.MTS     \
>                 -ss 00:08           \
>                 -to 00:17           \
>                 -acodec copy        \
>                 -vcodec libx264     \
>                 -preset veryfast    \
>                 audio1.mp4
>     time ffmpeg -y -i 00265.MTS     \
>                 -ss 00:04           \
>                 -to 00:17           \
>                 -acodec copy        \
>                 -vcodec libx264     \
>                 -preset veryfast    \
>                 audio2.mp4
>     time ffmpeg -y -i 00266.MTS     \
>                 -ss 00:06           \
>                 -to 00:15           \
>                 -acodec copy        \
>                 -vcodec libx264     \
>                 -preset veryfast    \
>                 audio3.mp4
>     time ffmpeg -y -i 00267.MTS     \
>                 -ss 00:08           \
>                 -to 00:16           \
>                 -acodec copy        \
>                 -vcodec libx264     \
>                 -preset veryfast    \
>                 audio4.mp4
>     time ffmpeg -y -i audio1.mp4 -i audio2.mp4 -i audio3.mp4 -i audio4.mp4  \
>                 -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a][3:v][3:a]
>                                  concat=n=4:v=1:a=1[v][a]"                  \
>                 -map "[v]" -map "[a]"                                       \
>                 -vcodec libx264 -preset veryfast                            \
>                 mergedAudio.mp4
> 
> I was wondering if this is the correct way to do this.
> I especially would like to know if it could be done in one swoop. Now
> the video is converted two times.


I don't know if it can be done in one fell swoop (and I'd love to know if that's possible!) but the last step might be possible to do without a re-encode with:

    $ cat combined.txt
    file '/home/foo/audio1.mp4'
    file '/home/foo/audio2.mp4'
    file '/home/foo/audio3.mp4'
    file '/home/foo/audio4.mp4'

    $ ffmpeg -y -f concat -safe 0 -i combined.txt -c copy mergedAudio.mp4

Tom


More information about the ffmpeg-user mailing list