2

On my Windows 7 PC, I've used Windows Live Movie Maker and Windows Media Encoder extensively to make and edit videos (I've also used other software like "Showbiz", "Super C" and "AVIdemux"). Recently I wanted to create a "grid mosaic" in a 2x2 arrangement of source videos in a target video.

After some flailing around and gnashing of teeth, I found out about ffmpeg, downloaded the Windows "build" from the ffmpeg.org website, and have installed it on my PC. I tried using a command in the cmd window (aka "DOS") for the simple task of converting a WMV video (with an unusual aspect ratio) to AVI, and that worked out fine. At first the output image was pretty low-grade, but adding -b:v 3M fixed that up. Then, for my real objective, following this example I had found online:

ffmpeg -i 1.avi -i 2.avi -i 3.avi -i 4.avi -filter_complex "nullsrc=size=640x480 [base]; 
[0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft]; [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright]; [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft]; [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright]; [base][upperleft] 
overlay=shortest=1 [tmp1]; [tmp1][upperright] overlay=shortest=1:x=320 [tmp2]; [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3]; [tmp3][lowerright] 

overlay=shortest=1:x=320:y=240" -c:v libx264 output.mkv

Based on this, I tried my own command in the cmd window, thus:

ffmpeg -i PatrShdY.wmv -i TJC.wmv -i TwSlRawD.wmv -i NightmrC.wmv -filter_complex "nullsrc=size=1056x594 [base]; 
[0:v] setpts=PTS-STARTPTS, scale=528x297 [ul]; [1:v] setpts=PTS-STARTPTS, scale=528x297 [ur]; [2:v] setpts=PTS-STARTPTS, scale=528x297 [ll]; [3:v] setpts=PTS-STARTPTS, scale=528x297 [lr]; 
[base][ul] overlay=shortest=1 [t1]; [t1][ur] overlay=shortest=1:x=528 [t2]; [t2][ll] overlay=shortest=1:y=297 [t3]; [t3][lr] overlay=shortest=1:x=528:y=297" -b:v 3M mos1.wmv

The "reportage" mentioned some "guessing" issues with the audio, but that was not a big concern. An oddity was that it repeatedly said "frame= 1" instead of increasing numbers, and indeed, the result mos1.wmv had four images placed properly, but which were nothing more than one still image from each source video. All four source videos were 30 seconds duration, and the output "ran" for 30 seconds, but doing nothing more than showing one set of still images. The output file size of about 500kb was in line with this. The full reportage:

ffmpeg version N-87867-g0655810072 Copyright (c) 2000-2017 the FFmpeg developers

  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopu
s --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --ena
ble-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-lib
x264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-z
lib --enable-gmp --enable-libvidstab --enable-cuda --enable-cuvid --enable-d3d11
va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      55. 79.100 / 55. 79.100
  libavcodec     57.108.100 / 57.108.100
  libavformat    57. 84.100 / 57. 84.100
  libavdevice    57. 11.100 / 57. 11.100
  libavfilter     6.108.100 /  6.108.100
  libswscale      4.  9.100 /  4.  9.100
  libswresample   2. 10.100 /  2. 10.100
  libpostproc    54.  8.100 / 54.  8.100
[wmv3 @ 000000000048b200] Extra data: 8 bits left, value: 0
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, asf, from 'PatrShdY.wmv':
  Metadata:
    title           : In the woodshed
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: MP@HL
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 1
    VBR Peak        : 2156613
    Buffer Average  : 1555
  Duration: 00:00:30.02, start: 0.000000, bitrate: 2496 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 32000 Hz, mono, fltp,
20 kb/s
    Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1024x576,
 2441 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
[wmv3 @ 0000000000459ea0] Extra data: 8 bits left, value: 0
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, asf, from 'TJC.wmv':
  Metadata:
    title           : White -- 'nuff said!!
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: MP@HL
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 1
    VBR Peak        : 2181663
    Buffer Average  : 2514
  Duration: 00:00:30.02, start: 0.000000, bitrate: 2481 kb/s
    Stream #1:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 32000 Hz, stereo, fltp
