[FFmpeg-user] concat muxer with two video files with two different resolutions

Ben Mesander ben at cardinalpeak.com
Fri Apr 11 21:25:53 CEST 2014


Hello ffmpeg user mailing list,

  Today I tried to concatenate two h.264 video files with the concat muxer.
The two files have differing input resolutions (848x480 and 1280x720). I
would like the resulting video to be 640x480. I used today's static 32-bit
build from ffmpeg.org.

  Here's ffprobe output for the two files:

ben at ben-Latitude-D820:~/vid$ ./ffprobe 117_2463.MOV
ffprobe version N-62162-gec8789a Copyright (c) 2007-2014 the FFmpeg
developers
  built on Apr  5 2014 05:14:18 with gcc 4.6 (Debian 4.6.3-1)
  configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32
--extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static'
--extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static'
--extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared
--disable-ffserver --disable-doc --enable-bzlib --enable-zlib
--enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl
--enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray
--enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex
--enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3
--enable-libvpx
  libavutil      52. 74.100 / 52. 74.100
  libavcodec     55. 57.100 / 55. 57.100
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '117_2463.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2014-03-20 12:21:10
    comment         : KODAK Zi8 Pocket Video Camera
    comment-eng     : KODAK Zi8 Pocket Video Camera
  Duration: 00:00:15.02, start: 0.000000, bitrate: 4799 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
848x480 [SAR 1:1 DAR 53:30], 4654 kb/s, 29.97 fps, 29.97 tbr, 90k tbn,
59.94 tbc (default)
    Metadata:
      creation_time   : 2014-03-20 12:21:10
      handler_name    : Ambarella AVC
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2014-03-20 12:21:10
      handler_name    : Ambarella AAC
ben at ben-Latitude-D820:~/vid$ ./ffprobe 117_2466.MOV
ffprobe version N-62162-gec8789a Copyright (c) 2007-2014 the FFmpeg
developers
  built on Apr  5 2014 05:14:18 with gcc 4.6 (Debian 4.6.3-1)
  configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32
--extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static'
--extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static'
--extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared
--disable-ffserver --disable-doc --enable-bzlib --enable-zlib
--enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl
--enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray
--enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex
--enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3
--enable-libvpx
  libavutil      52. 74.100 / 52. 74.100
  libavcodec     55. 57.100 / 55. 57.100
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '117_2466.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2014-04-11 11:56:44
    comment         : KODAK Zi8 Pocket Video Camera
    comment-eng     : KODAK Zi8 Pocket Video Camera
  Duration: 00:01:26.39, start: 0.000000, bitrate: 4248 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 4111 kb/s, 29.97 fps, 29.97 tbr, 90k tbn,
59.94 tbc (default)
    Metadata:
      creation_time   : 2014-04-11 11:56:44
      handler_name    : Ambarella AVC
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2014-04-11 11:56:44
      handler_name    : Ambarella AAC


I tried creating a foo.txt like so:

ben at ben-Latitude-D820:~/vid$ cat foo.txt
file '117_2463.MOV'
file '117_2466.MOV'

And here is the ffmpeg command line & some of the thousands of lines of
output:

./ffmpeg -f concat -i foo.txt -strict -2 -s 640x480  -vcodec libx264
-preset fast -crf 20 -acodec aac out.mp4
ffmpeg version N-62162-gec8789a Copyright (c) 2000-2014 the FFmpeg
developers
  built on Apr  5 2014 05:14:18 with gcc 4.6 (Debian 4.6.3-1)
  configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32
--extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static'
--extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static'
--extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared
--disable-ffserver --disable-doc --enable-bzlib --enable-zlib
--enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl
--enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray
--enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex
--enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3
--enable-libvpx
  libavutil      52. 74.100 / 52. 74.100
  libavcodec     55. 57.100 / 55. 57.100
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[concat @ 0xa3903e0] Estimating duration from bitrate, this may be
inaccurate
Input #0, concat, from 'foo.txt':
  Duration: 00:00:00.07, start: 0.000000, bitrate: 4 kb/s
    Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 848x480
[SAR 1:1 DAR 53:30], 4654 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp,
127 kb/s
File 'out.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0xa3a0c60] using SAR=53/40
[libx264 @ 0xa3a0c60] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0xa3a0c60] profile High, level 3.0
[libx264 @ 0xa3a0c60] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec
- Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1
ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=1 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=20.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:
    encoder         : Lavf55.36.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p,
