[FFmpeg-user] Unable to capture audio and video synced

Leonardo Soares Müller leozinho29_eu at hotmail.com
Wed May 24 02:16:52 EEST 2017

Em 23/05/2017 17:16, Carl Eugen Hoyos escreveu:
> 2017-05-23 19:11 GMT+02:00 Leonardo Soares Müller <leozinho29_eu at hotmail.com>:
>> To record speakers and microphone, I use pulse.
> (If there really is an issue, it is unclear for me from your report:)
> Please also test alsa if possible.
While I can record the microphone without (apparent) problems, if I try 
to record the speakers sound with alsa I hear nothingwhile it is being 

The pulse recording has more problems: after I started the recording, if 
I open an application with a sound stream (then visible on pavucontrol), 
then all the sound gets delayed. This is not observed with parec and 
kazam (which, apparently, uses GStreamer).This is very noticeable with 
applications that use SDL, for example, mednafen. Not only the delay 
increases, but the sound gets distorted too, as if started to play 
faster due to the delay.

I have just downloaded and built ffmpeg snapshot. Then I recorded the 
screen using the following command:

env PULSE_LATENCY_MSEC=20 ffmpeg -vaapi_device /dev/dri/renderD128 
-hwaccel vaapi -hwaccel_output_format yuv420p -thread_queue_size 16384 
-f pulse -sample_rate 44100 -channels 2 -i 
alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -thread_queue_size 
16384 -f x11grab -s 1366x768 -framerate 30 -i :0.0 -acodec libfdk_aac 
-b:a 160k -vf format=nv12,hwupload,scale_vaapi=w=1280:h=720 -vcodec 
h264_vaapi -qp 20 -f flv -shortest SDL000.flv

Soon after I started the recording, I opened mednafen and then some 
messages started to appear. The output had messages like "Past duration 
0.880180 too large". Here is it complete:

ffmpeg version N-86241-gfb75ad7 Copyright (c) 2000-2017 the FFmpeg 
   built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
   configuration: --enable-shared --enable-avresample --enable-avisynth 
--enable-gnutls --enable-ladspa --enable-libass --enable-libbluray 
--enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite 
--enable-libfontconfig --enable-libfreetype --enable-libfribidi 
--enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame 
--enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp 
--enable-libschroedinger --enable-libshine --enable-libsnappy 
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora 
--enable-libtwolame --enable-libvorbis --enable-libvpx 
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid 
--enable-libzvbi --enable-openal --enable-opengl --enable-libdc1394 
--enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 
--enable-libopencv --enable-libfdk-aac --enable-libmfx --enable-vaapi 
--enable-nonfree --enable-gpl --enable-libxcb --enable-libxcb-shm 
--enable-libxcb-xfixes --enable-libxcb-shape --enable-ffplay
   libavutil      55. 63.100 / 55. 63.100
   libavcodec     57. 96.101 / 57. 96.101
   libavformat    57. 72.101 / 57. 72.101
   libavdevice    57.  7.100 / 57.  7.100
   libavfilter     6. 90.100 /  6. 90.100
   libavresample   3.  6.  0 /  3.  6.  0
   libswscale      4.  7.101 /  4.  7.101
   libswresample   2.  8.100 /  2.  8.100
   libpostproc    54.  6.100 / 54.  6.100
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, pulse, from 'alsa_output.pci-0000_00_1f.3.analog-stereo.monitor':
   Duration: N/A, start: 1495580627.717112, bitrate: 1411 kb/s
     Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
[x11grab @ 0xa07240] Stream #0: not enough frames to estimate rate; 
consider increasing probesize
Input #1, x11grab, from ':0.0':
   Duration: N/A, start: 1495580628.116939, bitrate: N/A
     Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1366x768, 
30 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
   Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
   Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[swscaler @ 0xa21100] Warning: data is not aligned! This can lead to a 
Output #0, flv, to 'SDL000.flv':
     encoder         : Lavf57.72.101
     Stream #0:0: Video: h264 (h264_vaapi) (High) ([7][0][0][0] / 
0x0007), vaapi_vld(progressive), 1280x720, q=0-31, 30 fps, 1k tbn, 30 tbc
       encoder         : Lavc57.96.101 h264_vaapi
     Stream #0:1: Audio: aac (libfdk_aac) ([10][0][0][0] / 0x000A), 
