0

I have been trying to concatenate two 48 seconds video bits to one using the following command

 ffmpeg -f concat -safe 0 -i C:\moviepy-master\concat.txt -c copy output.mp4 

When I played it using Windows media player the first 48 second plays fine but the player closes before playing the second bit .

Then I tried to play it using VLC media player but in the second bit player but the audio and video are not in sync .

Then I also tried giving inputs separately so the following error shows up

 C:\Users\SAMHITA VVNK>ffmpeg -f concat -safe 0 -i C:\moviepy-master\extract1.mp4 -i C:\moviepy-master\extract2.mp4 -c copy -flags +global_header output.mp4 ffmpeg version N-86723-g3b3501f Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7.1.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --e nable-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-li bfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug - -enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enabl e-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-li bsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolam e --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. 67.100 / 55. 67.100 libavcodec 57.100.103 / 57.100.103 libavformat 57. 75.100 / 57. 75.100 libavdevice 57. 7.100 / 57. 7.100 libavfilter 6. 94.100 / 6. 94.100 libswscale 4. 7.101 / 4. 7.101 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 C:\moviepy-master\extract1.mp4: Invalid data found when processing input 

These are the input file's specifications are as follows C:\Users\SAMHITA VVNK>ffmpeg -i C:\moviepy-master\extract.mp4 -filter_complex "[ 0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0" -map "[a]" extract1fast.mp4

 C:\Users\SAMHITA VVNK>ffmpeg -i C:\moviepy-master\extract2.mp4 -i C:\moviepy-mas ter\extract1.mp4 ffmpeg version N-86723-g3b3501f Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7.1.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --e nable-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-li bfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug - -enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enabl e-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-li bsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolam e --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. 67.100 / 55. 67.100 libavcodec 57.100.103 / 57.100.103 libavformat 57. 75.100 / 57. 75.100 libavdevice 57. 7.100 / 57. 7.100 libavfilter 6. 94.100 / 6. 94.100 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 'C:\moviepy-master\extract2.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.56.101 Duration: 00:00:49.00, start: 0.012993, bitrate: 785 kb/s Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu v420p(tv, smpte170m/smpte170m/bt709), 640x360, 668 kb/s, 29.97 fps, 29.97 tbr, 1 1988 tbn, 23976 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 137 kb/s (default) Metadata: handler_name : SoundHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\moviepy-master\extract1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.56.101 Duration: 00:00:49.00, start: 0.012993, bitrate: 526 kb/s Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [ SAR 1:1 DAR 16:9], 462 kb/s, 24.86 fps, 24.86 tbr, 19888 tbn, 49.72 tbc (default ) Metadata: handler_name : VideoHandler Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt p, 95 kb/s (default) Metadata: handler_name : SoundHandler 
3
  • Run ffmpeg -i input1 -i input2 then edit your question to add the complete console output from that command. Commented Jul 18, 2017 at 18:38
  • I did and the error the above error shows up. Commented Jul 19, 2017 at 2:19
  • Run ffmpeg -i C:\moviepy-master\extract1.mp4 -i C:\moviepy-master\extract2.mp4 and show the output. It will show useful info about both inputs. Commented Jul 19, 2017 at 2:53

1 Answer 1

1

Your inputs vary in frame rate, H.264 profile, and audio channels, but the concat demuxer requires that everything be the same. Conform everything to similar parameters before using the concat demuxer, or use the concat filter instead.

Basic example:

ffmpeg -i input0.mp4 -i input1.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" output.mp4 

This will rely on the defaults of the concat filter which will automatically choose a common pixel format for video streams, and a common sample format, sample rate and channel layout for audio streams. These "common" parameters will, of course, vary depending on your inputs, so it may be advisable to prefix the concat filter with other filters to conform everything if you want consistent results.

Advanced example:

ffmpeg -i input0.mp4 -i input1.mp4 -filter_complex "[0:v]fps=25,format=yuv420p,setpts=PTS-STARTPTS[v0];[0:a]aformat=sample_rates=44100:channel_layouts=stereo,asetpts=PTS-STARTPTS[a0];[1:v]fps=25,format=yuv420p,setpts=PTS-STARTPTS[v1];[1:a]aformat=sample_rates=44100:channel_layouts=stereo,asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1" -movflags +faststart output.mp4 
Sign up to request clarification or add additional context in comments.

3 Comments

The size of my videos are about 60 minutes long and this process is slow ,is there a way to do it faster than this
Plus is there any documentation that i could refer to for the same , as in reading the parameters of the video .
@Samhitavempatti To increase encoding speed use a faster x264 encoding preset. Or just re-encode only the segment(s) with incorrect parameters and join using concat demuxer in stream copy mode (-c copy). For reading parameters see ffprobe documentation and examples.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.