File: video_format.sgml

package info (click to toggle)
dvdauthor 0.7.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,436 kB
  • sloc: ansic: 21,379; sh: 634; yacc: 460; lex: 199; makefile: 83
file content (138 lines) | stat: -rw-r--r-- 7,256 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<refentry id="video_format">

    <refentryinfo>
        <address>
            &dhemail;
        </address>
        <author>
            &dhfirstname;
            &dhsurname;
        </author>
        <copyright>
            <year>2016</year>
            <holder>&dhusername;</holder>
        </copyright>
        &dhdate;
    </refentryinfo>
    <refmeta>
        <refentrytitle>video_format</refentrytitle>
        <manvolnum>7</manvolnum>
    </refmeta>

    <refnamediv>
        <refname>video_format</refname>
        <refpurpose>
        Proposal For A Video Format Preference Specification
        </refpurpose>
    </refnamediv>

    <refsect1>
        <title>DESCRIPTION</title>
        <para>
            A number of different programs that create or work with video material need to know whether to generate their output in NTSC or PAL format. The ones that I’ve seen seem to have a hard-coded preference for one unless the user specifies the other. Overriding the default every time you want to use these programs gets tiresome.
        </para>
        <para>
        Therefore, there needs to be a way for the user to configure a single default that will apply to all these programs. This default should be settable on a per-user basis and a systemwide basis, with the per-user setting overriding the systemwide one, as is usual. It makes sense to avoid dotfile clutter by following, at least to some extent, the XDG Base Directory Specification <uri>http://standards.freedesktop.org/basedir-spec/latest/</uri>.
        </para>
        <para>
        The preference setting shall consist of the single word “NTSC” or “PAL” (without quotes, might as well be case-insensitive). This can be specified in the following ways, in order of decreasing priority:
            <itemizedlist mark="opencircle">
                <listitem><para>
                As the value of the environment variable <literal>VIDEO_FORMAT</literal>
                </para></listitem>
                <listitem><para>
                As the contents of the user-specific file <literal>$XDG_CONFIG_HOME/video_format</literal>, with <literal>$XDG_CONFIG_HOME</literal> defaulting to <literal>$HOME/.config</literal> if not defined.
                </para></listitem>
                <listitem><para>
                As the contents of a systemwide file <replaceable>dir</replaceable><literal>/video_format</literal>, where <replaceable>dir</replaceable> is taken in turn from the colon-separated items in the value of <literal>$XDG_CONFIG_DIRS</literal> until the file is found, or if <literal>$XDG_CONFIG_DIRS</literal> is not defined, then the single directory <literal>/etc</literal>.
                </para></listitem>
            </itemizedlist>
        </para>
        <para>
            The application should use the first of these settings that it finds, searching in the specified order.
        </para>
        <para>
            <emphasis>Note:</emphasis> the XDG Base Dir spec says systemwide config files should go in <literal>/etc/xdg</literal>. I'm not sure why this is, since lots of other apps put systemwide config in other places in <literal>/etc</literal>. Particularly since the spec doesn’t similarly restrict shared read-only data to just one subdirectory of <literal>/usr/share</literal>.
        </para>
    </refsect1>
    <refsect1>
        <title>DISCUSSION</title>
        <para>
        Can this spec apply to both standard-definition and high-definition video? For standard definition, there is a difference of frame size, being 720 by 480 for NTSC and 720 by 576 for PAL (in both cases, the aspect ratio of the displayed image is always 4:3). But this doesn’t seem to matter for high definition. For both standard-definition and high-definition, there is a difference of frame rates, based around 29.97 fps for NTSC and 25 fps for PAL.
        </para>
        <para>
        Note also that if a config file earlier in the search contains an invalid setting, the search does not continue even if another, later config file might contain a valid setting. This allows the user to override a system default with “no default”. Is this important? I think it could be.
        </para>
    </refsect1>

    <refsect1>
        <title>REFERENCE IMPLEMENTATION</title>
        <para>
        The following Python code implements a routine called <literal>get_default_video_format</literal> that returns either one of the strings “NTSC” or “PAL” indicating the user/system-configured default format as per the spec above, or <literal>None</literal> if the default is invalid or not configured.
        </para>
        <programlisting><![CDATA[
    class xdg_base_dir :
        "Implementation of relevant parts of the XDG Base Directory specification" \
        " <http://standards.freedesktop.org/basedir-spec/latest/>."
        @classmethod
        def get_config_home(self) :
            "returns the directory for holding user-specific config files."
            result = os.environ.get("XDG_CONFIG_HOME")
            if result == None :
                result = os.path.join(os.environ["HOME"], ".config")
            #end if
            return result
        #end get_config_home

        @classmethod
        def config_search_path(self) :
            "returns the list of config directories to search (apart from the user area)."
            return tuple(os.environ.get("XDG_CONFIG_DIRS", "/etc").split(":"))
              # note spec actually says default should be /etc/xdg, but /etc is the
              # conventional location for system config files.
        #end config_search_path

        @classmethod
        def find_first_config_path(self, path) :
            "searches for path in all the config directory locations in order of decreasing" \
            " priority, returning the expansion where it is first found, or None if not found."
            paths_to_try = iter((self.get_config_home(),) + self.config_search_path())
              # highest priority first
            while True :
                this_path = next(paths_to_try, None)
                if this_path == None :
                    break
                this_path = os.path.join(this_path, path)
                if os.path.exists(this_path) :
                    break
            #end while
            return this_path
        #end find_first_config_path

    #end xdg_base_dir

    valid_video_formats = frozenset(("NTSC", "PAL"))

    def get_default_video_format() :
        video_format = os.environ.get("VIDEO_FORMAT")
        if video_format == None :
            config_file = xdg_base_dir.find_first_config_path("video_format")
            if config_file != None :
                try :
                    video_format = open(config_file, "r").readline().strip()
                except OSError :
                    video_format = None
                #end try
            #end if
        #end if
        if video_format != None :
            video_format = video_format.upper()
            if video_format not in valid_video_formats :
                video_format = None
            #end if
        #end if
        return video_format
    #end get_default_video_format
        ]]></programlisting>
    </refsect1>
</refentry>