FFmpeg scaling issue - ffmpeg

I am trying to down scale a video from 607x1080 to 440 width with the height automatically being calculated using the following command. It does scale the video but not to the specified dimension. The video is scaled to 216x384 even though the output below indicates 440x384.
ffmpeg -i video.mp4 -vf scale=440:-2 -c:v libx264 -c:a aac -y video-out.mp4
The output is as follows:
ffmpeg version N-87043-gf0f48884b0-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.4.0 (Debian 6.4.0-2) 20170724
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
libavutil 55. 74.100 / 55. 74.100
libavcodec 57.103.100 / 57.103.100
libavformat 57. 77.100 / 57. 77.100
libavdevice 57. 7.101 / 57. 7.101
libavfilter 6.100.100 / 6.100.100
libswscale 4. 7.103 / 4. 7.103
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2017-12-13T19:49:15.000000Z
encoder : HandBrake 1.0.7 2017040900
Duration: 00:00:04.37, start: 0.000000, bitrate: 10080 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1238x1080 [SAR 27:55 DAR 619:1100], 10244 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2017-12-13T19:49:15.000000Z
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default)
Metadata:
creation_time : 2017-12-13T19:49:15.000000Z
handler_name : Stereo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x5aef920] using SAR=1215/2474
[libx264 # 0x5aef920] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x5aef920] profile High, level 2.2
[libx264 # 0x5aef920] 264 - core 152 r19 ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'video-out.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.77.100
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 440x384 [SAR 7428:15125 DAR 619:1100], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
creation_time : 2017-12-13T19:49:15.000000Z
handler_name : VideoHandler
encoder : Lavc57.103.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2017-12-13T19:49:15.000000Z
handler_name : Stereo
encoder : Lavc57.103.100 aac
frame= 121 fps=0.0 q=29.0 size= 0kB time=00:00:04.33 bitrate= 0.1kbits/s speed=8.65x
frame= 129 fps=0.0 q=-1.0 Lsize= 255kB time=00:00:04.37 bitrate= 478.0kbits/s speed=6.81x
video:248kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.344491%
[libx264 # 0x5aef920] frame I:1 Avg QP:22.07 size: 5065
[libx264 # 0x5aef920] frame P:52 Avg QP:23.68 size: 4248
[libx264 # 0x5aef920] frame B:76 Avg QP:24.30 size: 361
[libx264 # 0x5aef920] consecutive B-frames: 12.4% 20.2% 20.9% 46.5%
[libx264 # 0x5aef920] mb I I16..4: 13.1% 81.7% 5.2%
[libx264 # 0x5aef920] mb P I16..4: 2.1% 5.2% 1.5% P16..4: 36.4% 12.2% 8.2% 0.0% 0.0% skip:34.4%
[libx264 # 0x5aef920] mb B I16..4: 0.2% 0.2% 0.1% B16..8: 16.3% 1.3% 0.2% direct: 0.5% skip:81.2% L0:42.2% L1:52.1% BI: 5.8%
[libx264 # 0x5aef920] 8x8 transform intra:62.0% inter:70.3%
[libx264 # 0x5aef920] coded y,uvDC,uvAC intra: 52.3% 45.2% 20.0% inter: 13.3% 10.0% 2.6%
[libx264 # 0x5aef920] i16 v,h,dc,p: 17% 48% 11% 24%
[libx264 # 0x5aef920] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 8% 35% 23% 5% 3% 2% 6% 3% 14%
[libx264 # 0x5aef920] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 8% 29% 16% 6% 7% 4% 12% 4% 14%
[libx264 # 0x5aef920] i8c dc,h,v,p: 64% 26% 7% 2%
[libx264 # 0x5aef920] Weighted P-Frames: Y:32.7% UV:5.8%
[libx264 # 0x5aef920] ref P L0: 55.7% 22.1% 15.8% 5.8% 0.7%
[libx264 # 0x5aef920] ref B L0: 77.8% 15.9% 6.3%
[libx264 # 0x5aef920] ref B L1: 97.6% 2.4%
[libx264 # 0x5aef920] kb/s:471.40
[aac # 0x5b7e180] Qavg: 65536.000
I did some searching and learned this may be an issue scaling with libx264 codec and the input width being an odd number? If so, is there a workaround so get the video to scale to the specified size? Thank you.

The scaling is "correct", but the video has a pixel or sample aspect ratio below 1 (27:55 ~= 0.491) so the video's effective display ratio is not the same as the ratio of width to height of the stored pixels.
Use the -vf expression below
-vf scale=440:2*trunc(ow/dar/2),setsar=1
Besides the scale, I reset the SAR to 1.

Related

FFMPEG - latest build doesn't work, earlier build does

I have been using FFMPEG to overlay coloured rectangles on a video. I updated FFMPEG and it no longer works. No error is issued, it just doesn't do the job - the resulting video is the same as the input video. Here's the script:
FFMpeg -y -i Input.mp4 -filter_complex \
"nullsrc=size=1920x1080, \
drawbox=x=200:y=100:w=300:h=150:t=20:c=yellow, fade=in:st=10:d=1:alpha=1, fade=out:st=20:d=2:alpha=1 [tmp1]; \
nullsrc=size=1920x1080, \
drawbox=x=240:y=140:w=300:h=150:t=20:c=red, fade=in:st=15:d=1:alpha=1, fade=out:st=25:d=2:alpha=1 [tmp2]; \
[tmp1][tmp2] overlay=0:0:shortest=1[tmp3]; \
[0:v][tmp3] overlay=0:0:shortest=1" \
Output.mp4
The output video should be the input video with a yellow rectangle added from T=10 to T=20 and a red rectangle from T=15 to T=25, fading them in and out.
The version that was working (3.4) was one that came with an ImageMagick installation. The version I updated it to was 4.2.3. I tried it on various other builds I had lying around and it only works with 3.4.
It seems unlikely that this is a regression so I haven't submitted a bug report. I figure it's more likely that I'm not doing something correctly and 3.4 is more lenient on its interpretation of my command.
Whatever, I prefer to be working with a current build, so I invite comments on what the reasons might be.
Console dump of 3.4 run
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:01:48.67, start: 0.000000, bitrate: 1693 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1562 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
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 000001f0d4a0e6a0] using SAR=1/1
[libx264 # 000001f0d4a0e6a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001f0d4a0e6a0] profile High, level 4.0
[libx264 # 000001f0d4a0e6a0] 264 - core 152 r2851 ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Output-34.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 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 : Lavc57.107.100 aac
frame= 3260 fps= 25 q=-1.0 Lsize= 21461kB time=00:01:48.56 bitrate=1619.3kbits/s speed=0.828x
video:19713kB audio:1634kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.534457%
[libx264 # 000001f0d4a0e6a0] frame I:14 Avg QP:17.68 size:208205
[libx264 # 000001f0d4a0e6a0] frame P:844 Avg QP:21.55 size: 16867
[libx264 # 000001f0d4a0e6a0] frame B:2402 Avg QP:28.40 size: 1263
[libx264 # 000001f0d4a0e6a0] consecutive B-frames: 0.7% 2.9% 0.4% 96.0%
[libx264 # 000001f0d4a0e6a0] mb I I16..4: 14.0% 39.6% 46.4%
[libx264 # 000001f0d4a0e6a0] mb P I16..4: 0.4% 0.7% 0.2% P16..4: 20.2% 9.1% 4.6% 0.0% 0.0% skip:64.8%
[libx264 # 000001f0d4a0e6a0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 12.4% 0.4% 0.1% direct: 0.1% skip:87.1% L0:42.9% L1:55.2% BI: 1.9%
[libx264 # 000001f0d4a0e6a0] 8x8 transform intra:45.2% inter:68.3%
[libx264 # 000001f0d4a0e6a0] coded y,uvDC,uvAC intra: 64.4% 81.6% 45.1% inter: 2.9% 4.2% 0.1%
[libx264 # 000001f0d4a0e6a0] i16 v,h,dc,p: 32% 26% 6% 37%
[libx264 # 000001f0d4a0e6a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 20% 15% 5% 6% 7% 7% 7% 8%
[libx264 # 000001f0d4a0e6a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 28% 8% 4% 6% 6% 6% 5% 5%
[libx264 # 000001f0d4a0e6a0] i8c dc,h,v,p: 37% 25% 28% 10%
[libx264 # 000001f0d4a0e6a0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 000001f0d4a0e6a0] ref P L0: 70.4% 15.3% 10.8% 3.5%
[libx264 # 000001f0d4a0e6a0] ref B L0: 93.1% 6.0% 0.9%
[libx264 # 000001f0d4a0e6a0] ref B L1: 97.8% 2.2%
[libx264 # 000001f0d4a0e6a0] kb/s:1486.03
[aac # 000001f0d4a10a20] Qavg: 1586.609
And 4.2.3
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 'Input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:01:48.67, start: 0.000000, bitrate: 1693 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1562 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
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 000001e7b4531d40] using SAR=1/1
[libx264 # 000001e7b4531d40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001e7b4531d40] profile High, level 4.0, 4:2:0, 8-bit
[libx264 # 000001e7b4531d40] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Output-423.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 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.54.100 aac
frame= 3260 fps= 28 q=-1.0 Lsize= 21425kB time=00:01:48.56 bitrate=1616.7kbits/s speed=0.917x
video:19686kB audio:1625kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.535352%
[libx264 # 000001e7b4531d40] frame I:14 Avg QP:17.68 size:208355
[libx264 # 000001e7b4531d40] frame P:844 Avg QP:21.54 size: 16838
[libx264 # 000001e7b4531d40] frame B:2402 Avg QP:28.43 size: 1261
[libx264 # 000001e7b4531d40] consecutive B-frames: 0.7% 2.9% 0.4% 96.0%
[libx264 # 000001e7b4531d40] mb I I16..4: 13.9% 39.7% 46.4%
[libx264 # 000001e7b4531d40] mb P I16..4: 0.4% 0.7% 0.2% P16..4: 20.2% 9.1% 4.6% 0.0% 0.0% skip:64.8%
[libx264 # 000001e7b4531d40] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 12.4% 0.4% 0.1% direct: 0.1% skip:87.1% L0:42.9% L1:55.2% BI: 1.9%
[libx264 # 000001e7b4531d40] 8x8 transform intra:45.3% inter:68.3%
[libx264 # 000001e7b4531d40] coded y,uvDC,uvAC intra: 65.2% 82.4% 45.8% inter: 2.9% 4.2% 0.1%
[libx264 # 000001e7b4531d40] i16 v,h,dc,p: 32% 24% 6% 38%
[libx264 # 000001e7b4531d40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 19% 14% 5% 6% 7% 7% 7% 8%
[libx264 # 000001e7b4531d40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 28% 8% 4% 6% 6% 6% 5% 5%
[libx264 # 000001e7b4531d40] i8c dc,h,v,p: 37% 24% 28% 11%
[libx264 # 000001e7b4531d40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 000001e7b4531d40] ref P L0: 70.4% 15.3% 10.8% 3.5%
[libx264 # 000001e7b4531d40] ref B L0: 93.1% 6.0% 0.9%
[libx264 # 000001e7b4531d40] ref B L1: 97.8% 2.2%
[libx264 # 000001e7b4531d40] kb/s:1483.98
[aac # 000001e7b47fa800] Qavg: 1462.566
There was a bug in the drawbox filter whereby the source alpha pixels would be replaced with the drawbox color's alpha (usually opaque) instead of preserving or blending it. Your command relies on that remaining the case, but I changed that after 3.4 series, so you now have to tell drawbox to replace the alpha for the box pixels.
So,
drawbox=x=200:y=100:w=300:h=150:t=20:c=yellow:replace=1
and
drawbox=x=240:y=140:w=300:h=150:t=20:c=red:replace=1

FFmpeg wrong duration(double) when convert mp4

The output file has the double duration :
Source video duration :00:01:58.88
output video duration :00:03:57.76
(video's duration is double ,audio's duration is correct. So, the video looks like played twice, with no sound in the second half )
here is the log:
./ffmpeg -i /Volumes/LANKEXIN/1383.mp4 out.mp4
ffmpeg version N-82977-g8fd3e02-tessus Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
libavutil 55. 43.100 / 55. 43.100
libavcodec 57. 70.100 / 57. 70.100
libavformat 57. 61.100 / 57. 61.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.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 '/Volumes/LANKEXIN/1383.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isom
creation_time : 2017-10-30T14:58:05.000000Z
encoder : mp4creator 1.6.1d
Duration: 00:01:58.88, start: 0.000000, bitrate: 1918 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1729 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-10-30T14:58:05.000000Z
encoder : VC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2017-10-30T14:58:05.000000Z
File 'out.mp4' already exists. Overwrite ? [y/N] y
[libx264 # 0x7fbaca003c00] using SAR=1/1
[libx264 # 0x7fbaca003c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x7fbaca003c00] profile High, level 3.1
[libx264 # 0x7fbaca003c00] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isom
encoder : Lavf57.61.100
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 2017-10-30T14:58:05.000000Z
encoder : Lavc57.70.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2017-10-30T14:58:05.000000Z
encoder : Lavc57.70.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 46 fps=0.0 q=0.0 size= 0kB time=00:00:00.93 bitrate= 0.0kbits/sframe= 64 fps= 45 q=28.0 size= 137kB time=00:00:01.66 bitrate= 672.2kbits/frame= 85 fps= 44 qframe= 5944 fps= 33 q=-1.0 Lsize= 38746kB time=00:03:57.64 bitrate=1335.7kbits/s speed=1.33x 4kB time=00:00:02.94 bitrate= 818.0kbits/s speed= 1.2x
video:36779kB audio:1846kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.311413%
[libx264 # 0x7fbaca003c00] frame I:24 Avg QP:19.49 size: 67090
[libx264 # 0x7fbaca003c00] frame P:1806 Avg QP:21.65 size: 14304
[libx264 # 0x7fbaca003c00] frame B:4114 Avg QP:25.42 size: 2484
[libx264 # 0x7fbaca003c00] consecutive B-frames: 2.2% 8.1% 25.5% 64.2%
[libx264 # 0x7fbaca003c00] mb I I16..4: 20.6% 55.8% 23.6%
[libx264 # 0x7fbaca003c00] mb P I16..4: 5.2% 9.3% 0.8% P16..4: 36.0% 9.9% 4.2% 0.0% 0.0% skip:34.5%
[libx264 # 0x7fbaca003c00] mb B I16..4: 0.5% 1.0% 0.0% B16..8: 27.2% 1.8% 0.2% direct: 0.9% skip:68.5% L0:48.6% L1:47.6% BI: 3.8%
[libx264 # 0x7fbaca003c00] 8x8 transform intra:60.9% inter:78.2%
[libx264 # 0x7fbaca003c00] coded y,uvDC,uvAC intra: 38.3% 61.5% 12.3% inter: 6.6% 11.3% 0.6%
[libx264 # 0x7fbaca003c00] i16 v,h,dc,p: 22% 35% 10% 33%
[libx264 # 0x7fbaca003c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 24% 21% 5% 6% 6% 6% 5% 6%
[libx264 # 0x7fbaca003c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 33% 11% 4% 7% 6% 6% 4% 4%
[libx264 # 0x7fbaca003c00] i8c dc,h,v,p: 43% 30% 20% 7%
[libx264 # 0x7fbaca003c00] Weighted P-Frames: Y:0.3% UV:0.2%
[libx264 # 0x7fbaca003c00] ref P L0: 73.5% 9.0% 13.8% 3.7% 0.0%
[libx264 # 0x7fbaca003c00] ref B L0: 92.4% 6.6% 1.1%
[libx264 # 0x7fbaca003c00] ref B L1: 97.7% 2.3%
[libx264 # 0x7fbaca003c00] kb/s:1267.21
[aac # 0x7fbaca021800] Qavg: 897.576

Video and audio stretch calculations in ffmpeg

I'm doing some extreme slow motion in ffmpeg on a video, both video and audio track, but can't quite get my calculations correct.
The input video is 00:06:41:00 at 24fps (9624 frames).
I need the output video to be 34:00:00:00 at 24fps (2937600 frames).
I tried these for the video and audio:
setpts=305.237*PTS
atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.807668329177057
However the video overshoots by 00:01:19:08 and the audio I'm unsure, on one player it stops somewhere around 8 hours but on another it just continues. What are the correct formulas?
Also on VLC the video has grey frames between video frames - do I need to interpolate to have continuous video frames?
Edit by #Mulvya:
fred-macbookpro:~ srederiquefantune$ ffmpeg -i /Users/srederiquefantune/Desktop/test.mp4 -filter_complex "[0:v]setpts=305.237*PTS, scale=320:240[v];[0:a]atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.5, atempo=0.807668329177057[a]" -map "[v]" -map "[a]" /Users/srederiquefantune/Desktop/output2.mp4
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-indev=jack --disable-outdev=xv --disable-audiotoolbox --disable-videotoolbox --disable-sdl2 --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --disable-filter=coreimage --disable-filter=coreimagesrc --enable-vda --disable-indev=avfoundation --arch=x86_64 --enable-yasm --enable-libx265 --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/srederiquefantune/Desktop/test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
Duration: 00:06:41.25, start: 0.000000, bitrate: 2294 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2172 kb/s, 24 fps, 120 tbr, 90k tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 112 kb/s (default)
Metadata:
handler_name : VideoHandler
[libx264 # 0x104801200] using SAR=4/3
[libx264 # 0x104801200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 # 0x104801200] profile High, level 1.3
[libx264 # 0x104801200] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/Users/srederiquefantune/Desktop/output2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 320x240 [SAR 4:3 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
Metadata:
encoder : Lavc57.64.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc57.64.101 aac
Stream mapping:
Stream #0:0 (h264) -> setpts
Stream #0:1 (aac) -> atempo
scale -> Stream #0:0 (libx264)
atempo -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[output stream 0:1 # 0x104105420] 100 buffers queued in output stream 0:1, something may be wrong.
frame= 1 fps=0.0 q=0.0 size= 3kB time=00:00:22.01 bitrate= 1.2kbits/s
…
frame=2938515 fps=281 q=-1.0 Lsize= 2439310kB time=35:19:08.66 bitrate= 157.2kbits/s dup=2928888 drop=1 speed=12.1x
video:389302kB audio:1994106kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.345466%
[libx264 # 0x104801200] frame I:15399 Avg QP:14.27 size: 20680
[libx264 # 0x104801200] frame P:740673 Avg QP:17.21 size: 68
[libx264 # 0x104801200] frame B:2182443 Avg QP:25.83 size: 14
[libx264 # 0x104801200] consecutive B-frames: 0.9% 0.2% 0.1% 98.8%
[libx264 # 0x104801200] mb I I16..4: 7.9% 47.3% 44.8%
[libx264 # 0x104801200] mb P I16..4: 0.0% 0.1% 0.1% P16..4: 0.7% 0.1% 0.1% 0.0% 0.0% skip:99.0%
[libx264 # 0x104801200] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0:14.0% L1:85.9% BI: 0.0%
[libx264 # 0x104801200] 8x8 transform intra:48.2% inter:52.8%
[libx264 # 0x104801200] coded y,uvDC,uvAC intra: 91.4% 90.7% 88.0% inter: 0.1% 0.1% 0.0%
[libx264 # 0x104801200] i16 v,h,dc,p: 78% 4% 11% 7%
[libx264 # 0x104801200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 13% 17% 7% 8% 10% 7% 10% 10%
[libx264 # 0x104801200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 13% 11% 8% 10% 11% 8% 10% 9%
[libx264 # 0x104801200] i8c dc,h,v,p: 62% 15% 16% 7%
[libx264 # 0x104801200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x104801200] ref P L0: 87.6% 7.8% 4.0% 0.6% 0.0%
[libx264 # 0x104801200] ref B L0: 50.0% 49.6% 0.4%
[libx264 # 0x104801200] ref B L1: 91.3% 8.7%
[libx264 # 0x104801200] kb/s:26.05
[aac # 0x104802a00] Qavg: 632.499
fred-macbookpro:~ srederiquefantune$

FFMPEG "buffer queue overflow, dropping" with trim and atrim filters

In FFMPEG I am actually trimming and concating a 24 FPS video. When I apply a complex filter
ffmpeg -i sample.mp4 -filter_complex \
"[0:v]setpts = PTS-STARTPTS[bv];
[bv]split=6[v0][v1][v2][v3][v4][v5];
[v0]trim=start_frame=1:end_frame=142,loop=1:1:1,setpts=N/FRAME_RATE/TB[0v];
[v1]trim=start_frame=846:end_frame=878,loop=1:1:1,setpts=N/FRAME_RATE/TB[1v];
[v2]trim=start_frame=57:end_frame=114,loop=1:1:1,setpts=N/FRAME_RATE/TB[2v];
[v3]trim=start_frame=865:end_frame=885,loop=1:1:1,setpts=N/FRAME_RATE/TB[3v];
[v4]trim=start_frame=70:end_frame=155,loop=1:1:1,setpts=N/FRAME_RATE/TB[4v];
[v5]trim=start_frame=155:end_frame=909,loop=1:1:1,setpts=N/FRAME_RATE/TB[5v];
[0:a]asplit=6[a0][a1][a2][a3][a4][a5];
[a0]atrim=0.041666666666666664:5.917,asetpts=N/SR/TB[0a];
[a1]atrim=35.256:36.603,asetpts=N/SR/TB[1a];
[a2]atrim=2.379:4.767,asetpts=N/SR/TB[2a];
[a3]atrim=36.024:36.859,asetpts=N/SR/TB[3a];
[a4]atrim=2.93:6.438172,asetpts=N/SR/TB[4a];
[a5]atrim=6.438172:37.895,asetpts=N/SR/TB[5a];
[0v][0a][1v][1a][2v][2a][3v][3a][4v][4a][5v][5a]concat=n=6:v=1:a=1[vv][aa]"\
-map "[vv]" -map "[aa]" output.mp4
I am getting "buffer queue overflow, dropping" error. The resultant video and audio is still and not working properly.
ffmpeg version 3.2-1~16.04.york1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.1 (Ubuntu 5.4.1-3ubuntu1~ubuntu16.04.1york0) 20161019
configuration: --prefix=/usr --extra-version='1~16.04.york1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-libtesseract --disable-stripping --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-opengl --enable-sdl2 --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-openal --enable-frei0r --enable-libopencv --enable-libx264 --enable-chromaprint --enable-shared
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
track : 0
artist :
album :
date : 0
genre :
lyrics :
title :
encoder : Lavf56.36.100
Duration: 00:00:37.90, start: 0.000000, bitrate: 951 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 820 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, 126 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'output.mp4' already exists. Overwrite ? [y/N] y
[libx264 # 0x55650097a540] using SAR=1/1
[libx264 # 0x55650097a540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x55650097a540] profile High, level 3.0
[libx264 # 0x55650097a540] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
track : 0
artist :
album :
date : 0
genre :
lyrics :
title :
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
Metadata:
encoder : Lavc57.64.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc57.64.100 aac
Stream mapping:
Stream #0:0 (h264) -> setpts
Stream #0:1 (aac) -> asplit
concat:out:v0 -> Stream #0:0 (libx264)
concat:out:a0 -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_concat_33 # 0x55650097b420] Buffer queue overflow, dropping. 471.5kbits/s speed=4.94x
Last message repeated 201 times
[Parsed_concat_33 # 0x55650097b420] Buffer queue overflow, dropping. 522.9kbits/s speed=3.89x
Last message repeated 1266 times
[Parsed_concat_33 # 0x55650097b420] Buffer queue overflow, dropping. 557.0kbits/s speed=3.28x
Last message repeated 48 times
[output stream 0:1 # 0x556500947e20] 100 buffers queued in output stream 0:1, something may be wrong.
[Parsed_concat_33 # 0x55650097b420] Buffer queue overflow, dropping. 718.6kbits/s speed=3.46x
Last message repeated 19 times
[output stream 0:0 # 0x5565009785c0] 100 buffers queued in output stream 0:0, something may be wrong.
frame= 1091 fps=117 q=-1.0 Lsize= 2795kB time=00:00:45.51 bitrate= 503.1kbits/s dup=475 drop=0 speed=4.88x
video:2455kB audio:316kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.861779%
[libx264 # 0x55650097a540] frame I:8 Avg QP:19.26 size: 24207
[libx264 # 0x55650097a540] frame P:409 Avg QP:21.33 size: 4108
[libx264 # 0x55650097a540] frame B:674 Avg QP:27.46 size: 949
[libx264 # 0x55650097a540] consecutive B-frames: 10.3% 13.9% 24.5% 51.3%
[libx264 # 0x55650097a540] mb I I16..4: 9.9% 57.0% 33.1%
[libx264 # 0x55650097a540] mb P I16..4: 3.6% 7.6% 2.9% P16..4: 33.0% 10.6% 3.0% 0.0% 0.0% skip:39.2%
[libx264 # 0x55650097a540] mb B I16..4: 0.4% 0.8% 0.4% B16..8: 24.5% 2.6% 0.2% direct: 0.5% skip:70.5% L0:55.5% L1:41.8% BI: 2.7%
[libx264 # 0x55650097a540] 8x8 transform intra:53.8% inter:66.7%
[libx264 # 0x55650097a540] coded y,uvDC,uvAC intra: 44.6% 50.0% 14.8% inter: 6.2% 7.7% 0.2%
[libx264 # 0x55650097a540] i16 v,h,dc,p: 22% 28% 17% 33%
[libx264 # 0x55650097a540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 23% 28% 3% 4% 3% 11% 3% 5%
[libx264 # 0x55650097a540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 26% 16% 2% 5% 3% 16% 3% 3%
[libx264 # 0x55650097a540] i8c dc,h,v,p: 60% 22% 13% 6%
[libx264 # 0x55650097a540] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x55650097a540] ref P L0: 72.6% 8.4% 15.1% 3.9%
[libx264 # 0x55650097a540] ref B L0: 88.5% 10.7% 0.8%
[libx264 # 0x55650097a540] ref B L1: 93.3% 6.7%
[libx264 # 0x55650097a540] kb/s:442.30
[aac # 0x556500979280] Qavg: 3215.870
I tried with other stackoverflow questions but none of them worked. Also I think it is partially because the trim timings are mixed. That is start time can be anywhere between 0-end. When I make it strictly increasing it is working fine.
Add a fifo filter at the end of each of the video filterchains.
i.e.
[v0]trim=start_frame=1:end_frame=142,loop=1:1:1,setpts=N/FRAME_RATE/TB,fifo[0v];
Although probably not necessary, you can add afifo to the end of audio chains as well.

FFMPEG - Concatenate 2 MP4 Files, one has video and audio and the other has only audio

I am trying to merge 2 mp4 files using FFMPEG. One of these files has both video and audio (track1.mp4), while the other one has only audio (track2.mp4). The names of these files are listed in a text file called 'filesToMerge.txt' in the following manner:
file 'track1.mp4'
file 'track2.mp4'
I then execute the following ffmpeg command to merge them.
ffmpeg -f concat -i filesToMerge.txt -c copy output.mp4
However, the concatenated file that is generated consists of only the first file that is listed in filesToMerge.txt. That is, if track1.mp4 (which has both video and audio) is the first file in the list, then only that file makes up output.mp4 (the concatenated file produced) and vice versa.
I would like for both files to be in output.mp4. I am using Ubuntu 14.04 (if that helps). How can I solve this problem?
When I run this command
ffmpeg -i track1.mp4 -i track2.mp4 output.mp4
I get the following
ffmpeg version N-76944-g15206ff Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 17.100 / 6. 17.100
libavresample 3. 0. 0 / 3. 0. 0
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 'track1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:10.76, start: 0.023220, bitrate: 351 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x400 [SAR 400:533 DAR 800:533], 181 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 194 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'track2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.32.0
Duration: 00:00:32.21, start: 0.000000, bitrate: 46 kb/s
Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 43 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
[libx264 # 0x3950ce0] using SAR=400/533
[libx264 # 0x3950ce0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 # 0x3950ce0] profile High, level 3.0
[libx264 # 0x3950ce0] 264 - core 142 r2491 24e4fed - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.19.100
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 800x400 [SAR 400:533 DAR 800:533], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.16.101 libx264
Stream #0:1(und): Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.16.101 libfdk_aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame= 270 fps= 99 q=28.0 Lsize= 382kB time=00:00:10.72 bitrate= 291.9kbits/s dup=1 drop=0
video:230kB audio:143kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.482656%
[libx264 # 0x3950ce0] frame I:2 Avg QP:18.87 size:109452
[libx264 # 0x3950ce0] frame P:68 Avg QP:15.09 size: 171
[libx264 # 0x3950ce0] frame B:200 Avg QP:23.33 size: 23
[libx264 # 0x3950ce0] consecutive B-frames: 1.1% 0.0% 1.1% 97.8%
[libx264 # 0x3950ce0] mb I I16..4: 11.0% 39.6% 49.5%
[libx264 # 0x3950ce0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 5.9% 0.1% 0.0% 0.0% 0.0% skip:93.9%
[libx264 # 0x3950ce0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.3% 0.0% 0.0% direct: 0.0% skip:99.7% L0:21.8% L1:78.2% BI: 0.0%
[libx264 # 0x3950ce0] 8x8 transform intra:39.7% inter:92.8%
[libx264 # 0x3950ce0] coded y,uvDC,uvAC intra: 92.0% 95.0% 73.2% inter: 0.1% 1.4% 0.0%
[libx264 # 0x3950ce0] i16 v,h,dc,p: 1% 30% 4% 66%
[libx264 # 0x3950ce0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 6% 55% 16% 2% 4% 2% 8% 2% 6%
[libx264 # 0x3950ce0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 18% 13% 7% 9% 7% 12% 6% 11%
[libx264 # 0x3950ce0] i8c dc,h,v,p: 44% 35% 10% 11%
[libx264 # 0x3950ce0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x3950ce0] ref P L0: 98.1% 0.2% 1.1% 0.5%
[libx264 # 0x3950ce0] ref B L0: 85.1% 13.2% 1.7%
[libx264 # 0x3950ce0] ref B L1: 93.6% 6.4%
[libx264 # 0x3950ce0] kb/s:174.10
So if I'm understanding correctly, you want the final outputted video file to play track1.mp4, which will have video and audio, and then track2.mp4, which will have only audio and display nothing? The following answer assumes this is your desired output.
I tried several solutions, namely splitting the audio from the video and concatenating the audios first, then remerging, and generating a black video to go with the track2.mp4. I couldn't convince either to work. The final solution I found that DID work well is a bash script on the ffmpeg wiki's Concatenate page.
The steps are very straightforward. Copy the bash script into a file named "mmcat" in the same directory as track1/2.mp4. Then run
chmod +x mmcat && ./mmcat track1.mp4 track2.mp4 final.mp4
You should now have your desired file in final.mp4.
Note that this method does involve some transcoding, so you will theoretically lose some quality in doing so. Based on my experimentations, I don't believe this is avoidable since stream copying is only supported if the codecs exactly match, and you don't appear to be in that situation (your audio files have different bitrates, sample rates, etc).
Also note that whatever is in the final frame of video from track1 will be displayed, frozen, for the duration of track2. If you want it to go to black, you'd better make sure your final frame in track1 is a black frame. Doing so has been left as an exercise for OP.

Resources