FFmpeg - Concatenate videos with not know format - shell

I am developing an application.
People upload videos from their mobile, from other places.
Using a CMS in PHP (it is the language with which the application is developed) I need to generate a unique video with these partial uploads.
Through FFmpeg I am doing tests, from the command line:
ffmpeg -i concat:IMG_1916.mp4\|IMG_1917.mp4 -c copy videoLoop.mp4
This code when I run it says:
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7f8515000000] Found duplicated MOOV Atom. Skipped it Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat:IMG_1916.mp4|IMG_1917.mp4':
Metadata:
encoder : Lavf57.66.102
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
Duration: 00:00:04.27, start: 0.000000, bitrate: 26792 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 11978 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 120 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, mp4, to 'videoLoop.mp4':
Metadata:
compatible_brands: isomiso2avc1mp41
major_brand : isom
minor_version : 512
encoder : Lavf57.56.101
Stream #0:0(und): Video: h264 (Constrained Baseline) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080, q=2-31, 11978 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, 120 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 127 fps=0.0 q=-1.0 Lsize= 6264kB time=00:00:04.22 bitrate=12142.8kbits/s speed= 376x
video:6196kB audio:63kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.076698%
This execution generates a video, but not concatenated with the 2 specified, only with the first one.
Why not join the 2?
The videos to upload, will be of very different formats so I can not define codec.

You will have to make all inputs similar before concatenation, then use the concat filter. A rough example (you will of course have to customize it to your needs):
ffmpeg -i input0 -i input1 -filter_complex \
"[0:v]fps=25,scale=1280:720,format=yuv420p,setsar=1,setpts=PTS-STARTPTS[v0]; \
[1:v]fps=25,scale=1280:720,format=yuv420p,setsar=1,setpts=PTS-STARTPTS[v1]; \
[0:a]aformat=channel_layouts=stereo:sample_rates=44100,asetpts=PTS-STARTPTS[a0]; \
[1:a]aformat=channel_layouts=stereo:sample_rates=44100,asetpts=PTS-STARTPTS[a1]; \
[v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" -c:v libx264 -c:a aac -movflags +faststart output.mp4

Using this adaptation of code, i can generate a video with two sources.
ffmpeg -i IMG_1916.mp4 -i IMG_1917.mp4 \
-filter_complex \
"[0:v:0] [0:a:0] \
[1:v:0] [1:a:0] \
concat=n=2:v=1:a=1 [v] [a]" \
-map "[v]" -map "[a]" videoLoop.mp4
I'm not sure if I can concatenate any video format, from any device of any source / format with this code.

Related

FFMPEG Multiple Filters (Scale Video + Scale / Apply Watermark)

