[FFmpeg-user] Ticket #1238, synchronization of filtered streams

Misc misc.info at virgin.net
Mon Jun 4 12:13:20 CEST 2012


Just for information relevant to Ticket #1238, I have been using ffmpeg to 
crop, pad and overlay two image2 inputs with the following command

ffmpeg -f image2 -i stream1\N%04d.jpg -f image2 -i 
stream2\N%04d.jpg -filter_complex
"[0:v0]crop=in_w:in_h/2:0:75,pad=in_w:in_h*2:0:0:black[top]; 
[1:v0]crop=in_w:in_h/2:0:75[bottom]; [top][bottom]overlay=0:360"
 -vcodec mpeg4 -r 25 -an testshort.avi

The result is that the first 2 frames only show stream1 (correctly cropped 
and padded), and frames 3 onwards show the overlay correctly but with 
stream2 delayed by two frames (so the frame sequence is 1&-, 2&-, 3&1, 4&2, 
5&3.....).  The result does not seem to be sensitive to the vcodec used. 
Hope this helps, and thanks for all your efforts.

Here is the console output.

ffmpeg version N-41074-g9c27f29 Copyright (c) 2000-2012 the FFmpeg 
developers
  built on May 27 2012 13:22:28 with gcc 4.6.3
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect 
 --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt 
 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype  
--enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp 
 --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo 
 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx 
 --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      51. 55.100 / 51. 55.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, image2, from 'stream1\N%04d.jpg':
  Duration: 00:00:00.20, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 72:72 DAR 16:9], 25 
fps, 25 tbr, 25 tbn, 25 tbc
Input #1, image2, from 'stream2\N%04d.jpg':
  Duration: 00:00:00.20, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 72:72 DAR 16:9], 25 
fps, 25 tbr, 25 tbn, 25 tbc
[buffer @ 02376d40] w:1280 h:720 pixfmt:yuvj420p tb:1/25 sar:72/72 
sws_param:
[buffer @ 02383140] w:1280 h:720 pixfmt:yuvj420p tb:1/25 sar:72/72 
sws_param:
[buffersink @ 02388200] No opaque field provided
File 'testshort.avi' already exists. Overwrite ? [y/N] auto-inserting filter 
'auto-inserted scaler 0' between the filter 'Parsed_pad_1' and the filter 
'Parsed_overlay_3'
[overlay @ 0237d780] auto-inserting filter 'auto-inserted scaler 1' between 
the filter 'Parsed_crop_2' and the filter 'Parsed_overlay_3'
[crop @ 02380ac0] w:1280 h:720 sar:72/72 -> w:1280 h:360 sar:72/72
[pad @ 02380c60] w:1280 h:360 -> w:1280 h:720 x:0 y:0 color:0x000000FF
[scale @ 02372600] w:1280 h:720 fmt:yuvj420p sar:72/72 -> w:1280 h:720 
fmt:yuv420p sar:1/1 flags:0x2
[crop @ 0237d4a0] w:1280 h:720 sar:72/72 -> w:1280 h:360 sar:72/72
[scale @ 023704a0] w:1280 h:360 fmt:yuvj420p sar:72/72 -> w:1280 h:360 
fmt:yuva420p sar:1/1 flags:0x2
[overlay @ 0237d780] main w:1280 h:720 fmt:yuv420p overlay x:0 y:360 w:1280 
h:360 fmt:yuva420p
[overlay @ 0237d780] main_tb:1/25 overlay_tb:1/25 -> tb:1/25 exact:1
Output #0, avi, to 'testshort.avi':
  Metadata:
    ISFT            : Lavf54.6.101
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x720 [SAR 
1:1 DAR 16:9], q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (mjpeg) -> crop
  Stream #1:0 (mjpeg) -> crop
  format -> Stream #0:0 (mpeg4)
Press [q] to stop, [?] for help
frame=    5 fps=0.0 q=2.2 Lsize=      29kB time=00:00:00.20 
bitrate=1208.2kbits/s

video:24kB audio:0kB global headers:0kB muxing overhead 24.183866%



More information about the ffmpeg-user mailing list