VIDEO_FORMAT(7)

πŸ“¦
version 0.7.2 Β· 2 versions
  • 0.7.2 Β· alpine 3.24, arch rolling, debian bookworm, debian trixie, epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.7.2 Β· opensuse-leap 16.0
, in alpine 3.24, arch rolling, debian bookworm, debian trixie, epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

🌸 VIDEO_FORMAT 🌸 (iykyk, it's section 7)

okay bestie, this one's from the DVDAuthor Man Pages, and it's literally a whole proposal for how video format preference should work. no cap. let's get into it πŸ’…


✨ NAME ✨

video_format β€” Proposal For A Video Format Preference Specification πŸŽ€


πŸ’– DESCRIPTION πŸ’–

so here's the vibe. a whole bunch of programs that create or work with video material need to know whether to spit out their output in NTSC or PAL format. and the ones I've seen? they just hard-code a preference for one of them unless the user explicitly says otherwise. which means if you want the other one, you're overriding the default every single time. and that, bestie, gets tiresome. 😭

so obviously there needs to be a way for the user to configure one single default that applies to all of these programs. slay. and this default should be settable both per-user and systemwide, with the per-user setting overriding the systemwide one, as is usual. πŸ‘‘

also β€” and this is the lowkey genius part β€” it makes sense to avoid dotfile clutter by following, at least to some extent, the XDG Base Directory Specification http://standards.freedesktop.org/basedir-spec/latest/. 🌈

the preference setting itself shall consist of the single word β€œNTSC” or β€œPAL” (without quotes, and might as well be case-insensitive, fr fr). and you can specify it in the following ways, in order of decreasing priority:

  • as the value of the environment variable VIDEO_FORMAT ⭐
  • as the contents of the user-specific file $XDG_CONFIG_HOME/video_format, with $XDG_CONFIG_HOME defaulting to $HOME/.config if not defined 🫢
  • as the contents of a systemwide file dir/video_format, where dir is taken in turn from the colon-separated items in the value of $XDG_CONFIG_DIRS until the file is found, or if $XDG_CONFIG_DIRS is not defined, then the single directory /etc πŸ’œ

the application should use the first of these settings that it finds, searching in the specified order. periodt.

Note: the XDG Base Dir spec says systemwide config files should go in /etc/xdg. I'm not sure why this is, since lots of other apps put systemwide config in other places in /etc. Particularly since the spec doesn't similarly restrict shared read-only data to just one subdirectory of /usr/share. πŸ™ˆ like, make it make sense.

πŸ¦‹ DISCUSSION πŸ¦‹

so the big question: 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 (and 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. 🎬

also note: 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. which is actually the whole point β€” it lets the user override a system default with β€œno default”. is this important? I think it could be. πŸ’€


πŸ”₯ REFERENCE IMPLEMENTATION πŸ”₯

the following Python code implements a routine called get_default_video_format that returns either one of the strings β€œNTSC” or β€œPAL” indicating the user/system-configured default format as per the spec above, or None if the default is invalid or not configured. πŸ‘‘

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

okay that's the whole thing, bestie, you ate it πŸ’…βœ¨ this was the DVDAuthor Man Pages rendition of VIDEO_FORMAT(7), dated Fri Dec 30 19:47:26 CET 2005 πŸŽ€ go set your VIDEO_FORMAT and be free πŸŒΈπŸ¦‹