1

I use VLC media player 2.2.8 Weatherwax (revision 2.2.7-14-g3cc1d8cba9), installed from my distrib repo (Arch Linux). My purpose is to create a command which records a video of my desktop, with audio input from micro.

After some research, I've used this command :

vlc screen:// 
:screen-fps=24 
:screen-follow-mouse 
:screen-mouse-image=cursor.png 
:input-slave=alsa://hw:1,0
:sout="#transcode{vcodec=h264,venc=x264,vb=2048,acodec=mp3,scale=1.0,vfilter=croppadd{cropleft=0,croptop=0,cropright=0,cropbottom=0}}:duplicate{dst=std{mux=mp4,access=file,dst=out.mp4}}"

I tested it for a ~1mn video, and it worked without any noticeable issue. Then I recorded an ~1h video, and the result is the following : Link to image (imgur).

The values are approximative. The audio lag begins with ~3s, and finishes with ~3mn. Except the lag, video and audio work properly.

Why is there an audio lag ? Is it due to some sort of compression, or some reasons like "the micro input is slower than screen video capture" ?

Thank you for your answer.

1 Answer 1

0

Ok, I think I have found a solution. Please correct me if I'm wrong.

Solution

vlc screen:// 
:screen-fps=24 

...

:sout="#transcode{...fps=24}...

The solution is to specify the same fps in the transcode option than in the :screen-fps option.

Complete command (for reference) :

vlc screen:// 
:screen-fps=24 
:screen-follow-mouse 
:screen-mouse-image=cursor.png 
:input-slave=alsa://hw:1,0
:sout="#transcode{vcodec=h264,venc=x264,vb=2048,acodec=mp3,scale=1.0,vfilter=croppadd{cropleft=0,croptop=0,cropright=0,cropbottom=0},fps=24}:duplicate{dst=std{mux=mp4,access=file,dst=out.mp4}}"

Details

By default, VLC has :

  • an input of 500 000 µs,
  • an output of 40 000 µs.

You can see it in the console after the vlc command : Link to image (imgur).

  • The :screen-fps=24 option provides the stream_out_transcode stream out: input interval 41666 (base 1) option to VLC.
  • The fps=24 in transcode option provides the stream_out_transcode stream out: output interval 41666 (base 1) option to VLC.

If I am right, to obtain 41666 from 24 fps (or Hz), we need to do the following operation : 10^6 / 24 = 41666.66666... ~= 41666 µs

In my original post, I did not define fps=24 in the transcode option. So, the default value for output interval was 40 000 µs.

If I consider my video is 3600 s long, and I do the following operation : 3600 * (1-40000/41666) = 143.9447 seconds.

It is > 2mn, and it corresponds with the observed delta.

Result with correct options : Link to image (imgur).


Remark

Although it exists a parameter audio-sync in transcode option, it didn't work as I expected. Only adding fps parameter did the trick.


References

You can find references here :

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .