This question already has an answer here:
How to concatenate videos in ffmpeg with different attributes?
(1 answer)
Closed 2 years ago.
I tried this command:
ffmpeg -f concat -i mylist.txt -c copy output.mp4
But output.mp4 has no audio.
mylist.txt contains:
file '1.mp4'
file '2.mp4'
Information about 1.mp4 and 2.mp4:
C:\Users\Admin\OneDrive\Desktop\New folder>ffmpeg -n -i 1.mp4 -i 2.mp4
ffmpeg version git-2020-05-23-26b4509 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 48.100 / 56. 48.100
libavcodec 58. 87.101 / 58. 87.101
libavformat 58. 43.100 / 58. 43.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 83.100 / 7. 83.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-05-31T08:12:56.000000Z
Duration: 00:00:05.93, start: 0.000000, bitrate: 186 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 184 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-05-31T08:21:56.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-06-01T03:32:58.000000Z
Duration: 00:00:12.23, start: 0.000000, bitrate: 1909 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1708 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-06-01T04:17:17.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 196 kb/s (default)
Metadata:
creation_time : 2020-06-01T04:17:17.000000Z
handler_name : SoundHandler
At least one output file must be specified
For concatenation to work:
According to the concat demuxer documentation:
Each input must have the same number of video and audio streams.
Each video and audio stream must have the same attributes.
Each input must have the same video and audio format.
What is wrong with your inputs
1.mp4 has no audio. 2.mp4 has audio.
1.mp4 needs audio to be able to concatenate to 2.mp4.
Solution
Add silent audio to 1.mp4 using anullsrc filter:
ffmpeg -i input.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -map 0:v -map 1:a -c:v copy -c:a aac -shortest 1b.mp4
Then update mylist.txt to:
file '1b.mp4'
file '2.mp4'
Finally run your ffmpeg command to concatenate:
ffmpeg -f concat -i mylist.txt -c copy -movflags +faststart output.mp4
Related
I try to concatenate two video files a.mov & b.mov on Win 10 using ffmpeg with the following command:
ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy c.mov
There are no errors displayed however when I open the resulting file c it has the same length as file a with the last frame appering to be a frame of b.
File a is a longer video, file b are credits (couple of seconds) made with ffmpeg from an image file.
Both files have the same aspect ratio, size and framerate.
I try to concatenate two video files a.mov & b.mov on Win 10 using ffmpeg with the following command:
ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy c.mov
There are no errors displayed however when I open the resulting file c it has the same length as file a with the last frame appering to be a frame of b.
File a is a longer video, file b are credits (couple of seconds) made with ffmpeg from an image file.
Both files have the same aspect ratio, size and framerate.
Here the log:
ffmpeg -n -i a.mov -i b.mov
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9.3.1 (GCC) 20200523 configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 /
58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 /
3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mov': Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.62.100 Duration: 00:31:50.04, start: 0.000000, bitrate: 5309 kb/s
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 4151 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : Core Media Video
encoder : Lavc58.54.100 libx264
Stream #0:1: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
Metadata:
handler_name : SoundHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'b.mov': Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.29.100 Duration: 00:00:10.01, start: 0.000000, bitrate: 67 kb/s
Stream #1:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 64 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.54.100 libx264
Thank you.
Problems
Your inputs have some different attributes, but they need to be the same to concatenate:
The timescales (30k vs 11988) are different. This is probably due to a.mov having 30000/1001 proper NTSC frame rate and b.mov is 29.97. ffprobe can confirm this. The ffmpeg output is for "entertainment purposes only" and reports an abbreviated frame rate.
a.mov has audio, but b.mov does not.
To fix it
Re-mux b.mov and add silent audio:
ffmpeg -i b.mov -f lavfi -i anullsrc=r=48000:cl=mono -c:v copy -c:a pcm_s24le -video_track_timescale 30k -shortest b2.mov
Then update list.txt with the new file (b2.mov).
Concatenate:
ffmpeg -safe 0 -f concat -i list.txt -c copy c.mov
Options
-f lavfi -i anullsrc=r=48000:cl=mono makes silent audio with 48000 sample rate and mono channel layout. This matches the sample rate and channel layout of a.mov. You can't concatenate an input with audio with an input that has no audio, so this just creates silent filler/dummy audio.
-c:v copy stream copy the video.
-c:a pcm_s24le chooses the encoder pcm_s24le to create an audio format that matches a.mov.
-video_track_timescale 30k sets video timescale to match a.mov. See What is video timescale, timebase, or timestamp in ffmpeg?
-shortest ends the output whenever the shortest input ends. Needed because I did not set a duration for anullsrc (using -shortest is easier).
I am trying to run the following command :
-i "2020_11_30_03_37_37.mp4" -i "2020_11_30_03_37_44.jpg" -f lavfi -t 6.016 -i anullsrc -filter_complex "[0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1[si];[si]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)'" "2020_11_30_03_37_50.mp4"
but FFmpeg throwing the following error:
Invalid stream specifier: si.
but I already specified this stream in command. unable to understand what's wrong
here is the log
C:\Users\abhis\AppData\Local\Packages\64815ZMobileApps.VideoDownloaderforYouTubeDownload_61cxy7b35vdsg\TempState>ffmpeg -i "2020_11_30_03_37_37.mp4" -i "2020_11_30_03_37_44.jpg" -f lavfi -t 6.016 -i anullsrc -filter_complex "[0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1[si];[si]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)'" "2020_11_30_03_37_50.mp4"
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --enable-librav1e --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2020_11_30_03_37_37.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:05.02, start: 0.000000, bitrate: 2097 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 544x960, 1997 kb/s, SAR 1:1 DAR 17:30, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandle
Input #1, image2, from '2020_11_30_03_37_44.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 2416762 kb/s
Stream #1:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x854 [SAR 200:200 DAR 640:427], 25 tbr, 25 tbn, 25 tbc
Input #2, lavfi, from 'anullsrc':
Duration: N/A, start: 0.000000, bitrate: 705 kb/s
Stream #2:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
[mov,mp4,m4a,3gp,3g2,mj2 # 00000279fa82eb80] Invalid stream specifier: si.
Last message repeated 1 times
Stream specifier 'si' in filtergraph description [0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1[si];[si]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)' matches no streams.
You can't re-use labels (a.k.a. "pads", unintuitively) from filter outputs. So you can't use si more than once.
Add the split filter to make copies:
-i "2020_11_30_03_37_37.mp4" -i "2020_11_30_03_37_44.jpg" -f lavfi -t 6.016 -i anullsrc -filter_complex "[0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1,split=outputs=2[si1][si2];[si1]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si2]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)'" "2020_11_30_03_37_50.mp4"
I had to reinstall windows 10 because windows. I have this exact same code working prior to the reinstall, however after I cant get it to work.
I am using the latest nvidia drivers 416.16
I have VisualStudio and Cuda Toolkit installed
2x 1080TIs
Using ffmpeg 4.0.2:
T:\ffmpeg\bin\4.0.2\ffmpeg.exe -c:v h264_cuvid -i "T:\Streams\01-ready\2018-10-10 21-19-21.mp4" -i "T:\Streams\10-source\kpg-logo.png" -filter_complex "overlay=10:10" -b:v 24000k -c:v h264_nvenc -c:a copy "T:\Streams\02-encoded\2018-10-10 21-19-21_watermarked.mp4"
Output:
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.1 (GCC) 20180722
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'T:\Streams\01-ready\2018-10-10 21-19-21.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.84.100
Duration: 00:28:41.71, start: 0.000000, bitrate: 24422 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/unknown/unknown), 2560x1440, 24130 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 286 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, png_pipe, from 'T:\Streams\10-source\kpg-logo.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 2560x1440 [SAR 2834:2834 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 (h264_cuvid) -> overlay:main
Stream #1:0 (png) -> overlay:overlay
overlay -> Stream #0:0 (h264_nvenc)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264_nvenc # 000002851a001940] CreateInputBuffer failed: out of memory (10)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Press any key to continue . . .
Error Message
[h264_nvenc # 000002851a001940] CreateInputBuffer failed: out of memory (10)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Press any key to continue . . .
Any ideas?
EDIT:
Still having issues, now even with the simple commands:
ffmpeg.exe -y -hwaccel cuvid -c:v h264_cuvid -i "input" -c:v h264_nvenc -preset slow "output.mp4"
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.1 (GCC) 20180722
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'T:\Streams\01-ready\2018-10-15 20-49-44.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.84.100
Duration: 00:00:10.64, start: 0.000000, bitrate: 22978 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/unknown), 2560x1440, 24216 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 156 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to 'T:\Streams\02-encoded\2018-10-15 20-49-44.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Stream #0:0(und): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), cuda, 2560x1440 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 60 fps, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.18.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.18.100 aac
[h264_cuvid # 000001a99033b600] ctx->cvdl->cuvidMapVideoFrame(ctx->cudecoder, parsed_frame.dispinfo.picture_index, &mapped_frame, &pitch, ¶ms) failed -> CUDA_ERROR_UNKNOWN: unknown error
Error while decoding stream #0:0: Generic error in an external library
/* repeated many many times */
[h264_nvenc # 000001a98fcfc100] Failed locking bitstream buffer: invalid param (8)
video encoding failed: Invalid argument
[aac # 000001a98fdcd380] Qavg: 64894.355
[aac # 000001a98fdcd380] 2 frames left in the queue on closing
Conversion failed!
Press any key to continue . . .
Full windows batch file:
#echo off
set ffmpegversion=20181015-c27c7b4-win64-static
set sourcedir=T:\Streams\01-ready
set outputdir=T:\Streams\02-encoded
set finaldir=T:\ffmpeg\mp4-upload
set libdir=T:\ffmpeg\bin\%ffmpegversion%
set introvid=T:\Streams\10-source\kpg-intro-10pec-audio.mp4
set watermark=T:\Streams\10-source\kpg-logo.png
set introvidlen=3.00
set outputbitrate=24000
cd /d %libdir%
if not exist %outputdir% (
mkdir %outputdir%
)
if not exist %finaldir% (
mkdir %finaldir%
)
setlocal enabledelayedexpansion
#echo Checking %sourcedir%\*.mp4
for %%f in (%sourcedir%\*.mp4) do (
if not exist "%outputdir%\%%~nf_watermarked.mp4" (
%libdir%\ffmpeg.exe -i "%%f" -i "%watermark%" -filter_complex "overlay=0:0" -b:v %outputbitrate%k -s 2560x1440 -pix_fmt yuv420p -c:a copy "%outputdir%\%%~nf_watermarked.mp4"
TIMEOUT 2
)
if not exist "%outputdir%\%%~nf_watermarked_ready.mp4" (
%libdir%\ffmpeg.exe -i "%introvid%" -i "%outputdir%\%%~nf_watermarked.mp4" -an -filter_complex " [0:v]trim=start=0:end=%introvidlen%,setpts=PTS-STARTPTS[firstclip]; [1:v]trim=start=1,setpts=PTS-STARTPTS[secondclip]; [0:v]trim=start=%introvidlen%,setpts=PTS-STARTPTS[fadeoutsrc]; [1:v]trim=start=0:end=1,setpts=PTS-STARTPTS[fadeinsrc]; [fadeinsrc]format=pix_fmts=yuva420p, fade=t=in:st=0:d=1:alpha=1[fadein]; [fadeoutsrc]format=pix_fmts=yuva420p, fade=t=out:st=0:d=1:alpha=1[fadeout]; [fadein]fifo[fadeinfifo]; [fadeout]fifo[fadeoutfifo];[fadeoutfifo][fadeinfifo]overlay[crossfade]; [firstclip][crossfade][secondclip]concat=n=3[output]; [0:a][1:a] acrossfade=d=1 [audio]" -map "[output]" -map "[audio]" -c:v libx264 -c:a aac -b:v %outputbitrate%k -ar 44100 -ab 96k -sn "%outputdir%\%%~nf_watermarked_ready.mp4"
TIMEOUT 2
)
if not exist "%finaldir%\%%~nf.mp4" (
COPY "%outputdir%\%%~nf_watermarked_ready.mp4" "%finaldir%\%%~nf.mp4"
TIMEOUT 2
)
)
PAUSE
Experienced similar results when other processes were running that had access the the video card. Just having the programs open(not actively encoding or otherwise requiring hardware acceleration) caused a conflict.
can you help me split 2 videos
enter image description here
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]vstack[v];[0:a][1:a]amerge=inputs=2[a]" -map "[v]" -map "[a]" -ac 2 output.mp4
Don't work
My complete log
C:\Users\forumrulez\Desktop\POST>ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]vstack[v];[0:a][1:a]amerge=inputs=2[a]" -map "[v]" -map "[a]" -ac 2 output.mp4
ffmpeg version N-91447-g0bd48ab2d9 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.1 (GCC) 20180709
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 21.104 / 58. 21.104
libavformat 58. 17.101 / 58. 17.101
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 25.100 / 7. 25.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.17.101
Duration: 00:01:00.08, start: 0.000000, bitrate: 586 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 260x480 [SAR 128:39 DAR 16:9], 428 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 152 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.17.101
Duration: 00:01:00.08, start: 0.000000, bitrate: 703 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 360x480 [SAR 64:27 DAR 16:9], 545 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 152 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 (h264) -> vstack:input0
Stream #0:1 (aac) -> amerge:in0
Stream #1:0 (h264) -> vstack:input1
Stream #1:1 (aac) -> amerge:in1
vstack -> Stream #0:0 (libx264)
amerge -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_amerge_1 # 00000165b1e6af00] No channel layout for input 1
[Parsed_amerge_1 # 00000165b1e6af00] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
[Parsed_vstack_0 # 00000165b29f1040] Input 1 width 360 does not match input 0 width 260.
[Parsed_vstack_0 # 00000165b29f1040] Failed to configure output pad on Parsed_vstack_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!
I have two files with multiple streams in each.
Output.mp4 has 2 streams: video and audio (streams 0,1)
Input.mp4 has 3 streams: video, audio and data (streams 0,1,2)
I need to add stream 2 from Input.mp4 to Output.mp4 yielding Final.mov.
I tried using this command but it does seem to preserve the format and metadata for the stream that is added:
ffmpeg -y -i Output.mp4 -i Input.mp4 -c copy -map 0:0 -map 0:1 -map 1:2 Final.mov
The output from ffmpeg seems to show that it is working but the format and metadata for the streams in the Final.mov is not correct.
I would appreciate any help with how to change the command to make it work.
Thank you!
Here is the command output:
ffmpeg -y -i Output.mp4 -i Input.mp4 -c copy -map 0:0 -map 0:1 -map 1:2 Final.mov
ffmpeg version N-84679-gd65b595 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. 51.100 / 55. 51.100
libavcodec 57. 86.103 / 57. 86.103
libavformat 57. 67.100 / 57. 67.100
libavdevice 57. 3.101 / 57. 3.101
libavfilter 6. 78.100 / 6. 78.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Output.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2018-04-15T21:57:13.000000Z
Duration: 00:24:25.05, start: 0.000000, bitrate: 3571 kb/s
Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 7680x3840 [SAR 1:1 DAR 2:1], 3252 kb/s, 1 fps, 1 tbr, 100k tbn, 2.15 tbc (default)
Metadata:
creation_time : 2018-04-15T21:57:13.000000Z
handler_name : Alias Data Handler
encoder : HEVC Coding
Side data:
stereo3d: 2D
spherical: equirectangular (0.000000/0.000000/0.000000)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2018-04-15T21:57:13.000000Z
handler_name : Alias Data Handler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'Input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
creation_time : 2018-04-12T12:02:32.000000Z
make : Insta360
model : Insta360 Pro
encoder : Lavf57.71.100
description : {"info":{"gyro_stabilized":false,"initial_view_changed":false}}
Duration: 00:24:25.00, start: -0.004233, bitrate: 6394 kb/s
Stream #1:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 7680x3840, 6196 kb/s, 1 fps, 1 tbr, 360k tbn, 5 tbc (default)
Metadata:
creation_time : 2018-04-12T12:02:32.000000Z
handler_name : VideoHandler
Side data:
stereo3d: 2D
spherical: equirectangular (0.000000/0.000000/0.000000)
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 4.0, fltp, 129 kb/s (default)
Metadata:
creation_time : 2018-04-12T12:02:32.000000Z
handler_name : SoundHandler
Stream #1:2(und): Data: none (camm / 0x6D6D6163), 36 kb/s
Metadata:
creation_time : 2018-04-12T12:02:32.000000Z
handler_name : CameraMetadataMotionHandler
Output #0, mov, to 'Final.mov':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
encoder : Lavf57.67.100
Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 7680x3840 [SAR 1:1 DAR 2:1], q=2-31, 3252 kb/s, 1 fps, 1 tbr, 100k tbn, 100k tbc (default)
Metadata:
creation_time : 2018-04-15T21:57:13.000000Z
handler_name : Alias Data Handler
encoder : HEVC Coding
Side data:
stereo3d: 2D
spherical: equirectangular (0.000000/0.000000/0.000000)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2018-04-15T21:57:13.000000Z
handler_name : Alias Data Handler
Stream #0:2(und): Data: none (camm / 0x6D6D6163), 36 kb/s
Metadata:
creation_time : 2018-04-12T12:02:32.000000Z
handler_name : CameraMetadataMotionHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #1:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
[mov # 0000000004894f00] Unknown hldr_type for camm / 0x6D6D6163, writing dummy valuesd= 629x
frame= 1465 fps=625 q=-1.0 Lsize= 650825kB time=00:24:24.98 bitrate=3639.3kbits/s speed= 625x
video:581593kB audio:56757kB subtitle:0kB other streams:6602kB global headers:0kB muxing overhead: 0.910633%
Here are the streams in the Final.mp4 file:
ffmpeg -i Final.mov
ffmpeg version N-84679-gd65b595 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. 51.100 / 55. 51.100
libavcodec 57. 86.103 / 57. 86.103
libavformat 57. 67.100 / 57. 67.100
libavdevice 57. 3.101 / 57. 3.101
libavfilter 6. 78.100 / 6. 78.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000000002726860] overread end of atom 'stsd' by 2974416 bytes
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Final.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf57.67.100
Duration: 00:24:25.00, start: 0.000000, bitrate: 3639 kb/s
Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 7680x3840 [SAR 1:1 DAR 2:1], 3252 kb/s, 1 fps, 1 tbr, 100k tbn, 2.15 tbc (default)
Metadata:
handler_name : DataHandler
encoder : HEVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
handler_name : DataHandler
Stream #0:2(eng): Data: none (stts / 0x73747473), 36 kb/s
Metadata:
handler_name : DataHandler