Ticket #33869: yorick-av-test.i

File yorick-av-test.i, 3.2 KB (added by paumard, 13 years ago)

example/test script

Line 
1/*
2 * check.i - Check / example file for yorick-av
3 * This file is part of yorick-av, a Yorick plu-ing to write movies
4 * using LibAV/FFmpeg.
5 *
6 * ============================================================================
7 * Copyright (c) 2012 Thibaut Paumard
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 * THE SOFTWARE.
26 * ============================================================================
27 *
28 * This script should create a number of movie files called
29 * libavcheck.* with the same content encoded in various formats using
30 * various codecs.
31 *
32 * Those movies should show a red band coming from the left (brighter
33 * at the bottom), then yellow stuff comes, and finally white. The
34 * movie ends when the red bar reaches the middle of the image.
35 *
36 * Unless the environment variable YAV_NODISPLAY is set, a window
37 * should pop-up displaying a moving sine curve. This movie will be
38 * saved as libavtest.*.
39 *
40 * If, in addition, mpgtest.i (from the ympeg plug-in) can be located,
41 * it will be run, the mpeg_* functions replaced by their av_*
42 * counterparts using libav-mpeg.i. This will create a file named
43 * test.mpg.
44 *
45 */
46
47if (open("libav.i", "r", 1)) plug_dir, _("./", plug_dir());
48#include "libav.i"
49
50exts=["mpg", "avi", "ogg", "mkv", "mp4", "mov", "h264", "wmv", "vob"];
51vcodecs=["mpeg1video", "mpeg4", "libtheora", "mpeg4", "mpeg4", "mpeg4",
52         "libx264", "msmpeg4", "mpeg2video"];
53         
54for (e=1; e<=numberof(exts); ++e) {
55  fname="libavcheck."+exts(e);
56  write, format="==========================================\n"+
57                "     testing extension: '%s'\n"+
58                "==========================================\n", exts(e);
59  obj=av_create(fname, vcodec=vcodecs(e));
60
61  data = array(char, 3, 704, 288);
62
63  for (i=1; i<=352; ++i) {
64    data(1, i, ) = span(0,255,288);
65    if (i>100) data(2,i-100,) = span(0,255,288);
66    if (i>200) data(3,i-200,) = span(0,255,288);
67    av_write, obj, data;
68  }
69 
70  write, format="done, closing file '%s'\n", fname;
71  av_close, obj;
72 }
73
74if (!get_env("YAV_NODISPLAY")) {
75
76  require, "avtest.i";
77  for (e=1; e<=numberof(exts); ++e) avtest, "libavtest."+exts(e), vcodec=vcodecs(e);
78
79  include,"mpgtest.i", 3;
80  require, "libav-mpeg.i";
81  if (is_func(mpgtest)) mpgtest;
82 }
83if (batch()) quit;
84