, 24 kb/s
    Stream #1:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1024x576,
 2441 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
[wmv3 @ 0000000000506360] Extra data: 8 bits left, value: 0
Input #2, asf, from 'TwSlRawD.wmv':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: M0
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 0
  Duration: 00:00:30.04, start: 0.000000, bitrate: 2276 kb/s
    Stream #2:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1024x576,
90k tbr, 90k tbn, 90k tbc
    Metadata:
      comment         : Movie/video screen capture
    Stream #2:1: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1024x576, 2200
 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Stream #2:2: Audio: wmapro (b[1][0][0] / 0x0162), 32000 Hz, stereo, fltp, 32
 kb/s
[wmv3 @ 00000000004cc1a0] Extra data: 8 bits left, value: 0
Guessed Channel Layout for Input Stream #3.0 : stereo
Input #3, asf, from 'NightmrC.wmv':
  Metadata:
    title           : In a Nightmare
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: MP@HL
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 1
    VBR Peak        : 3032434
    Buffer Average  : 1675
  Duration: 00:00:30.02, start: 0.000000, bitrate: 3483 kb/s
    Stream #3:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 32000 Hz, stereo, fltp
, 24 kb/s
    Stream #3:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1024x576,
 3441 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
[wmv3 @ 0000000000451fe0] Extra data: 8 bits left, value: 0
[wmv3 @ 0000000000504b60] Extra data: 8 bits left, value: 0
[wmv3 @ 00000000004ccb40] Extra data: 8 bits left, value: 0
Stream mapping:
  Stream #0:1 (wmv3) -> setpts (graph 0)
  Stream #1:1 (wmv3) -> setpts (graph 0)
  Stream #2:0 (mjpeg) -> setpts (graph 0)
  Stream #3:1 (wmv3) -> setpts (graph 0)
  overlay (graph 0) -> Stream #0:0 (msmpeg4)
  Stream #1:0 -> #0:1 (wmav2 (native) -> wmav2 (native))
Press [q] to stop, [?] for help
[swscaler @ 00000000034d1f20] deprecated pixel format used, make sure you did se
t range correctly
Output #0, asf, to 'mos2.wmv':
  Metadata:
    title           : Patrik Janovic in the woodshed
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: MP@HL
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 1
    VBR Peak        : 2156613
    Buffer Average  : 1555
    WM/EncodingSettings: Lavf57.84.100
    Stream #0:0: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p(progres
sive), 1056x594 [SAR 1:1 DAR 16:9], q=2-31, 3000 kb/s, 25 fps, 1k tbn, 25 tbc (d
efault)
    Metadata:
      encoder         : Lavc57.108.100 msmpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/3000000 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 32000 Hz, stereo, fltp
, 128 kb/s
    Metadata:
      encoder         : Lavc57.108.100 wmav2
