Difference between revisions of "Documentation:Format String"

From VideoLAN Wiki
Jump to navigation Jump to search
(→‎Source code: Explain b_empty_if_na)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RightMenu|documentation play howto toc}}
+
{{RightMenu|Documentation TOC}}
  
Starting with [[VLC media player]] 0.9.0, format string variables can be used with the following options:
+
== Time ==
 +
 
 +
Starting with [[VLC media player]] 0.9.0, the following options specify a character formatted time string, rather than just a plain character string:
 
* --marq-marquee
 
* --marq-marquee
* --snapshot-path (when specifying a full image path, not a directory)
+
* --snapshot-path
 
* --snapshot-prefix
 
* --snapshot-prefix
* --image-out-prefix (or --scene-prefix in 1.0.0 and newer)
+
* --sout-file-format
* --msn-format (windows only)
+
* --sout-livehttp-index
* file access output dst/url (like in std{access=file,mux=ts,dst='''THIS'''})
 
 
 
There are two kinds of format string variables: time variables and meta variables.
 
 
 
==Time==
 
  
Time variables are those defined by the '''strftime''' C function. Those include:
+
Time variables are those defined by the '''strftime''' C function. The following expansions are most common:
 
* %Y : year
 
* %Y : year
 
* %m : month
 
* %m : month
Line 20: Line 17:
 
* %M : minute
 
* %M : minute
 
* %S : second
 
* %S : second
For an extensive list have a look at [http://www.hmug.org/man/3/strftime.php man strftime].
 
  
==Meta==
+
For an extensive list have a look at [http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html] (or the strftime manual page on Unix systems).
 +
 
 +
==Input meta==
  
Meta variables are VLC specific. The complete list is:
+
VLC-specific meta-data expansions are available for the following options:
 +
* --input-title-format
 +
* --snapshot-path (in version 2.2.0 and later)
 +
* --snapshot-prefix (in version 2.2.0 and later)
 +
 
 +
The following expansion are performed:
 
* $a : artist
 
* $a : artist
 
* $b : album
 
* $b : album
Line 30: Line 33:
 
* $d : description
 
* $d : description
 
* $e : encoded by
 
* $e : encoded by
* $f : frame count
+
* $f : total decoded frame count (since VLC started)
 
* $g : genre
 
* $g : genre
 
* $l : language
 
* $l : language
* $n : track num
+
* $n : track number
 +
* $o : track total
 
* $p : now playing
 
* $p : now playing
 
* $r : rating
 
* $r : rating
Line 54: Line 58:
 
* $U : publisher
 
* $U : publisher
 
* $V : volume
 
* $V : volume
 +
* $Z : now playing (artist - title)
 
* $_ : new line
 
* $_ : new line
 
* $<any other char> : <any other char> (for example: $$ transforms to $)
 
* $<any other char> : <any other char> (for example: $$ transforms to $)
  
You can insert a space between the $ sign and the character to tell it to not display anything if the meta data isn't available. For example: $ T instead will display "" if no time is available while $T would display something like "01_22_13" (for a snapshot from one hour, 22 minutes and 13 seconds in a video).
+
You can insert a space between the $ sign and the character to tell it to not display anything if the meta data isn't available. For example: <code>$ T</code> instead will display "" while <code>$T</code> would display "--:--:--", if no time is available. If a time is available,  it would display something like "01_22_13" (for a snapshot from one hour, 22 minutes and 13 seconds in a video).
 +
 
 +
===Source code===
 +
If you want to know how this works, check out {{VLCSourceFile|src/text/strings.c}} (search for <code>vlc_strfinput</code>)
  
==Source code==
+
The variable <var>b_empty_if_na</var> refers to the leading space feature: {{Commitdiff|3cc651e520ccb3106097e3f0167cc8c26f23e36c|l=Add option to format strings to prevent displaying dashes if the meta info was unavailable (ie: if time is unavailable, "$T" will display "--:--:--" while "$ T" won't display anything). This is of course completely untested :)}}
If you want to know how this works, check out src\text\strings.c  (str_format_meta function)[http://git.videolan.org/?p=vlc.git;a=blob;f=src/text/strings.c]
 
  
 
{{Documentation}}
 
{{Documentation}}

Latest revision as of 03:03, 4 April 2019

VLC User Guide

Quick Start Guide
Installing VLC
History
Usage
Interface
Open Media
Audio
Video
Playback
Playlist
Subtitles
Video and Audio Filters
Snapshots
Hotkeys
Uninstalling VLC
Troubleshooting
Advanced usage
Using VLC inside a webpage
Command line
Alternative Interfaces
Misc

Appendix
Building Pages for the HTTP Interface
Format String
Building Lua Playlist Scripts
View this alone

Time

Starting with VLC media player 0.9.0, the following options specify a character formatted time string, rather than just a plain character string:

  • --marq-marquee
  • --snapshot-path
  • --snapshot-prefix
  • --sout-file-format
  • --sout-livehttp-index

Time variables are those defined by the strftime C function. The following expansions are most common:

  • %Y : year
  • %m : month
  • %d : day
  • %H : hour
  • %M : minute
  • %S : second

For an extensive list have a look at [1] (or the strftime manual page on Unix systems).

Input meta

VLC-specific meta-data expansions are available for the following options:

  • --input-title-format
  • --snapshot-path (in version 2.2.0 and later)
  • --snapshot-prefix (in version 2.2.0 and later)

The following expansion are performed:

  • $a : artist
  • $b : album
  • $c : copyright
  • $d : description
  • $e : encoded by
  • $f : total decoded frame count (since VLC started)
  • $g : genre
  • $l : language
  • $n : track number
  • $o : track total
  • $p : now playing
  • $r : rating
  • $s : subtitles language
  • $t : title
  • $u : url
  • $A : date
  • $B : audio bitrate (in kb/s)
  • $C : chapter (as in DVD chapter number)
  • $D : duration
  • $F : full name with path
  • $I : title (as in DVD title number)
  • $L : time left
  • $N : name (media name as seen in the VLC playlist)
  • $O : audio language
  • $P : position (in %)
  • $R : rate
  • $S : audio sample rate (in kHz)
  • $T : time code of the video
  • $U : publisher
  • $V : volume
  • $Z : now playing (artist - title)
  • $_ : new line
  • $<any other char> : <any other char> (for example: $$ transforms to $)

You can insert a space between the $ sign and the character to tell it to not display anything if the meta data isn't available. For example: $ T instead will display "" while $T would display "--:--:--", if no time is available. If a time is available, it would display something like "01_22_13" (for a snapshot from one hour, 22 minutes and 13 seconds in a video).

Source code

If you want to know how this works, check out src/text/strings.c (search for vlc_strfinput)

The variable b_empty_if_na refers to the leading space feature: Add option to format strings to prevent displaying dashes if the meta info was unavailable (ie: if time is unavailable, "$T" will display "--:--:--" while "$ T" won't display anything). This is of course completely untested :)

This page is part of official VLC media player Documentation (User GuideStreaming HowToHacker GuideModules)
Please read the Documentation Editing Guidelines before you edit the documentation
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.