44100 Hz, stereo, s16, 160 kb/s
       encoder         : Lavc57.96.101 libfdk_aac
frame=   17 fps=0.0 q=-0.0 size=     591kB time=00:00:00.44 
bitrate=10924.6kbits/s speed=0.87frame=   32 fps= 31 q=-0.0 size=     
687kB time=00:00:00.94 bitrate=5975.8kbits/s speed=0.915frame=   48 fps= 
31 q=-0.0 size=     796kB time=00:00:01.47 bitrate=4432.3kbits/s 
speed=0.958frame=   63 fps= 31 q=-0.0 size=     896kB time=00:00:01.96 
bitrate=3730.5kbits/s speed=0.966frame=   78 fps= 31 q=-0.0 size=    
1031kB time=00:00:02.46 bitrate=3422.1kbits/s speed=0.967frame=   94 
fps= 31 q=-0.0 size=    1126kB time=00:00:03.00 bitrate=3069.5kbits/s 
speed=0.981frame=  107 fps= 30 q=-0.0 size=    1208kB time=00:00:03.44 
bitrate=2876.2kbits/s speed=0.966frame=  123 fps= 30 q=-0.0 size=    
1301kB time=00:00:03.96 bitrate=2685.1kbits/s speed=0.976frame=  139 
fps= 30 q=-0.0 size=    1561kB time=00:00:04.50 bitrate=2840.5kbits/s 
speed=0.986frame=  154 fps= 30 q=-0.0 size=    1651kB time=00:00:05.00 
bitrate=2702.7kbits/s speed=0.984frame=  169 fps= 30 q=-0.0 size=    
1751kB time=00:00:05.50 bitrate=2607.9kbits/s speed=0.984frame=  184 
fps= 30 q=-0.0 size=    1843kB time=00:00:06.00 bitrate=2515.8kbits/s 
speed=0.985frame=  198 fps= 30 q=-0.0 size=    1935kB time=00:00:06.46 
bitrate=2451.1kbits/s speed=0.979frame=  215 fps= 30 q=-0.0 size=    
2049kB time=00:00:07.04 bitrate=2383.6kbits/s speed=0.99xframe=  230 
fps= 30 q=-0.0 size=    2146kB time=00:00:07.53 bitrate=2333.5kbits/s 
speed=0.99xframe=  245 fps= 30 q=-0.0 size=    2428kB time=00:00:08.03 
bitrate=2474.9kbits/s speed=0.99xframe=  260 fps= 30 q=-0.0 size=    
2518kB time=00:00:08.53 bitrate=2416.7kbits/s speed=0.99xframe=  276 
fps= 30 q=-0.0 size=    2636kB time=00:00:09.07 bitrate=2379.7kbits/s 
speed=0.994frame=  289 fps= 30 q=-0.0 size=    2741kB time=00:00:09.50 
bitrate=2363.6kbits/s speed=0.984frame=  304 fps= 30 q=-0.0 size=    
2831kB time=00:00:10.00 bitrate=2318.1kbits/s speed=0.983Past duration 
0.812965 too large
frame=  322 fps= 30 q=-0.0 size=    3194kB time=00:00:10.63 
bitrate=2460.8kbits/s speed=0.995Past duration 0.880180 too large
frame=  336 fps= 30 q=-0.0 size=    3543kB time=00:00:11.10 
bitrate=2613.0kbits/s speed=0.993Past duration 0.974129 too large
frame=  352 fps= 30 q=-0.0 size=    3614kB time=00:00:11.63 
bitrate=2543.9kbits/s speed=0.992frame=  367 fps= 30 q=-0.0 size=    
3793kB time=00:00:12.15 bitrate=2556.9kbits/s speed=0.993frame=  383 
fps= 30 q=-0.0 size=    3885kB time=00:00:12.66 bitrate=2512.6kbits/s 
speed=0.993frame=  400 fps= 30 q=-0.0 size=    3906kB time=00:00:13.24 
bitrate=2416.3kbits/s speed=0.999frame=  415 fps= 30 q=-0.0 size=    
3983kB time=00:00:13.73 bitrate=2376.0kbits/s speed=0.998Past duration 
0.983528 too large
frame=  428 fps= 30 q=-0.0 size=    4323kB time=00:00:14.17 
bitrate=2499.0kbits/s speed=0.993Past duration 0.921227 too large
frame=  444 fps= 30 q=-0.0 size=    4687kB time=00:00:14.70 
bitrate=2610.8kbits/s speed=0.996frame=  460 fps= 30 q=-0.0 size=    
5002kB time=00:00:15.24 bitrate=2688.6kbits/s speed=0.995frame=  476 
fps= 30 q=-0.0 size=    5142kB time=00:00:15.77 bitrate=2670.4kbits/s 
speed=0.994frame=  491 fps= 30 q=-0.0 size=    5199kB time=00:00:16.26 
bitrate=2618.0kbits/s speed=0.994frame=  507 fps= 30 q=-0.0 size=    
5238kB time=00:00:16.80 bitrate=2554.0kbits/s speed=0.995frame=  522 
fps= 30 q=-0.0 size=    5263kB time=00:00:17.30 bitrate=2491.2kbits/s 
speed=0.995frame=  539 fps= 30 q=-0.0 size=    5377kB time=00:00:17.86 
bitrate=2465.1kbits/s speed=0.998Past duration 0.986336 too large
frame=  552 fps= 30 q=-0.0 size=    5422kB time=00:00:18.30 
bitrate=2426.7kbits/s speed=0.994Past duration 0.878105 too large
frame=  568 fps= 30 q=-0.0 size=    5484kB time=00:00:18.83 
bitrate=2384.8kbits/s speed=0.995frame=  583 fps= 30 q=-0.0 size=    
5538kB time=00:00:19.33 bitrate=2346.6kbits/s speed=0.994frame=  600 
fps= 30 q=-0.0 size=    5598kB time=00:00:19.90 bitrate=2304.5kbits/s 
speed=0.997Past duration 0.818199 too large
frame=  615 fps= 30 q=-0.0 size=    5669kB time=00:00:20.40 
bitrate=2275.9kbits/s speed=0.996frame=  631 fps= 30 q=-0.0 size=    
5726kB time=00:00:20.94 bitrate=2240.0kbits/s speed=0.997Past duration 
0.957954 too large
frame=  646 fps= 30 q=-0.0 size=    5779kB time=00:00:21.43 
bitrate=2208.6kbits/s speed=0.996frame=  662 fps= 30 q=-0.0 size=    
5835kB time=00:00:21.96 bitrate=2176.1kbits/s speed=0.997frame=  677 
fps= 30 q=-0.0 size=    5889kB time=00:00:22.47 bitrate=2146.6kbits/s 
speed=0.997Past duration 0.985390 too large
frame=  693 fps= 30 q=-0.0 size=    5945kB time=00:00:23.00 
bitrate=2116.8kbits/s speed=0.997Past duration 0.988029 too large
frame=  708 fps= 30 q=-0.0 size=    6000kB time=00:00:23.51 
bitrate=2090.1kbits/s speed=0.997frame=  723 fps= 30 q=-0.0 size=    
6053kB time=00:00:24.00 bitrate=2065.8kbits/s speed=0.996frame=  740 
fps= 30 q=-0.0 size=    6138kB time=00:00:24.56 bitrate=2046.7kbits/s 
speed=0.999frame=  755 fps= 30 q=-0.0 size=    6198kB time=00:00:25.06 
bitrate=2025.5kbits/s speed=0.998frame=  770 fps= 30 q=-0.0 size=    
6260kB time=00:00:25.56 bitrate=2005.6kbits/s speed=0.998Past duration 
0.961357 too large
Past duration 0.990959 too large
frame=  784 fps= 30 q=-0.0 size=    6320kB time=00:00:26.04 
bitrate=1987.8kbits/s speed=0.997Past duration 0.998009 too large
frame=  799 fps= 30 q=-0.0 size=    6384kB time=00:00:26.53 
bitrate=1971.0kbits/s speed=0.996frame=  816 fps= 30 q=-0.0 size=    
6457kB time=00:00:27.11 bitrate=1950.9kbits/s speed=0.997Past duration 
0.918739 too large
frame=  832 fps= 30 q=-0.0 size=    6519kB time=00:00:27.63 
bitrate=1932.6kbits/s speed=0.998Past duration 0.953880 too large
Past duration 0.985588 too large
frame=  846 fps= 30 q=-0.0 size=    6596kB time=00:00:28.11 
bitrate=1922.3kbits/s speed=0.996frame=  863 fps= 30 q=-0.0 size=    
6669kB time=00:00:28.66 bitrate=1905.6kbits/s speed=0.998frame=  878 
fps= 30 q=-0.0 size=    6734kB time=00:00:29.20 bitrate=1889.2kbits/s 
speed=0.999frame=  893 fps= 30 q=-0.0 size=    6796kB time=00:00:29.66 
bitrate=1876.4kbits/s speed=0.998frame=  909 fps= 30 q=-0.0 size=    
6863kB time=00:00:30.20 bitrate=1861.5kbits/s speed=0.997frame=  925 
fps= 30 q=-0.0 size=    6929kB time=00:00:30.73 bitrate=1846.9kbits/s 
speed=0.998frame=  939 fps= 30 q=-0.0 size=    6989kB time=00:00:31.20 
bitrate=1835.1kbits/s speed=0.997frame=  955 fps= 30 q=-0.0 size=    
7049kB time=00:00:31.73 bitrate=1819.6kbits/s speed=0.998frame=  970 
fps= 30 q=-0.0 size=    7199kB time=00:00:32.24 bitrate=1829.0kbits/s 
speed=0.998frame=  984 fps= 30 q=-0.0 size=    7496kB time=00:00:32.70 
bitrate=1877.6kbits/s speed=0.996frame= 1001 fps= 30 q=-0.0 size=    
7761kB time=00:00:33.26 bitrate=1911.1kbits/s speed=0.998frame= 1017 
fps= 30 q=-0.0 size=    7836kB time=00:00:33.80 bitrate=1899.1kbits/s 
speed=0.998frame= 1032 fps= 30 q=-0.0 size=    7865kB time=00:00:34.31 
bitrate=1877.9kbits/s speed=0.997frame= 1048 fps= 30 q=-0.0 size=    
8039kB time=00:00:34.84 bitrate=1889.9kbits/s speed=0.998frame= 1064 
fps= 30 q=-0.0 size=    8429kB time=00:00:35.37 bitrate=1951.9kbits/s 
speed=0.998frame= 1080 fps= 30 q=-0.0 size=    8579kB time=00:00:35.93 
bitrate=1955.7kbits/s speed=0.999frame= 1095 fps= 30 q=-0.0 size=    
8711kB time=00:00:36.40 bitrate=1960.5kbits/s speed=0.998frame= 1110 
fps= 30 q=-0.0 size=    9053kB time=00:00:36.91 bitrate=2009.1kbits/s 
speed=0.998frame= 1126 fps= 30 q=-0.0 size=    9299kB time=00:00:37.44 
bitrate=2034.4kbits/s speed=0.998Past duration 0.984886 too large
frame= 1141 fps= 30 q=-0.0 size=    9400kB time=00:00:37.93 
bitrate=2030.0kbits/s speed=0.997frame= 1157 fps= 30 q=-0.0 size=    
9592kB time=00:00:38.48 bitrate=2041.6kbits/s speed=0.998frame= 1173 
fps= 30 q=-0.0 size=    9614kB time=00:00:39.02 bitrate=2018.2kbits/s 
speed=0.999frame= 1187 fps= 30 q=-0.0 size=    9630kB time=00:00:39.46 
bitrate=1998.7kbits/s speed=0.997frame= 1203 fps= 30 q=-0.0 size=    
9858kB time=00:00:40.00 bitrate=2018.8kbits/s speed=0.998frame= 1219 
fps= 30 q=-0.0 size=   10314kB time=00:00:40.55 bitrate=2083.3kbits/s 
speed=0.999Past duration 0.917915 too large
frame= 1235 fps= 30 q=-0.0 size=   10665kB time=00:00:41.06 
bitrate=2127.4kbits/s speed=0.999frame= 1249 fps= 30 q=-0.0 size=   
10980kB time=00:00:41.53 bitrate=2165.7kbits/s speed=0.998Past duration 
0.949638 too large
frame= 1265 fps= 30 q=-0.0 size=   11364kB time=00:00:42.06 
bitrate=2213.0kbits/s speed=0.998frame= 1280 fps= 30 q=-0.0 size=   
11718kB time=00:00:42.57 bitrate=2254.7kbits/s speed=0.998frame= 1296 
fps= 30 q=-0.0 size=   12086kB time=00:00:43.11 bitrate=2296.6kbits/s 
speed=0.998frame= 1310 fps= 30 q=-0.0 size=   12367kB time=00:00:43.57 
bitrate=2325.0kbits/s speed=0.997frame= 1327 fps= 30 q=-0.0 size=   
12511kB time=00:00:44.13 bitrate=2322.3kbits/s speed=0.999frame= 1342 
fps= 30 q=-0.0 size=   12908kB time=00:00:44.64 bitrate=2368.6kbits/s 
speed=0.998frame= 1357 fps= 30 q=-0.0 size=   12923kB time=00:00:45.13 
bitrate=2345.6kbits/s speed=0.998frame= 1372 fps= 30 q=-0.0 size=   
12937kB time=00:00:45.64 bitrate=2322.1kbits/s speed=0.998frame= 1388 
fps= 30 q=-0.0 size=   12952kB time=00:00:46.17 bitrate=2297.8kbits/s 
speed=0.998frame= 1404 fps= 30 q=-0.0 size=   12974kB time=00:00:46.70 
bitrate=2275.8kbits/s speed=0.998frame= 1419 fps= 30 q=-0.0 size=   
13031kB time=00:00:47.21 bitrate=2261.1kbits/s speed=0.998frame= 1435 
fps= 30 q=-0.0 size=   13225kB time=00:00:47.73 bitrate=2269.6kbits/s 
speed=0.999frame= 1451 fps= 30 q=-0.0 size=   13312kB time=00:00:48.26 
bitrate=2259.2kbits/s speed=0.999Past duration 0.999184 too large
frame= 1466 fps= 30 q=-0.0 size=   13353kB time=00:00:48.76 
bitrate=2243.0kbits/s speed=0.999frame= 1479 fps= 30 q=-0.0 size=   
13396kB time=00:00:49.21 bitrate=2230.0kbits/s speed=0.998frame= 1495 
fps= 30 q=-0.0 size=   13450kB time=00:00:49.74 bitrate=2215.0kbits/s 
speed=0.998frame= 1510 fps= 30 q=-0.0 size=   13502kB time=00:00:50.23 
bitrate=2201.9kbits/s speed=0.998frame= 1527 fps= 30 q=-0.0 size=   
13564kB time=00:00:50.81 bitrate=2186.8kbits/s speed=0.999frame= 1541 
fps= 30 q=-0.0 size=   13605kB time=00:00:51.27 bitrate=2173.6kbits/s 
speed=0.998Past duration 0.957832 too large
frame= 1557 fps= 30 q=-0.0 size=   13656kB time=00:00:51.81 
bitrate=2159.3kbits/s speed=0.998frame= 1571 fps= 30 q=-0.0 size=   
13743kB time=00:00:52.27 bitrate=2153.7kbits/s speed=0.998frame= 1588 
fps= 30 q=-0.0 size=   13831kB time=00:00:52.87 bitrate=2142.7kbits/s 
speed=0.999frame= 1603 fps= 30 q=-0.0 size=   13871kB time=00:00:53.34 
bitrate=2130.3kbits/s speed=0.998frame= 1619 fps= 30 q=-0.0 size=   
13922kB time=00:00:53.87 bitrate=2117.0kbits/s speed=0.999frame= 1634 
fps= 30 q=-0.0 size=   13974kB time=00:00:54.36 bitrate=2105.6kbits/s 
speed=0.998Past duration 0.978645 too large
frame= 1650 fps= 30 q=-0.0 size=   14096kB time=00:00:54.94 
bitrate=2101.7kbits/s speed=   1xPast duration 0.988838 too large
frame= 1665 fps= 30 q=-0.0 size=   14141kB time=00:00:55.40 
bitrate=2090.8kbits/s speed=0.999Past duration 0.990135 too large
Past duration 0.970406 too large
frame= 1680 fps= 30 q=-0.0 size=   14181kB time=00:00:55.90 
bitrate=2078.2kbits/s speed=0.999frame= 1695 fps= 30 q=-0.0 size=   
14264kB time=00:00:56.40 bitrate=2071.7kbits/s speed=0.998frame= 1711 
fps= 30 q=-0.0 size=   14325kB time=00:00:56.93 bitrate=2061.0kbits/s 
speed=0.998Past duration 0.991936 too large
frame= 1728 fps= 30 q=-0.0 size=   14425kB time=00:00:57.54 
bitrate=2053.6kbits/s speed=   1xframe= 1743 fps= 30 q=-0.0 size=   
14475kB time=00:00:58.00 bitrate=2044.2kbits/s speed=0.999frame= 1759 
fps= 30 q=-0.0 size=   14520kB time=00:00:58.53 bitrate=2032.1kbits/s 
speed=0.998frame= 1774 fps= 30 q=-0.0 size=   14562kB time=00:00:59.04 
bitrate=2020.5kbits/s speed=0.998Past duration 0.957558 too large
frame= 1790 fps= 30 q=-0.0 size=   14607kB time=00:00:59.57 
bitrate=2008.6kbits/s speed=0.999frame= 1805 fps= 30 q=-0.0 size=   
14897kB time=00:01:00.06 bitrate=2031.7kbits/s speed=0.999frame= 1820 
fps= 30 q=-0.0 size=   15372kB time=00:01:00.57 bitrate=2078.8kbits/s 
speed=0.999frame= 1835 fps= 30 q=-0.0 size=   15932kB time=00:01:01.06 
bitrate=2137.1kbits/s speed=0.998frame= 1851 fps= 30 q=-0.0 size=   
16420kB time=00:01:01.62 bitrate=2183.0kbits/s speed=0.999Past duration 
0.976585 too large
frame= 1867 fps= 30 q=-0.0 size=   16813kB time=00:01:02.13 
bitrate=2216.7kbits/s speed=0.999frame= 1882 fps= 30 q=-0.0 size=   
17058kB time=00:01:02.64 bitrate=2230.7kbits/s speed=0.999Past duration 
0.861092 too large
frame= 1897 fps= 30 q=-0.0 size=   17089kB time=00:01:03.13 
bitrate=2217.3kbits/s speed=0.998frame= 1914 fps= 30 q=-0.0 size=   
17139kB time=00:01:03.70 bitrate=2204.0kbits/s speed=0.999Past duration 
0.966194 too large
frame= 1928 fps= 30 q=-0.0 size=   17516kB time=00:01:04.16 
bitrate=2236.2kbits/s speed=0.999frame= 1944 fps= 30 q=-0.0 size=   
17576kB time=00:01:04.74 bitrate=2224.0kbits/s speed= 1xframe= 1959 fps= 
30 q=-0.0 size=   17626kB time=00:01:05.20 bitrate=2214.5kbits/s 
speed=0.999frame= 1975 fps= 30 q=-0.0 size=   17647kB time=00:01:05.74 
bitrate=2199.0kbits/s speed=0.999frame= 1989 fps= 30 q=-0.0 size=   
17959kB time=00:01:06.20 bitrate=2222.3kbits/s speed=0.999frame= 2005 
fps= 30 q=-0.0 size=   18293kB time=00:01:06.73 bitrate=2245.4kbits/s 
speed=0.999frame= 2021 fps= 30 q=-0.0 size=   18312kB time=00:01:07.27 
bitrate=2229.9kbits/s speed=0.999frame= 2038 fps= 30 q=-0.0 size=   
18630kB time=00:01:07.83 bitrate=2249.9kbits/s speed=0.999Past duration 
0.993843 too large
frame= 2051 fps= 30 q=-0.0 size=   18951kB time=00:01:08.27 
bitrate=2274.0kbits/s speed=0.998frame= 2067 fps= 30 q=-0.0 size=   
19017kB time=00:01:08.80 bitrate=2264.2kbits/s speed=0.999frame= 2083 
fps= 30 q=-0.0 size=   19176kB time=00:01:09.33 bitrate=2265.5kbits/s 
speed=0.998Past duration 0.919121 too large
frame= 2098 fps= 30 q=-0.0 size=   19275kB time=00:01:09.83 
bitrate=2261.1kbits/s speed=0.998Past duration 0.921806 too large
frame= 2115 fps= 30 q=-0.0 size=   19295kB time=00:01:10.40 
bitrate=2245.3kbits/s speed=0.999frame= 2129 fps= 30 q=-0.0 size=   
19371kB time=00:01:10.86 bitrate=2239.2kbits/s speed=0.998frame= 2145 
fps= 30 q=-0.0 size=   19729kB time=00:01:11.40 bitrate=2263.6kbits/s 
speed=0.998frame= 2162 fps= 30 q=-0.0 size=   20126kB time=00:01:11.97 
bitrate=2290.8kbits/s speed=0.999frame= 2177 fps= 30 q=-0.0 size=   
20546kB time=00:01:12.46 bitrate=2322.6kbits/s speed=0.999frame= 2192 
fps= 30 q=-0.0 size=   20911kB time=00:01:12.99 bitrate=2346.9kbits/s 
speed=   1xframe= 2207 fps= 30 q=-0.0 size=   21359kB time=00:01:13.47 
bitrate=2381.3kbits/s speed=0.999Past duration 0.994209 too large
Past duration 0.970543 too large
frame= 2224 fps= 30 q=-0.0 size=   21601kB time=00:01:14.04 
bitrate=2389.8kbits/s speed=0.999frame= 2239 fps= 30 q=-0.0 size=   
21740kB time=00:01:14.53 bitrate=2389.4kbits/s speed=0.999frame= 2254 
fps= 30 q=-0.0 size=   21885kB time=00:01:15.04 bitrate=2389.2kbits/s 
speed=0.998frame= 2272 fps= 30 q=-0.0 size=   22054kB time=00:01:15.64 
bitrate=2388.3kbits/s speed=   1xframe= 2286 fps= 30 q=-0.0 size=   
22422kB time=00:01:16.11 bitrate=2413.3kbits/s speed=0.999frame= 2290 
fps= 30 q=-0.0 Lsize=   22511kB time=00:01:16.30 bitrate=2416.9kbits/s 
speed=   1x
video:20917kB audio:1495kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: 0.445482%