640x480 [SAR 53:40 DAR 53:30], q=-1--1, 30k tbn, 29.97 tbc
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo,
fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (aac -> aac)
Press [q] to stop, [?] for help
frame=   40 fps=0.0 q=26.0 size=      29kB time=00:00:01.38 bitrate=
170.0kbits/s    frame=   59 fps= 57 q=26.0 size=      67kB time=00:00:02.02
bitrate= 272.7kbits/s    frame=   79 fps= 50 q=26.0 size=     105kB
time=00:00:02.68 bitrate= 319.6kbits/s    frame=   99 fps= 47 q=26.0
size=     140kB time=00:00:03.34 bitrate= 342.4kbits/s    frame=  119 fps=
45 q=26.0 size=     174kB time=00:00:04.03 bitrate= 353.2kbits/s    frame=
137 fps= 44 q=26.0 size=     207kB time=00:00:04.62 bitrate=
366.1kbits/s    frame=  156 fps= 43 q=26.0 size=     241kB time=00:00:05.26
bitrate= 374.9kbits/s    frame=  175 fps= 42 q=26.0 size=     276kB
time=00:00:05.88 bitrate= 383.8kbits/s    frame=  195 fps= 41 q=26.0
size=     310kB time=00:00:06.57 bitrate= 386.7kbits/s    frame=  215 fps=
41 q=26.0 size=     345kB time=00:00:07.23 bitrate= 390.4kbits/s    frame=
235 fps= 41 q=26.0 size=     381kB time=00:00:07.89 bitrate=
395.0kbits/s    frame=  253 fps= 40 q=26.0 size=     413kB time=00:00:08.49
bitrate= 398.8kbits/s    frame=  274 fps= 41 q=26.0 size=     451kB
time=00:00:09.17 bitrate= 403.1kbits/s    frame=  289 fps= 40 q=26.0
size=     516kB time=00:00:09.70 bitrate= 435.8kbits/s    frame=  309 fps=
40 q=26.0 size=     563kB time=00:00:10.36 bitrate= 445.2kbits/s    frame=
329 fps= 40 q=26.0 size=     613kB time=00:00:11.00 bitrate=
456.1kbits/s    frame=  343 fps= 39 q=26.0 size=     649kB time=00:00:11.49
bitrate= 462.5kbits/s    frame=  359 fps= 39 q=26.0 size=     693kB
time=00:00:12.03 bitrate= 471.8kbits/s    frame=  375 fps= 38 q=26.0
size=     744kB time=00:00:12.56 bitrate= 485.1kbits/s    frame=  393 fps=
38 q=26.0 size=     797kB time=00:00:13.16 bitrate= 495.8kbits/s    frame=
412 fps= 38 q=26.0 size=     842kB time=00:00:13.80 bitrate=
499.5kbits/s    frame=  429 fps= 38 q=26.0 size=     884kB time=00:00:14.37
bitrate= 503.8kbits/s    [h264 @ 0xac826c0] left block unavailable for
requested intra4x4 mode -1 at 0 1
[h264 @ 0xac826c0] error while decoding MB 0 1, bytestream 209211
[h264 @ 0xac826c0] concealing 1586 DC, 1586 AC, 1586 MV errors in I frame
frame=  448 fps= 38 q=26.0 size=     921kB time=00:00:14.84 bitrate=
508.1kbits/s    [h264 @ 0xacc7600] concealing 1515 DC, 1515 AC, 1515 MV
errors in B frame
[h264 @ 0xacc7ca0] concealing 1199 DC, 1199 AC, 1199 MV errors in B frame
[h264 @ 0xac826c0] left block unavailable for requested intra mode at 0 9
[h264 @ 0xac826c0] error while decoding MB 0 9, bytestream 62961
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1162 DC, 1162 AC, 1162 MV errors in P frame
[h264 @ 0xacc7600] concealing 1502 DC, 1502 AC, 1502 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1534 DC, 1534 AC, 1534 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1405 DC, 1405 AC, 1405 MV errors in P frame
[h264 @ 0xacc7600] concealing 1429 DC, 1429 AC, 1429 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1414 DC, 1414 AC, 1414 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1525 DC, 1525 AC, 1525 MV errors in P frame
[h264 @ 0xacc7600] concealing 1521 DC, 1521 AC, 1521 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1503 DC, 1503 AC, 1503 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1482 DC, 1482 AC, 1482 MV errors in P frame
[h264 @ 0xacc7600] concealing 1364 DC, 1364 AC, 1364 MV errors in B frame
frame=  461 fps= 37 q=26.0 size=     956kB time=00:00:15.44 bitrate=
507.3kbits/s    [h264 @ 0xacc7ca0] concealing 1202 DC, 1202 AC, 1202 MV
errors in B frame
[h264 @ 0xac826c0] left block unavailable for requested intra4x4 mode -1 at
0 1
[h264 @ 0xac826c0] error while decoding MB 0 1, bytestream 222145
[h264 @ 0xac826c0] concealing 1586 DC, 1586 AC, 1586 MV errors in I frame
[h264 @ 0xacc7600] concealing 1323 DC, 1323 AC, 1323 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1369 DC, 1369 AC, 1369 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1174 DC, 1174 AC, 1174 MV errors in P frame
[h264 @ 0xacc7600] concealing 1366 DC, 1366 AC, 1366 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1302 DC, 1302 AC, 1302 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1417 DC, 1417 AC, 1417 MV errors in P frame
[h264 @ 0xacc7600] concealing 1481 DC, 1481 AC, 1481 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1136 DC, 1136 AC, 1136 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1516 DC, 1516 AC, 1516 MV errors in P frame
[h264 @ 0xacc7600] concealing 960 DC, 960 AC, 960 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1319 DC, 1319 AC, 1319 MV errors in B frame
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1488 DC, 1488 AC, 1488 MV errors in P frame
[h264 @ 0xacc7600] concealing 1241 DC, 1241 AC, 1241 MV errors in B frame
frame=  476 fps= 37 q=26.0 size=     985kB time=00:00:15.93 bitrate=
506.7kbits/