Can someone please tell me the proper syntax for combining the following filters into a single command? I can't seem to figure it out.
The following command is being used to scale the video.
ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -vf scale="'if(gt(a,4/3),1280,-1)':'if(gt(a,4/3),-1,720)'" -movflags +faststart output.mp4 2>&1
Then, I use the following code to scale and apply the watermark.
ffmpeg -i input.mp4 -vf "movie=logo.png, scale=200:-1 [wm]; [in][wm] overlay=5:main_h-overlay_h-5 [out]" output.mp4 2>&1
They work fine independently but every attempt I've made to combine the filter commands has been unsuccessful. Some assistance would be appreciated.
LOG
# ffmpeg -i /var/www/html/site/public_html/media/input.mp4 \
> -i /var/www/html/site/public_html/media/logo.png \
> -c:v libx264 -preset medium -crf 23 -filter_complex "[0]scale='if(gt(a,4/3),1280,-1)':'if(gt(a,4/3),-1,720)'[main];[1]scale=200:-1[wm];[main][wm]overlay=5:main_h-overlay_h-5" -movflags +faststart \
> /var/www/html/site/public_html/media/output.mp4
ffmpeg version git-2015-04-08-b926f02 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/usr/bin --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-libtheora
libavutil 54. 22.101 / 54. 22.101
libavcodec 56. 34.100 / 56. 34.100
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 13.101 / 5. 13.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/site/public_html/media/input.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2021-10-17 22:26:58
Duration: 00:00:02.40, start: 0.047891, bitrate: 2614 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 81 kb/s (default)
Metadata:
creation_time : 2021-10-17 22:26:58
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 716x1280, 2521 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2021-10-17 22:26:58
handler_name : Core Media Data Handler
encoder : H.264
Input #1, png_pipe, from '/var/www/html/site/public_html/media/logo.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba, 468x100, 25 tbr, 25 tbn, 25 tbc
File '/var/www/html/site/public_html/media/output.mp4' already exists. Overwrite ? [y/N] y
[libx264 # 0x30008a0] width not divisible by 2 (403x720)
Output #0, mp4, to '/var/www/html/site/public_html/media/output.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 30 fps (default)
Metadata:
encoder : Lavc56.34.100 libx264
Stream #0:1(und): Audio: aac, 0 channels, 128 kb/s (default)
Metadata:
creation_time : 2021-10-17 22:26:58
handler_name : Core Media Data Handler
encoder : Lavc56.34.100 libfdk_aac
Stream mapping:
Stream #0:1 (h264) -> scale (graph 0)
Stream #1:0 (png) -> scale (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:0 -> #0:1 (aac (native) -> aac (libfdk_aac))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Combined command:
ffmpeg -i input.mp4 -i logo.png -c:v libx264 -preset medium -crf 23 -filter_complex "[0]scale='if(gt(a,4/3),1280,-2)':'if(gt(a,4/3),-2,720)'[main];[1]scale=200:-1[wm];[main][wm]overlay=5:main_h-overlay_h-5" -c:a copy -movflags +faststart output.mp4
See FFmpeg Filtering Intro.

Stream specifier in filtergraph description matches no streams [duplicate]

I am not getting why this isn't working.. I have tried to get the video streams with [0:v]/[0:1]/[0:v:0] & the audio streams with [0:a]/[0:0]/[0:0:0].
nothing worked.
Explaining the inputs:
1.1st input stream is a video that can be of varying resolution on which the filter adds a padding on to make it 600:480.
2.2nd input is an overlay png which is already at 5:4 ratio.. just making it 600:480 before it gets overlaid in the filter.
3.3rd & 4th ones are also videos which I don't care if they get stretched.. n they are getting stretched to 600:480.
4.so finally there are 3 streams 1 overlaid video 2 stretched videos which needs to be concatenated.
here's the command :
ffmpeg
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4'
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png'
-i '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4'
-i '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4'
-filter_complex
"[0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a]"
-map "[v]"
-map "[a]"
-c:v libx264
-shortest /home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_final.mp4
this is the complete error I am getting :
Stream specifier ':a' in filtergraph description [0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a] matches no streams.
also there are these warnings:
[Parsed_setsar_9 # 0x219fba0] num:den syntax is deprecated, please use num/den or named options instead
[Parsed_setsar_11 # 0x21a4840] num:den syntax is deprecated, please use num/den or named options instead
Complete log as requested :
[root#cloud ~]# ffmpeg -i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4' -i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png' -i '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4' -i '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4' -filter_complex \ "[0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 -shortest /home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_final.mp4
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libdc1394 --enable-libfaac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-08-21 02:23:24
Duration: 00:02:17.23, start: 0.000000, bitrate: 417 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 318 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
creation_time : 2017-08-21 02:23:24
handler_name : IsoMedia File Produced by Google, 5-11-2011
Input #1, png_pipe, from '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba, 600x479, 25 tbr, 25 tbn, 25 tbc
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2018-01-31 22:40:09
Duration: 00:00:04.90, start: 0.103811, bitrate: 846 kb/s
Stream #2:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 1920x1080, 827 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2018-01-31 22:40:10
handler_name : Core Media Video
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2018-01-31 22:40:09
Duration: 00:00:04.90, start: 0.103811, bitrate: 846 kb/s
Stream #3:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 1920x1080, 827 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2018-01-31 22:40:10
handler_name : Core Media Video
[Parsed_setsar_9 # 0x17c8ba0] num:den syntax is deprecated, please use num/den or named options instead
[Parsed_setsar_11 # 0x17cd840] num:den syntax is deprecated, please use num/den or named options instead
Stream specifier ':a' in filtergraph description [0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a] matches no streams.
Your other inputs don't have audio. A dummy audio has to be supplied.
ffmpeg \
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4' \
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png' \
-i '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4' \
-i '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4' \
-f lavfi -t 0.1 -i anullsrc \
-filter_complex \
"[0:v]trim=0:138,setpts=PTS-STARTPTS[v0]; \
[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0]; \
[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][4:a][z][a0][x1][4:a]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 -shortest /home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_final.mp4

FFmpeg Hardware Acceleration with NVENC produces Half Green output video

Using the FFmpeg build found here: https://github.com/illuspas/ffmpeg-hw-win32
gcc 5.3.0
--enable-nvenc nvidia_video_sdk_6.0.1
--enable-libmfx Intel(R)_Media_SDK_2016.0.1
--enable-libfdk-aac 0.1.4
--enable-libspeex 1.2rc1
--enable-libx264 1:148.20150725
--enable-libopenh264 1.5.0
--enable-libx265 1.8
--enable-libopus 1.1.2
--enable-libmp3lame 3.99.5
--enable-libkvazaar 0.8.2
./configure --prefix=/home/aliang/FFmpeg/x86_64 --enable-small --disable-debug --disable-doc --arch=x86_64 --cc='ccache x86_64-w64-mingw32-gcc' --cross-prefix=x86_64-w64-mingw32- --enable-cross-compile --target-os=mingw32 --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libspeex --enable-libx264 --enable-libx265 --enable-libmfx --enable-nvenc --enable-libopenh264 --enable-libkvazaar --enable-gpl --enable-nonfree
I'm running Windows on a MacBook Pro. I also tried with a more recent build and had the same output.
Input video is from sample-videos.com.
The ffmpeg command I am running is:
ffmpeg -y -i sample.mp4 -vcodec nvenc_h264 -pixel_format yuv420p -f mp4 sample-out-nvenc.mp4
sample-out-nvenc.mp4 looks like this via ffplay or vlc:
When I grab a frame using jpeg2, the colors appear normal, but the height is squished.
ffmpeg -y -ss 15.5 -i sample.mp4 -vframes 1 -s 480x300 -f image2 grab.jpg
The ffprobe results for the output (sample-out-nvenc.mp4):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample-out-nvenc.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:00:31.02, start: 0.021333, bitrate: 1994 kb/s
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3], 1650 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 342 kb/s (default)
Metadata:
handler_name : SoundHandler
Lastly the output from the nvenc encoding command:
ffmpeg -y -i sample.mp4 -vcodec nvenc_h264 -pixel_format yuv420p -f mp4 sample-out-nvenc.mp4
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --prefix=/home/aliang/FFmpeg/x86_64 --enable-small --disable-debug --disable-doc --arch=x86_64 --cc='ccache x86_64-w64-mingw32-gcc' --cross-prefix=x86_64-w64-mingw32- --enable-cross-compile --target-os=mingw32 --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libspeex --enable-libx264 --enable-libx265 --enable-libmfx --enable-nvenc --enable-libopenh264 --enable-libkvazaar --enable-gpl --enable-nonfree
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.24.2
Duration: 00:00:31.00, start: 0.000000, bitrate: 1353 kb/s
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 966 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
Output #0, mp4, to 'sample-out-nvenc.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Stream #0:0(und): Video: h264 (nvenc_h264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 2000 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
encoder : Lavc57.24.102 nvenc_h264
Side data:
unknown side data type 10 (24 bytes)
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, 5.1, fltp, 341 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
encoder : Lavc57.24.102 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (nvenc_h264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 774 fps=253 q=-0.0 Lsize= 7551kB time=00:00:30.99 bitrate=1995.6kbits/s speed=10.1x
video:6236kB audio:1297kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.243011%
[aac # 000001cdd9900520] Qavg: 743.457
I had exactly the same problem, with a GTX 980. This started after installing driver update 368.22. I downloaded and reverted to driver version 365.19 from the nividia driver archive and the problem went away.
So it appears to affect all nvidia cards and drivers.
I experienced the same problem with nvenc through another usecase. It seems to have been caused by the latest nvidia quadro driver. The problem was resolved when I reverted it. As you have a macbook, I guess it's fair to assume you don't have a quadro card, but it still might be a driver problem.

ffmpeg overlay video with transparent background

I have 2 videos: background (mp4) and overlay (mov), overlay has transparent background. I am trying to put video with transparent background as overlay on top of background video. But unfortunately overlay completely cover background video with black background instead of transparency.
I am using following command:
Here is the full output for the command:
ffmpeg -y -i rec_20151027_123445.mp4 -vf "[in]format=rgba[ina];movie=overlay_1920x1080_1.mov[o];[ina][o]overlay=0:0" -vcodec qtrle converted.mov
ffmpeg version 2.6 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rec_20151027_123445.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2015-10-27 10:34:57
location : +50.0474+036.2031/
location-eng : +50.0474+036.2031/
Duration: 00:00:06.04, start: 0.000000, bitrate: 16863 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 16837 kb/s, SAR 1:1 DAR 16:9, 29.62 fps, 29.75 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2015-10-27 10:34:57
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 95 kb/s (default)
Metadata:
creation_time : 2015-10-27 10:34:57
handler_name : SoundHandle
[swscaler # 0x7fa3db0ada00] No accelerated colorspace conversion found from yuva420p to argb.
Output #0, mov, to 'converted.mov':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
location-eng : +50.0474+036.2031/
location : +50.0474+036.2031/
encoder : Lavf56.25.101
Stream #0:0(eng): Video: qtrle (rle / 0x20656C72), argb, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.75 fps, 15232 tbn, 29.75 tbc (default)
Metadata:
creation_time : 2015-10-27 10:34:57
handler_name : VideoHandle
encoder : Lavc56.26.100 qtrle
Stream #0:1(eng): Audio: aac (libvo_aacenc) (mp4a / 0x6134706D), 48000 Hz, mono, s16, 128 kb/s (default)
Metadata:
creation_time : 2015-10-27 10:34:57
handler_name : SoundHandle
encoder : Lavc56.26.100 libvo_aacenc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> qtrle (native))
Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame= 179 fps= 19 q=0.0 Lsize= 126621kB time=00:00:06.05 bitrate=171213.2kbits/s dup=1 drop=1
video:126519kB audio:95kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005055%

ffmpeg - video processing - create transition with blank video

ffmpeg newbie here struggling to do something that apparently should be easy.
I want to concatenate three videos, being one of them just a blank video two seconds transition.
First I generate the blank video with:
ffmpeg -f lavfi -i color=c=black:s=320x240:d=0.5 silent.mp4
After I try to concat it with two other videos I have:
ffmpeg -i video-a.mp4 -i 2-seconds-silent-video.mp4 -i video-b.mp4 -y -filter_complex concat=n=3:v=1:a=1 result.mp4
What I'm getting:
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libvpx --enable-libfdk-aac --enable-libx265 --enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-a.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:03.03, start: 0.033333, bitrate: 822 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 691 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2-seconds-silent-video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:02.00, start: 0.000000, bitrate: 17 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 11 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'video-b.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:03.03, start: 0.033333, bitrate: 745 kb/s
Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 613 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
Cannot find a matching stream for unlabeled input pad 5 on filter Parsed_concat_0
What I also tried without success:
ffmpeg -y -i "concat:video-a.mp4|2-seconds-silent-video.mp4|video-b.mp4" -c copy result.mp4
Result:
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libvpx --enable-libfdk-aac --enable-libx265 --enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fd12a812800] Found duplicated MOOV Atom. Skipped it
Last message repeated 1 times
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat:video-a.mp4|2-seconds-silent-video.mp4|video-b.mp4':
Metadata:
encoder : Lavf56.40.101
minor_version : 512
major_brand : isom
compatible_brands: isomiso2avc1mp41
Duration: 00:00:03.03, start: 0.033333, bitrate: 1579 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 691 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[mp4 # 0x7fd12a033a00] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 # 0x7fd12a033a00] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'result.mp4':
Metadata:
compatible_brands: isomiso2avc1mp41
minor_version : 512
major_brand : isom
encoder : Lavf56.36.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 691 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 75 fps=0.0 q=-1.0 Lsize= 305kB time=00:00:03.05 bitrate= 818.1kbits/s
video:253kB audio:48kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.179313%
There's no audio stream when I generate my blank video. The solution is add a silent audio stream to the video:
ffmpeg -y -f lavfi -i anullsrc -i 2-seconds-silent-video.mp4 -shortest -c:v copy -c:a aac -strict experimental silent-video.mp4
answered here by #miindlek, thank you.
where I found the line above: adding silent audio in ffmpeg

Resources