[FFmpeg-user] Having problems combining multiple videos (concat)
Karen Norton
nortok00 at gmail.com
Fri Sep 22 00:56:07 EEST 2017
Hello all,
I'm looking for a little help combining some videos. Here's the situation.
I have two videos that were made using the same software and are identical
in nature (video resolution, fps, audio bitrate, codecs which are AVC/AAC,
etc.). I was able to put these together with concat and they turned out
perfect.
However I would like to add 5 seconds of black to the beginning as well as
between the segments and at the end but this isn't working so well. For
ease of testing I only put together 5 seconds of black at the beginning of
one of the video segments. Here's what I did:
1. Trimmed the first 6 seconds of one of the video segments using -ss to
get rid of some junk at the beginning. The resulting file is near perfect
however audio is slightly out of sync by about 1/2 a second (not sure if
this is causing problems with the final merged file). The exact command
line is:
ffmpeg -i input.mp4 -ss 00:00:06.433 -c:v libx264 -c:a aac -t 00:12:50.833
output.mp4 (I originally had -ss before -i as this is supposed to be faster
but after the -i is more accurate)
2. Downloaded a youtube video that is 5 seconds of black (you can get
everything from youtube). This file is a different resolution (720) while
my video is 1080 so I re-encoded it to be of the same format as my video
(or close to it)
3. I did the following command originally to bring the files together:
ffmpeg -f concat -i mylist.txt -c copy output.mp4
The text file pulls in:
- the re-encoded video that is 5 seconds of black (1920x1080)
- the first video segment
This command line finished quickly and everything merged together fine (no
errors or anything) however the 5 seconds of black ends up lasting for
about 10 seconds and the audio from the video segment rolls into the black
at about the 6 second mark and when the video actually appears it's all
jumpy and goes into slow motion. I assumed maybe this is because I just did
a -c copy so I then tried:
ffmpeg -f concat -i mylist.txt -c:v libx264 -c:a aac -b:a 128k -s 1920x1080
-r 30 output.mp4
This command line took awhile to finish (understandably) but the same
issues happen with the outputted video. The only difference is that I got
the message that says "More than 1000 frames duplicated" then "More than
10000 frames duplicated" part way through the encoding however the video
plays exactly the same (10 seconds of black with the audio from the video
segment rolling into the black at about 6 seconds and the actual video
portion is all wonky).
Here's are the details:
1. The main video file that has been trimmed (from mediainfo):
- 1920x1080
- Video: AVC, bit rate mode: constant, 30fps, frame rate mode: variable, 2
reference frames
- Audio: AAC, bit rate mode: *constant*, bit rate 128kb/s, 2 channels
*48khz*
Output of file:
ffmpeg version N-85588-g6108805 Copyright (c) 2000-2017 the FFmpeg
developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda
--enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx
--enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig
--enable-frei0r --enable-gnutls --enable-iconv --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype
--enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp
--enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 93.100 / 57. 93.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'quilting1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2017-09-18T02:25:33.000000Z
Duration: 00:12:50.80, start: 0.000000, bitrate: 10505 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
1920x1080 [SAR 1:1 DAR 16:9], 10369 kb/s, 30.01 fps, 60 tbr, 30k tbn, 59.94
tbc (default)
Metadata:
creation_time : 2017-09-18T02:25:33.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 130 kb/s (default)
Metadata:
creation_time : 2017-09-18T02:25:33.000000Z
handler_name : SoundHandler
2. The 5 seconds of black (which was re-encoded to match the above video
specs:
segment I'm using are (from mediainfo):
- 1920x1080
- Video: AVC, 30fps, frame rate mode: constant, 4 reference frames
- Audio: AAC, bit rate mode: *variable*, bit rate 128kb/s, 2 channels *41.1*
khz
Output of file:
ffmpeg version N-85588-g6108805 Copyright (c) 2000-2017 the FFmpeg
developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda
--enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx
--enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig
--enable-frei0r --enable-gnutls --enable-iconv --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype
--enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp
--enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 93.100 / 57. 93.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '5-seconds-black-1080-v2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.72.101
Duration: 00:00:05.09, start: 0.000000, bitrate: 31 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080 [SAR 1281:1280 DAR 427:240], 18 kb/s, 30 fps, 30 tbr, 15360 tbn,
60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 2 kb/s (default)
Metadata:
handler_name : SoundHandler
3. This is the output of the final video file that has gone all wonky:
ffmpeg version N-85588-g6108805 Copyright (c) 2000-2017 the FFmpeg
developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda
--enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx
--enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig
--enable-frei0r --enable-gnutls --enable-iconv --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype
--enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp
--enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 93.100 / 57. 93.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1b.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.72.101
Duration: 00:25:03.10, start: 0.000000, bitrate: 1663 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080 [SAR 1281:1280 DAR 427:240], 1586 kb/s, 30 fps, 30 tbr, 15360
tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 126 kb/s (default)
Metadata:
handler_name : SoundHandler
It seems to me this should be fairly easy as I'm not doing anything
complicated like cross fading,etc. Something is eluding me or I have to
re-encode the 5 seconds of black differently or possibly re-encode the
actual video file so it has a different format.
I'm hoping someone can help. If you need something from ffprobe from any of
the files let me know.
Thanks.
Karen
More information about the ffmpeg-user
mailing list