Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
809 views
in Technique[技术] by (71.8m points)

ubuntu - After merge videos, the duration is too long - ffmpeg

I have file txt with content

file intro.mp4
file video.mp4
file outtro.mp4

with duration by 10s, 178s, 13s.

I use ffmpeg to merge 3 files into one with below command:

ffmpeg -f concat -i "file.txt" -vcodec copy -acodec copy "endfile.mp4"

The duration of endfile.mp4 is longer 11 mins (660s).

I have a question that which params of video affect to merge? And which common params to merge another videos?

My English really too bad. Sorry for it :)
Good working this week!

P/S Details infor of files:

intro.mp4:

ffprobe version N-82885-g6d09d6e Copyright (c) 2007-2016 the FFmpeg developers<br>
    built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)<br>
    configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --<br>bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame<br> --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265<br>
    libavutil      55. 43.100 / 55. 43.100<br>
    libavcodec     57. 68.100 / 57. 68.100<br>
    libavformat    57. 61.100 / 57. 61.100<br>
    libavdevice    57.  2.100 / 57.  2.100<br>
    libavfilter     6. 68.100 /  6. 68.100<br>
    libswscale      4.  3.101 /  4.  3.101<br>
    libswresample   2.  4.100 /  2.  4.100<br>
    libpostproc    54.  2.100 / 54.  2.100<br>
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/intro.mp4':<br>
    Metadata:<br>
    major_brand     : isom<br>
    minor_version   : 512<br>
    compatible_brands: isomiso2avc1mp41<br>
    encoder         : Lavf56.23.100<br>
  Duration: 00:00:10.08, start: -0.013061, bitrate: 701 kb/s<br>
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)<br>
    Metadata:<br>
    handler_name    : SoundHandler<br>
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 853 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)<br>
  Metadata:<br>
    handler_name    : VideoHandler<br>

outtro.mp4:

ffprobe version N-82885-g6d09d6e Copyright (c) 2007-2016 the FFmpeg developers<br>
    built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)<br>
    configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --<br>bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame<br> --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265<br>
    libavutil      55. 43.100 / 55. 43.100<br>
    libavcodec     57. 68.100 / 57. 68.100<br>
    libavformat    57. 61.100 / 57. 61.100<br>
    libavdevice    57.  2.100 / 57.  2.100<br>
    libavfilter     6. 68.100 /  6. 68.100<br>
    libswscale      4.  3.101 /  4.  3.101<br>
    libswresample   2.  4.100 /  2.  4.100<br>
    libpostproc    54.  2.100 / 54.  2.100<br>
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/outtro.mp4':<br>
Metadata:<br>
    major_brand     : isom<br>
    minor_version   : 512<br>
    compatible_brands: isomiso2avc1mp41<br>
    encoder         : Lavf56.23.100<br>
Duration: 00:00:13.08, start: -0.013061, bitrate: 481 kb/s<br>
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)<br>
Metadata:<br>
    handler_name    : SoundHandler<br>
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 392 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)<br>
Metadata:<br>
    handler_name    : VideoHandler<br>

video.mp4

ffprobe version N-82885-g6d09d6e Copyright (c) 2007-2016 the FFmpeg developers<br>
    built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)<br>
    configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --<br>bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame<br> --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265<br>
    libavutil      55. 43.100 / 55. 43.100<br><br>
    libavcodec     57. 68.100 / 57. 68.100<br><br>
    libavformat    57. 61.100 / 57. 61.100<br><br>
    libavdevice    57.  2.100 / 57.  2.100<br><br>
    libavfilter     6. 68.100 /  6. 68.100<br><br>
    libswscale      4.  3.101 /  4.  3.101<br><br>
    libswresample   2.  4.100 /  2.  4.100<br><br>
    libpostproc    54.  2.100 / 54.  2.100<br><br>
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'path/to/video.mp4':<br>
    Metadata:<br>
        major_brand     : isom<br>
        minor_version   : 512<br>
        compatible_brands: isomiso2avc1mp41<br>
        encoder         : Lavf57.61.100<br>
    Duration: 00:02:58.38, start: 0.000000, bitrate: 922 kb/s<br>
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 782 kb/s, 29.97 fps, 29.97 tbr, 30k <br>tbn, 59.94 tbc (default)<br>
        Metadata:<br>
            handler_name    : VideoHandler<br>
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s (default)<br>
        Metadata:<br>
            handler_name    : SoundHandler<br>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The resolution, frames rates and timebase of the intro/outro and main videos don't match.

Convert your intro/outro like this and then concat:

ffmpeg -i intro.mp4 -s hd720 -r 30000/1001 -video_track_timescale 30k -c:a copy newintro.mp4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...