audio-sync with #duplicate to separate raw output files

About encoding, codec settings, muxers and filter usage
tvtalkshowshigh
Blank Cone
Blank Cone
Posts: 95
Joined: 13 Jun 2005 12:36
Location: UK

audio-sync with #duplicate to separate raw output files

Postby tvtalkshowshigh » 28 Nov 2013 15:42

I'm using VLC to receive a 30Mbps H.264 RTP stream, which I would then like to decode and output to separate files of raw audio and video data.

This is the command line I use:

Code: Select all

vlc -vvv -I dummy --extraintf http --http-port=9090 /home/npf/in.sdp --sout '#duplicate{dst="transcode{vcodec=UYVY}:std{mux=raw,access=file,dst=/tmp/video.uyvy422}",select="noaudio",dst="transcode{acodec=s16l}:std{mux=raw,access=file,dst=/tmp/audio.s16l}",select="novideo"}'
This works, except when the network stream is corrupted. If VLC can't decode a frame it simply drops it, so I end up with the raw audio file being of longer duration than the raw video file. There is no way to correct this because I don't know which frames of video were dropped.

If I open the stream in the normal VLC desktop interface then it corrects this problem by duplicating video frames to fill the gaps left by the frames it could not decode.

I had a look for a command line option to do this and found two:
audio-sync
When this option is enabled, VLC will drop/duplicate video frames to synchronize the video track on the audio track.
which appears to be related to the 'transcode' output module, and;
--sout-transcode-audio-sync, --no-sout-transcode-audio-sync
Synchronise on audio track (default disabled)
This option will drop/duplicate video frames to synchronise the video track on the audio track. (default disabled)
which I suppose is an '--sout' option.

Having still not mastered the intricacies of the VLC command line, I've used them in places that seem correct and don't cause complaints from VLC:

Code: Select all

vlc -vvv -I dummy --extraintf http --http-port=9090 /home/npf/in.sdp --sout-transcode-audio-sync --sout '#duplicate{dst="transcode{vcodec=UYVY,audio-sync}:std{mux=raw,access=file,dst=/tmp/video.uyvy422}",select="noaudio",dst="transcode{acodec=s16l,audio-sync}:std{mux=raw,access=file,dst=/tmp/audio.s16l}",select="novideo"}'
However, that doesn't seem to have any effect, other than causing VLC to output some errors:

Code: Select all

[0x7ffde8004bd8] stream_out_transcode stream out debug: drift is too high, resetting master sync [0x7ffddc000ff8] avcodec encoder warning: almost fed libavcodec with two frames with the same PTS (4846610504)
Google and the forum search don't find any complaints about the audio-sync options not working, so I assume it's because of the way I'm separating the audio and video. Does #duplicate cause the two transcodes to behave totally separately? If so, can someone suggest an alternative command line that will achieve what I'm trying to do?

VLC reports its version as: 2.0.8 Twoflower (2.0.8a-0-g68cf50b)
I'm running Ubuntu 12.04 with kernel 3.2.0-54-generic, in case that's relevant.

Many thanks.

tvtalkshowshigh
Blank Cone
Blank Cone
Posts: 95
Joined: 13 Jun 2005 12:36
Location: UK

Re: audio-sync with #duplicate to separate raw output files

Postby tvtalkshowshigh » 29 Nov 2013 11:18

After a bit more digging it looks like what I wanted to do can't really be done in that way. The #duplicate causes the two transcode pipelines to be treated totally separately. If I do the transcode before the duplicate then VLC can't tell what's video and what's audio - it's raw data after all. This all makes good sense really.

The best solution I can come up with so far is to transcode the input to UYVY+PCM and wrap that in an MKV, which I then pipe to separate VLC process that unwraps that to the individual raw video and audio files. That way VLC's audio-sync option should be applied when creating essence for the MKV. The only problem I can foresee is if the audio and video streams start at different points.

So, Is there a way to tell VLC to generate silence if it doesn't have audio with a matching presentation timestamp for the video it's receiving?

Thanks.

tvtalkshowshigh
Blank Cone
Blank Cone
Posts: 95
Joined: 13 Jun 2005 12:36
Location: UK

Re: audio-sync with #duplicate to separate raw output files

Postby tvtalkshowshigh » 03 Dec 2013 12:56

VLC's MKV support seems lacking. I used ffmpeg in the end.

Ta.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 2 guests