Graphics

All examples give the content of the JSON playlist (named `mix.json` here) - _see [filter](avmix), [howto](avmix_tuto)_  
The result can be viewed using `gpac avmix:pl=mix.json vout` (live mode) or `gpac avmix:live=0:pl=mix.json vout` (offline mode).

Insert text over video:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source.mp4"}] } ] },
{"sources": ["seq1"]},
{"x": 0, "y": -45, "width": 100, "height": 10, "text": ["Some nice text !"], "size": 60, "fill": "black", "line_width": -2, "line_color": "white"}
]
```

Insert last two lines of `text.txt` over video:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source.mp4"}] } ] },
{"sources": ["seq1"]},
{"x": 0, "y": -40, "width": 100, "height": 10, "text": ["text.txt", 2], "size": 60, "fill": "black", "line_width": -2, "line_color": "white"}
]
```


Mix two videos with blending:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{"sources": ["seq1", "seq2"], "mix": { "type": "mix"}, "mix_ratio": 0.5 }
]
```

Side by side videos:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source1.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{"sources": ["seq1"], "x": -25, "y": 0, "width": 50, "height": 100, "volume":0},
{"sources": ["seq2"], "x": 25, "y": 0, "width": 50, "height": 100, "volume":0}
]
```


Picture in picture video with alpha (source2 can be a video or an image) :
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source1.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{"sources": ["seq1"]},
{"sources": ["seq2"], "x": 35, "y": 35, "width": 20, "height": 20, "alpha":0.5}
]
```

Picture in picture video with shape and alpha:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source1.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{"sources": ["seq1"]},
{"sources": ["seq2"], "x": 35, "y": 35, "width": 20, "height": 20, "alpha":0.5, "shape": "ellipse", "line_width":2, "line_color":"cyan"}
]
```

Picture in picture video with alpha and rotation along Y axis (perspective texture mapping):
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source1.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{"sources": ["seq1"]},
{"sources": ["seq2"], "x": 35, "y": 35, "width": 20, "height": 20, "alpha":0.5, "rotation": "-30", "axis":[0,1,0]}
]
```

Moving picture in picture video with animated alpha:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source1.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{"sources": ["seq1"]},
{"id": "pip" "sources": ["seq2"], "x": 35, "y": 35, "width": 20, "height": 20, "alpha":0.5},
{"start": 0, "loop": true, "dur": 8, "keys": [0, 0.25, 0.5, 0.75, 1], "anims": [
    {"values": [35, -35, -35, 35, 35], "targets": ["pip@x"]},
    {"values": [35, 35, -35, -35, 35], "targets": ["pip@y"]},
    {"values": [1, 0, 1, 0, 1], "targets": ["logo@alpha"]}
 ]
}
]
```

Mix two videos with animated slide effect:
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source.mp4"}] } ] },
{ "id": "seq2", "seq": [ { "src": [{"in": "source2.mp4"}] } ] },
{ "id": "scene", "sources": ["seq1", "seq2"], "mix": { "type": "swipe"}, "mix_ratio": 0.5 },
{"start": 0, "loop": true, "dur": 4, "keys": [0, 0.5, 1], "anims": [
    {"values": [1, 0, 1], "targets": ["scene@mix_ratio"]}
 ]
}
]
```

Fractal-like animated video reuse
```
[
{ "id": "seq1", "seq": [ { "src": [{"in": "source.mp4"}] } ] },
{ "id": "gr1", "scenes": [
	{"sources": ["seq1"]},
    {"id":"use", "use": "gr1", "rotation": 10, "hscale": 0.9, "vscale": 0.9, "use_depth": 10}
]
},
{ "start": 0, "loop": true, "dur": 2, "keys": [0, 0.5, 1], "anims": [
    {"values": [0, 20, 0], "targets": ["use@use_depth"]}
 ]
}
]
```