A few days ago I wanted to watch a movie with a pretty special setup: The video should be displayed locally while the audio is streamed to another device on the network. This seems like an easy task, but the tricky thing was that the resolution was too big for my iPad (the audio receiving device) to handle. So only the audio should be streamed, in sync.

The solution to the problem stated above is transcoding via VLC. Unfortunately, the streaming syntax is badly documented. So here is my step by step solution.

Duplicate

First thing we gotta do is to split the original stream into two parts: One to display locally and the other can be streamed.

:sout=#duplicate{dst="…",dst="…",select="audio,video,nospu"}


Streaming Audio Only

This is pretty much straight forward: Create a transcode with no video codec.

transcode{vcodec=none,acodec=mp4a,ab=128,channels=2,samplerate=48000}


The newly transcoded stream has to be send via network to our sound device. I am using RTSP for this.

transcode{vcodec=none,acodec=mp4a,ab=128,channels=2,samplerate=48000}:rtp{sdp=rtsp://:8554/}


Showing Things Locally

The following part is a bit more complex than it should be. The reason is that VLC kept displaying subtitles. So in order to filter these out, I transcoded the local stream and set no proper scodec.

transcode{vcodec=h264,acodec=mp4a,scodec=bla}:display{delay=1000}


Not sure if I got lucky, but 1000ms was the exact amount delay I had to apply to keep the video and audio in sync.

Putting things together

Here is the final pipeline.

:sout=#duplicate{dst="transcode{vcodec=h264,acodec=mp4a,scodec=bla}:display{delay=1000}",dst="transcode{vcodec=none,acodec=mp4a,ab=128,channels=2,samplerate=48000}:rtp{sdp=rtsp://:8554/}",select="audio,video,nospu"}


Select the file you want to view in the Stream view and skip through to the end. Enter the above code into the textarea and click stream. You should now see media (and stream the audio across the network).

Update 2016-03-08

Instead of reencoding the local stream we can just keep the original data. As my VLC had trouble finding the AAC encoder I switched to wav (s16l).

:sout=#duplicate{dst="transcode{scodec=bla}:display{delay=1300}",dst="transcode{vcodec=none,acodec=s16l,ab=128,channels=2,samplerate=48000}:rtp{sdp=rtsp://:8554/}",select="audio,video,nospu"} :sout-keep