many thousands of lines substantively similar to the above and then:

[h264 @ 0xac826c0] left block unavailable for requested intra mode at 0 5
[h264 @ 0xac826c0] error while decoding MB 0 5, bytestream 5477
[h264 @ 0xac826c0] Cannot use next picture in error concealment
[h264 @ 0xac826c0] concealing 1374 DC, 1374 AC, 1374 MV errors in P frame
[h264 @ 0xacc7600] concealing 1334 DC, 1334 AC, 1334 MV errors in B frame
[h264 @ 0xacc7ca0] concealing 1482 DC, 1482 AC, 1482 MV errors in B frame
frame= 3039 fps= 42 q=26.0 size=    5502kB time=00:01:41.13 bitrate=
445.6kbits/s    frame= 3039 fps= 42 q=-1.0 Lsize=    5674kB
time=00:01:41.33 bitrate= 458.7kbits/s
video:3981kB audio:1583kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 1.977703%
[libx264 @ 0xa3a0c60] frame I:26    Avg QP:17.30  size: 10018
[libx264 @ 0xa3a0c60] frame P:859   Avg QP:19.38  size:  2324
[libx264 @ 0xa3a0c60] frame B:2154  Avg QP:20.15  size:   844
[libx264 @ 0xa3a0c60] consecutive B-frames:  4.4%  2.2%  2.8% 90.6%
[libx264 @ 0xa3a0c60] mb I  I16..4: 73.1% 14.1% 12.8%
[libx264 @ 0xa3a0c60] mb P  I16..4:  6.2%  1.9%  1.5%  P16..4: 14.8%  3.9%
2.0%  0.0%  0.0%    skip:69.6%
[libx264 @ 0xa3a0c60] mb B  I16..4:  1.0%  0.2%  0.2%  B16..8:  6.7%  1.7%
0.2%  direct: 5.6%  skip:84.4%  L0:50.6% L1:43.1% BI: 6.2%
[libx264 @ 0xa3a0c60] 8x8 transform intra:18.2% inter:43.5%
[libx264 @ 0xa3a0c60] coded y,uvDC,uvAC intra: 24.1% 27.7% 16.6% inter:
3.2% 8.4% 0.9%
[libx264 @ 0xa3a0c60] i16 v,h,dc,p: 80% 17%  2%  1%
[libx264 @ 0xa3a0c60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 22% 26%  2%  2%
2%  2%  2%  5%
[libx264 @ 0xa3a0c60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 30% 21%  3%  3%
3%  4%  3%  4%
[libx264 @ 0xa3a0c60] i8c dc,h,v,p: 46% 22% 31%  1%
[libx264 @ 0xa3a0c60] Weighted P-Frames: Y:0.5% UV:0.3%
[libx264 @ 0xa3a0c60] ref P L0: 63.8% 36.2%
[libx264 @ 0xa3a0c60] ref B L0: 78.0% 22.0%
[libx264 @ 0xa3a0c60] ref B L1: 90.5%  9.5%
[libx264 @ 0xa3a0c60] kb/s:321.56

In the resulting output mp4 file, the first video file appears as the
input, correctly sized to 640x480. The second video file shows up as mostly
grey with random green macroblocks and flickery random pixels here and
there.

So it appears an (undocumented? I don't see it) feature of the concat muxer
is the input files must be the same resolution, so this approach simply
won't work?

What I'm looking for is the simplest way to accomplish the goal of resizing
N h.264/aac files with differing sizes and concatenating them into a single
h.264/aac file in mp4 format. I think I can see how to accomplish this with
many, many named pipes, for instance I could fire up an ffmpeg on each
source video file and have it resize to the desired size and write the
audio and video streams to named pipes. Then I could 'cat' all the audio
and video pipes together respectively and feed them into another ffmpeg
instance which could reencode the video as h.264 and write it out in an mp4
container. This is a lot of named pipes to be setting up and tearing down
and seems like a fairly complex shell script with potentially a lot of edge
cases to handle in the face of corrupt or missing or zero length input
files, etc. I don't know if filtergraphs could help me here.

Any advice? Is the behavior I'm seeing expected, or a bug?

Thank you!

Regards,
Ben


-- 
*Ben Mesander*

(303)570-1606 | Email <email at cardinalpeak.com> |
vCard<http://www.cardinalpeak.com/vcard/bmesander.vcf>
 | Web <http://www.cardinalpeak.com/> | Company
Blog<http://www.cardinalpeak.com/blog>
 | LinkedIn<https://cardinalpeak.basecamphq.com/projects/6118601/file/79455231/Linked%20In%20url>


More information about the ffmpeg-user mailing list