Opened 12 years ago

Closed 12 years ago

#2413 closed defect (fixed)

Wrong complex filter graph example

Reported by: littlebat Owned by:
Priority: minor Component: documentation
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

The complex filter graph example at: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction , use the command line "ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output", I can't get the effect in document says "The result will be that in output the top half of the video is mirrored onto the bottom half. "

The detail console output is:
mdx@debian:~/test$ /opt/ffmpeggit/bin/ffmpeg -i test.mp4 -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output.mp4
ffmpeg version N-51433-g551f683 Copyright (c) 2000-2013 the FFmpeg developers

built on Mar 29 2013 10:01:04 with gcc 4.4.5 (Debian 4.4.5-8)
configuration: --prefix=/opt/ffmpeggit --enable-static --disable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-fontconfig --enable-libass --enable-libfreetype --enable-swscale --enable-postproc --enable-pthreads --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libopenjpeg --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --extra-cflags=-I/opt/custom/include --extra-ldflags=-L/opt/custom/lib
libavutil 52. 22.101 / 52. 22.101
libavcodec 55. 2.100 / 55. 2.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 48.105 / 3. 48.105
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf55.0.100

Duration: 00:00:05.04, start: 0.000000, bitrate: 378 kb/s

Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 176x144 [SAR 1:1 DAR 11:9], 323 kb/s, 12.50 fps, 12.50 tbr, 12800 tbn, 25 tbc
Metadata:

handler_name : VideoHandler

Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 49 kb/s
Metadata:

handler_name : SoundHandler

[Parsed_overlay_1 @ 0xa3a0d00] Overlay area with coordinates x1:0 y1:36 x2:176 y2:180 is not completely contained within the output with size 176x72
[libx264 @ 0xa396860] using SAR=1/1
[libx264 @ 0xa396860] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowCTZ SlowAtom
[libx264 @ 0xa396860] profile High, level 1.0
[libx264 @ 0xa396860] 264 - core 129 r36057 0a9132b - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=12 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: isomiso2mp41
encoder : Lavf55.0.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 176x72 [SAR 1:1 DAR 22:9], q=-1--1, 12800 tbn, 12.50 tbc
Metadata:

handler_name : VideoHandler

Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, s16, 128 kb/s
Metadata:

handler_name : SoundHandler

Stream mapping:

Stream #0:0 -> #0:0 (mpeg4 -> libx264)
Stream #0:1 -> #0:1 (aac -> libfaac)

