Skip to content

Commit

Permalink
Transcoding: Improve docs and examples
Browse files Browse the repository at this point in the history
Thanks to #2833 (comment)
  • Loading branch information
KarlStraussberger committed Jun 26, 2023
1 parent d1d3dee commit 2b316b5
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 6 deletions.
4 changes: 3 additions & 1 deletion doc/config-transcode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ This section defines the various transcoding profiles.

* Optional

If the flags match the ones defined in clients, the profile is selected for that client. Choose an unused flag, e.g. "0x100", to avoid collisions with other features.
If the flags match the ones defined in clients, the profile is selected for that client.
There are are ``TRANSCODE1``, ``TRANSCODE2``, ``TRANSCODE3`` or choose an unused flag,
e.g. ``0x10000``, to avoid collisions with other features.

::

Expand Down
33 changes: 32 additions & 1 deletion doc/transcoding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ We define ``vlcprof`` in the profiles section:
<profile name="vlcprof" enabled="yes" type="external">
<mimetype>video/mpeg</mimetype>
<agent command="vlc"
arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>
arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc://quit"/>
<buffer size="10485760" chunk-size="131072" fill-size="2621440"/>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
Expand Down Expand Up @@ -285,6 +285,37 @@ We also provide a way to specify that a profile should only process the Theora c
<accept-ogg-theora>yes</accept-ogg-theora>
Complete Example
----------------

.. code-block:: xml
<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="audio/x-flac" client-flags="TRANSCODING1" using="audio2mp3" />
<transcode mimetype="audio/flac" client-flags="TRANSCODING1" using="audio2mp3" />
</mimetype-profile-mappings>
<profiles>
<profile name="audio2mp3" enabled="yes" type="external">
<mimetype>audio/mpeg</mimetype>
<dlna-profile>MP3</dlna-profile>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>no</hide-original-resource>
<accept-ogg-theora>no</accept-ogg-theora>
<sample-frequency>44100</sample-frequency>
<audio-channels>2</audio-channels>
<agent command="ffmpeg" arguments="-loglevel error -vn -i %in -ab 320k -f mp3 -y %out" />
<thumbnail>yes</thumbnail>
<buffer size="1048576" chunk-size="131072" fill-size="262144" />
</profile>
</profiles>
</transcoding>
<clients enabled="yes">
<client ip="192.168.120.42" flags="TRANSCODING1"></client>
</clients>
Testing And Troubleshooting
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions src/config/client_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ static constexpr auto quirkFlags = std::array {
std::pair("PV_SUBTITLES", QUIRK_FLAG_PV_SUBTITLES),
std::pair("PANASONIC", QUIRK_FLAG_PANASONIC),
std::pair("STRICTXML", QUIRK_FLAG_STRICTXML),
std::pair("TRANSCODING1", QUIRK_FLAG_TRANSCODING1),
std::pair("TRANSCODING2", QUIRK_FLAG_TRANSCODING2),
std::pair("TRANSCODING3", QUIRK_FLAG_TRANSCODING3),
};

int ClientConfig::remapFlag(const std::string& flag)
Expand Down
2 changes: 1 addition & 1 deletion src/config/config_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void ConfigGenerator::generateTranscoding()

agent = setValue(fmt::format("{}/{}/", profileTag, ConfigDefinition::mapConfigOption(ATTR_TRANSCODING_PROFILES_PROFLE_AGENT)), "", true);
setValue(agent, ATTR_TRANSCODING_PROFILES_PROFLE_AGENT_COMMAND, "vlc");
setValue(agent, ATTR_TRANSCODING_PROFILES_PROFLE_AGENT_ARGS, "-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit");
setValue(agent, ATTR_TRANSCODING_PROFILES_PROFLE_AGENT_ARGS, "-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc://quit");

buffer = setValue(fmt::format("{}/{}/", profileTag, ConfigDefinition::mapConfigOption(ATTR_TRANSCODING_PROFILES_PROFLE_BUFFER)), "", true);
setValue(buffer, ATTR_TRANSCODING_PROFILES_PROFLE_BUFFER_SIZE, fmt::to_string(DEFAULT_VIDEO_BUFFER_SIZE));
Expand Down
3 changes: 3 additions & 0 deletions src/util/upnp_quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ using QuirkFlags = std::uint32_t;
#define QUIRK_FLAG_PV_SUBTITLES 0x00000040
#define QUIRK_FLAG_PANASONIC 0x00000080
#define QUIRK_FLAG_STRICTXML 0x00000100
#define QUIRK_FLAG_TRANSCODING1 0x00010000
#define QUIRK_FLAG_TRANSCODING2 0x00020000
#define QUIRK_FLAG_TRANSCODING3 0x00040000

// forward declaration
class ActionRequest;
Expand Down
2 changes: 1 addition & 1 deletion test/config/fixtures/mock-config-all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit" />
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc://quit" />
<buffer size="14400000" chunk-size="512000" fill-size="120000" />
</profile>
</profiles>
Expand Down
2 changes: 1 addition & 1 deletion test/config/fixtures/mock-config-minimal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit" />
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc://quit" />
<buffer size="14400000" chunk-size="512000" fill-size="120000" />
</profile>
</profiles>
Expand Down
2 changes: 1 addition & 1 deletion test/config/fixtures/mock-transcoding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit" />
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc://quit" />
<buffer size="14400000" chunk-size="512000" fill-size="120000" />
</profile>
</profiles>
Expand Down

0 comments on commit 2b316b5

Please sign in to comment.