>> The command I used to record was:
>> env PULSE_LATENCY_MSEC=20 ffmpeg -vaapi_device /dev/dri/renderD128
>> -hwaccel vaapi -hwaccel_output_format yuv420p -thread_queue_size 16384
>> -f pulse -sample_rate 44100 -channels 2 -i
>> alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -thread_queue_size
>> 16384 -f x11grab -s 1366x768 -r 30 -i :0.0 -acodec libfdk_aac -b:a 160k
> Remove -r 30, the correct option is "framerate" iirc.
Corrected, thank you.
>> -vf format=nv12,hwupload,scale_vaapi=w=960:h=540 -vcodec h264_vaapi
>> -qp 20 -f flv -shortest TEST001.flv
> [...]
After searching in the Internet, I have found this solution to use 
hardware encoding (VA-API). Software encoding is much slower and more 
demanding than VAAPI. Is something wrong on this particular command segment?
>> After I have recorded it, I have separated the video and audio from the
>> resulting file in two files
> Do you mean you did not test A/V sync on the file that was recorded
> with FFmpeg?
> You (generally) cannot "separate" a media file and expect A/V sync
> to be preserved, for screen recording, a (very large) length difference
> between audio and video is expected.
I believe I was not clear, sorry. I have noticed the problem in the file 
with video and audio together. I just separated them to see how big was 
this error. On VLC it is good, on Kdenlive and YouTube it is out of 
sync.As in the terminal is shown:

Input #0, pulse, from 'alsa_output.pci-0000_00_1f.3.analog-stereo.monitor':
   Duration: N/A, start: 1495580627.717112, bitrate: 1411 kb/s
     Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
[x11grab @ 0xa07240] Stream #0: not enough frames to estimate rate; 
consider increasing probesize
Input #1, x11grab, from ':0.0':
   Duration: N/A, start: 1495580628.116939, bitrate: N/A
     Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1366x768, 
30 fps, 1000k tbr, 1000k tbn, 1000k tbc

The inputs start at different moments (1495580627.717112for audio and 
1495580628.116939for video), but end at the same time. Consequently, 
their length is different. I believe some media players dislike 
different lengths for the audio and video streams.

I would like to make them start at exactly the same moment, or ignore, 
for example, the first two second after the command was sent, making the 
record start at the same time for both, consequently, making both 
streams have the same duration.

Thank you.

More information about the ffmpeg-user mailing list