Press [q] to stop, ? for help
frame= 42 fps=0.0 q=0.0 size= 0kB time=00:00:03.41 bitrate= 0.1kbits/sframe= 58 fps= 57 q=26.0 size= 5kB time=00:00:04.66 bitrate= 9.4kbits/frame= 63 fps= 24 q=-2.0 Lsize= 81kB time=00:00:05.01 bitrate= 132.8kbits/s
video:39kB audio:38kB subtitle:0 global headers:0kB muxing overhead 4.653034%
[libx264 @ 0xa396860] frame I:2 Avg QP:15.48 size: 152
[libx264 @ 0xa396860] frame P:55 Avg QP:23.73 size: 689
[libx264 @ 0xa396860] frame B:6 Avg QP:26.75 size: 244
[libx264 @ 0xa396860] consecutive B-frames: 81.0% 19.0% 0.0% 0.0%
[libx264 @ 0xa396860] mb I I16..4: 93.6% 4.5% 1.8%
[libx264 @ 0xa396860] mb P I16..4: 5.0% 6.8% 2.5% P16..4: 42.0% 28.9% 11.6% 0.0% 0.0% skip: 3.1%
[libx264 @ 0xa396860] mb B I16..4: 0.6% 0.0% 0.0% B16..8: 48.8% 13.9% 2.7% direct: 5.8% skip:28.2% L0:36.6% L1:27.7% BI:35.7%
[libx264 @ 0xa396860] 8x8 transform intra:38.6% inter:56.8%
[libx264 @ 0xa396860] coded y,uvDC,uvAC intra: 33.7% 74.5% 39.2% inter: 43.4% 73.1% 30.2%
[libx264 @ 0xa396860] i16 v,h,dc,p: 43% 21% 29% 7%
[libx264 @ 0xa396860] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 16% 47% 1% 3% 3% 2% 2% 3%
[libx264 @ 0xa396860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 22% 22% 1% 4% 5% 4% 2% 3%
[libx264 @ 0xa396860] i8c dc,h,v,p: 51% 21% 22% 6%
[libx264 @ 0xa396860] Weighted P-Frames: Y:38.2% UV:34.5%
[libx264 @ 0xa396860] ref P L0: 65.2% 17.5% 14.1% 2.6% 0.6%
[libx264 @ 0xa396860] ref B L0: 98.1% 1.9%
[libx264 @ 0xa396860] kb/s:62.92

I used the command below to get the result said in online document:
/opt/ffmpeggit/bin/ffmpeg -i test.mp4 -vf "[in] split [T1],crop=iw:ih/2:0:0,vflip,[T2] overlay=0:H/2 [out]; [T1]fifo[T2]" output2.mp4

Attachments:
1, input file: test.mp4
2, the wrong output file: output.mp4
3, the right output file: output2.mp4

Attachments (3)

test.mp4 (232.7 KB ) - added by littlebat 12 years ago.
output.mp4 (81.3 KB ) - added by littlebat 12 years ago.
output2.mp4 (115.9 KB ) - added by littlebat 12 years ago.

Download all attachments as: .zip

Change History (8)

by littlebat, 12 years ago

Attachment: test.mp4 added

by littlebat, 12 years ago

Attachment: output.mp4 added

by littlebat, 12 years ago

Attachment: output2.mp4 added

comment:1 by Carl Eugen Hoyos, 12 years ago

Priority: normalminor
Reproduced by developer: set
Status: newopen

Please consider sending a patch to ffmpeg-devel.

comment:2 by littlebat, 12 years ago

I am studying ffmpeg filtergraph these days, I found some documentation errors and post my sugguetions here, maybe still exist error too, please correct me if so.

Bugs in page: http://ffmpeg.org/ffmpeg-filters.html :

1, Because this filter example only process one video stream with "-vf" option, so it's a simple filtergraph. so, changed:
"In libavfilter, it is possible for filters to have multiple inputs and multiple outputs. To illustrate the sorts of things that are possible, we can use a complex filtergraph. "
to:
"To illustrate the usage, we can use a filtergraph."

2, Changed:
ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output
to:
ffmpeg -i input -vf "[in_0] split [split_out_0] [split_out_1]; [split_out_1] crop=iw:ih/2:0:0, vflip [vflip_out_0]; [split_out_0] [vflip_out_0] overlay=0:H/2 [out_0]" output

3, Changed:
"Filters are loaded using the -vf or -af option passed to ffmpeg or to ffplay. Filters in the same linear chain are separated by commas. In our example, split, overlay are in one linear chain, and crop, vflip are in another. The points where the linear chains join are labeled by names enclosed in square brackets. In our example, that is [T1] and [T2]. The special labels [in] and [out] are the points where video is input and output."
to:
"Filters are loaded using the -vf or -af option passed to ffmpeg or to ffplay. Filters in the same linear chain are separated by commas. For example, we separate this filter graph into three filterchains: the first filterchain is "split" filter(according to the filtergraph BNF description below, a filter can be a filterchain, even a filtergraph) has one default input pad(a video stream), and has two ouput pads; "crop, vflip" are in the second, it has one input pad and output pad; The third filterchain is "overlay" filter, has two input pads and one output pad. These three filterchains are linked with linklabels: Link the first and the second filterchain with linklabel "[split_out_1]", the first and the third with "[split_out_0]", the second and the third with "[vflip_out_0]". Linklabel "[in_0]" and "[out_0]" has no any special meaning, they even can be omitted, putting them there only is an indicating the video stream in and out point, they will be meaningful in a complex filtergraph(with -filter_complex option) which has multiple inputs or/and outputs."

4, 4.1 Filtergraph syntax, Changed:
"A filtergraph can be represented using a textual representation, which is recognized by the ‘-filter’/‘-vf’ and ‘-filter_complex’ options in ffmpeg and ‘-vf’ in ffplay, "
to:
"A filtergraph can be represented using a textual representation, which is recognized by the ‘-filter:v’/‘-vf’ and '-filter:a'/'-af' and ‘-filter_complex’ options in ffmpeg and ‘-vf’ and "-af" in ffplay, "

5, 8.45.1 Examples, Changed:
"color=red@.3:WxH [over]; [in][over] overlay [out]"
to:
"color=color=red@.3:size=WxH [over]; [in][over] overlay [out]"

6, 12.2.1 Examples, similar error as the second change above, changed:
"movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie]; [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]"
to:
"movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie]; [in] setpts=PTS-STARTPTS [setpts], [setpts] [movie] overlay=16:16 [out]"

7, 12.2.1 Examples, similar error as the bug "2" above, changed:
"movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie]; [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]"
to:
"movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie]; [in] setpts=PTS-STARTPTS [setpts], [setpts] [movie] overlay=16:16 [out]"

Bugs in page: http://ffmpeg.org/ffmpeg.html#Main-options :
8, ‘-filter[:stream_specifier] filtergraph (output,per-stream)’, because in recent ffmpeg, it is no necessary to use the "magic" label "[in]" and "[out]", so, deleted:
"In the filtergraph, the input is associated to the label in, and the output to the label out. "

By the way, I found ffmpeg 0.7.13(5:0.7.13-dmo2 Unofficial Multimedia Packages:6.0/stable [i386]) works on original command line in the bug 2,6,7 above in my Debian 6 machine, except need change "crop=iw:ih/2:0:ih/2" to "crop=iw:ih/2:0:0" in the bug 2. I found ffmpeg 0.7.13 breaks its own filter link rule in local documentation "If an output pad is not labelled, it is linked by default to the first unlabelled input pad of the next filter in the filterchain. ", for example, in the bug 7, "[in] setpts=PTS-STARTPTS" created an unlabelled output pad, it should be the second unlabelled input pad of "[movie] overlay=16:16 [out]", for the "overlay" filter, according to local documentation, it should be the second unlabelled input pad overlayed on the first "[movie]" label input pad, but, in fact, it's the first "[movie]" label input pad overlayed on the second unlabelled input pad. It's really a strange behavior. Is it a ffmpeg 0.7.13 bug? And, ffmpeg 0.7.13 has the special "magic" "[in]" and "[out]" label which has been dropped in recent ffmpeg.

Last edited 12 years ago by littlebat (previous) (diff)

comment:3 by Carl Eugen Hoyos, 12 years ago

Please consider sending patches to ffmpeg-devel.

comment:4 by littlebat, 12 years ago

Not familiar with ffmpeg's patch system, I post a patch at: http://ffmpeg.org/pipermail/ffmpeg-devel/2013-April/141716.html , I am afraid of email will break text lines and change the patch content, so I attach the patch in a attachment file: doc.patch, but in the page above, it became to "http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130404/069591ff/attachment.bin", just save this "attachment.bin" as "doc.patch".

comment:5 by Stefano Sabatini, 12 years ago

Analyzed by developer: set
Resolution: fixed
Status: openclosed

Should be fixed in:

commit 215ca864759a54f45265a51ac57dbfd75cb23da2
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Sat Apr 6 01:43:01 2013 +0200

    doc/filters: review introductory example and explanation
    
    In particular, fix wrong vertical mirroring command, and clarify
    and extend explanation.
    
    Based on a patch by littlebat <dashing.meng@gmail.com>.
    
    Should fix trac ticket #2413.
Note: See TracTickets for help on using tickets.