frame=    1 fps=0.0 q=6.1 size=      33kB time=00:00:00.25 bitrate=1044.1kbits/s
frame=    1 fps=0.8 q=6.1 size=      33kB time=00:00:01.21 bitrate= 219.8kbits/s
frame=    1 fps=0.6 q=6.1 size=      33kB time=00:00:02.30 bitrate= 116.0kbits/s
frame=    1 fps=0.5 q=6.1 size=      33kB time=00:00:03.60 bitrate=  74.1kbits/s
frame=    1 fps=0.4 q=6.1 size=      33kB time=00:00:04.86 bitrate=  55.0kbits/s
frame=    1 fps=0.3 q=6.1 size=      33kB time=00:00:06.01 bitrate=  44.4kbits/s
frame=    1 fps=0.3 q=6.1 size=      33kB time=00:00:07.74 bitrate=  34.5kbits/s
frame=    1 fps=0.2 q=6.1 size=      33kB time=00:00:09.15 bitrate=  29.2kbits/s
frame=    1 fps=0.2 q=6.1 size=      33kB time=00:00:10.24 bitrate=  26.1kbits/s
frame=    1 fps=0.2 q=6.1 size=      33kB time=00:00:12.35 bitrate=  21.6kbits/s
frame=    1 fps=0.2 q=6.1 size=      33kB time=00:00:13.05 bitrate=  20.5kbits/s
frame=    1 fps=0.2 q=6.1 size=      33kB time=00:00:14.46 bitrate=  18.5kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:16.19 bitrate=  16.5kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:17.98 bitrate=  14.9kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:18.88 bitrate=  14.2kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:20.28 bitrate=  13.2kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:21.69 bitrate=  12.3kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:23.26 bitrate=  11.5kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:24.32 bitrate=  11.0kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:25.08 bitrate=  10.7kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:25.98 bitrate=  10.3kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:28.49 bitrate=   9.4kbits/s
frame=    1 fps=0.1 q=6.1 size=      33kB time=00:00:29.95 bitrate=   8.9kbits/s
frame=    1 fps=0.1 q=6.1 Lsize=     524kB time=00:00:29.95 bitrate= 143.2kbits/s speed=2.54x
video:31kB audio:470kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.417643%

I decided to try an example sticking more closely to the example I'd found online, using a couple AVI source videos with frame size 320x240. The shorter of the two sources ran 4+ minutes, so that was the expected output duration. I put the two sources in a "checkerboard" 2x2 grid. In retrospect, I suppose I didn't need to NAME each of them twice, but I'm new at ffmpeg, so don't hate me! My command for this:

ffmpeg -i asianpho.avi -i WareMorg.avi -i WareMorg.avi -i asianpho.avi -filter_complex "nullsrc=size=640x480 [base]; [0:v] setpts=PTS-STARTPTS, scale=320x240 [ul]; [1:v] setpts=PTS-STARTPTS, scale=320x240 [ur]; [2:v] setpts=PTS-STARTPTS, scale=320x240 [ll]; [3:v] setpts=PTS-STARTPTS, scale=320x240 [lr]; [base][ul] overlay=shortest=1 [tmp1]; [tmp1][ur] overlay=shortest=1:x=320 [tmp2]; [tmp2][ll] overlay=shortest=1:y=240 [tmp3]; [tmp3][lr] overlay=shortest=1:x=320:y=240" -c:v libx264 output.mkv

The result of THIS reported the creation of 4+ minutes of video (and not all "frame= 1") -- it wasn't still images, but it was properly PLACED images that were a flickering, flashing jumbled mess with screwed-up time flow, file size 41.4 Mb. I've been requested to supply the full report on it:

https://pastebin.com/6DrjGPmA

So what am I doing, or is, wrong? How can I make it work?

  • No errors shown in the log. I suspect the WMVs can't be parsed correctly by ffmpeg. – Gyan Oct 19 '17 at 5:27
  • @AlanRat - well shoot. Sorry about that answer ban. It wasn't intentional and got put on by the system automatically. I'm not seeing an immediate way to fix it in my controls, but I'll edit one of your answers to include your answer from the comment and undelete it. That should at least get you an upvotable answer. I'll also check in to getting it cleared since it was a special case issue, not something that really should have hit the automatic ban. – AJ Henderson Oct 22 '17 at 4:25
  • Ok, looks like upvoting your answer and question was enough to make the system decide your weren't a high risk for answers... yay!!! – AJ Henderson Oct 22 '17 at 4:38
3

It occurred to me I could probably "work around" the problem.

My source files were all WMV files produced by Windows Media Encoder (mostly) and Windows Live Movie Maker, both of which can ONLY produce that file type.

As my first trial run with ffmpeg was to convert an individual one of those WMV files to another type, and THAT was successful, I decided to use ffmpeg to convert each source file separately to MP4. Then THOSE files could, indeed, be formed successfully into a "mosaic grid" with ffmpeg.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.