[FFmpeg-user] Audio/Video out of sync: -itsoffset value limit

MrNice wxcvbn2006 at iol.ie
Sun Nov 22 21:15:27 CET 2015


Hi,

I try to capture with the simplified command
./ffmpeg -debug 1 -f pulse -thread_queue_size 1024 -i
alsa_input.pci-0000_00_14.2.analog-stereo -f v4l2 -channel 1
-thread_queue_size 1024 -i /dev/video0 -c:v ffv1 -level 3 -g 1 -aspect
4:3 -pix_fmt yuv422p -top 0 -c:a pcm_s16le -channel_layout stereo
/Store3/Test/t_`date +%Y%m%d_%H%M`.mkv

I get audio out of sync late by 1.7 second.
If I add -itsoffset 0.70 to video input, I get audio just 1 second late.
But when I rise the value above 1.2, I get a lot of drops. I noticed as
well that above 1.0 the debug lines are output in burst with short
pauses between them. Pauses time increases with value.

What is/does the limit of -itsoffset value?

BTW, I tried with:
-af aresample=async=1 => Nothing better
-ts mono2abs/abs => Do nothing only start audio/video value closer
-Audio output before video output => Nothing
-vsync passthrough => Nothing
-ss 1.70: in video input => /dev/video0: could not seek to position
34725.055 and a lot of drops
-ss 1.70 in audio input => alsa_input.pci-0000_00_14.2.analog-stereo:
could not seek to position 1448217795.270
-ss 1.70: in output => Nothing
-threads 1 => Nothing

Is there another way to sync audio/video?
Any suggestion welcome.

Many thanks


./ffmpeg -debug 1 -f pulse -thread_queue_size 512 -i
alsa_input.pci-0000_00_14.2.analog-stereo -f v4l2 -channel 1
-thread_queue_size 2048 -itsoffset 1.70 -i /dev/video0 -c:v ffv1 -level
3 -g 1 -aspect 4:3 -pix_fmt yuv422p -top 0 -c:a pcm_s16le
-channel_layout stereo /Store3/Test/t_`date +%Y%m%d_%H%M`.mkv
ffmpeg version N-76674-g7ad698e Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 5.1.1 (GCC) 20150618 (Red Hat 5.1.1-4)
  configuration: --enable-libpulse --enable-gpl --enable-libx264
  libavutil      55.  6.100 / 55.  6.100
  libavcodec     57. 15.100 / 57. 15.100
  libavformat    57. 14.100 / 57. 14.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
 matched as AVOption 'debug' with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'pulse'.
Reading option '-thread_queue_size' ... matched as option
'thread_queue_size' (set the maximum number of queued packets from the
demuxer) with argument '512'.
Reading option '-i' ... matched as input file with argument
'alsa_input.pci-0000_00_14.2.analog-stereo'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'v4l2'.
Reading option '-channel' ... matched as AVOption 'channel' with
argument '1'.
Reading option '-thread_queue_size' ... matched as option
'thread_queue_size' (set the maximum number of queued packets from the
demuxer) with argument '2048'.
Reading option '-itsoffset' ... matched as option 'itsoffset' (set the
input ts offset) with argument '1.70'.
Reading option '-i' ... matched as input file with argument '/dev/video0'.
Reading option '-c:v' ... matched as option 'c' (codec name) with
argument 'ffv1'.
Reading option '-level' ... matched as AVOption 'level' with argument '3'.
Reading option '-g' ... matched as AVOption 'g' with argument '1'.
Reading option '-aspect' ... matched as option 'aspect' (set aspect
ratio (4:3, 16:9 or 1.3333, 1.7777)) with argument '4:3'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
format) with argument 'yuv422p'.
Reading option '-top' ... matched as option 'top'
(top=1/bottom=0/auto=-1 field first) with argument '0'.
Reading option '-c:a' ... matched as option 'c' (codec name) with
argument 'pcm_s16le'.
Reading option '-channel_layout' ... matched as option 'channel_layout'
(set channel layout) with argument 'stereo'.
Reading option '/Store3/Test/t_20151122_2006.mkv' ... matched as output
file.
Finished splitting the commandline.
Parsing a group of options: global .
Successfully parsed a group of options.
Parsing a group of options: input file
alsa_input.pci-0000_00_14.2.analog-stereo.
Applying option f (force format) with argument pulse.
Applying option thread_queue_size (set the maximum number of queued
packets from the demuxer) with argument 512.
Successfully parsed a group of options.
Opening an input file: alsa_input.pci-0000_00_14.2.analog-stereo.
[pulse @ 0x20c68e0] All info found
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, pulse, from 'alsa_input.pci-0000_00_14.2.analog-stereo':
  Duration: N/A, start: 1448222773.462464, bitrate: 1536 kb/s
    Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, 2 channels,
s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: input file /dev/video0.
Applying option f (force format) with argument v4l2.
Applying option thread_queue_size (set the maximum number of queued
packets from the demuxer) with argument 2048.
Applying option itsoffset (set the input ts offset) with argument 1.70.
Successfully parsed a group of options.
Opening an input file: /dev/video0.
[video4linux2,v4l2 @ 0x20e00a0] fd:8 capabilities:85220001
[video4linux2,v4l2 @ 0x20e00a0] Selecting input_channel: 1
[video4linux2,v4l2 @ 0x20e00a0] Current input_channel: 1, input_name:
S-Video, input_std: ffffff
[video4linux2,v4l2 @ 0x20e00a0] Querying the device for the current
frame size
[video4linux2,v4l2 @ 0x20e00a0] Setting frame size to 720x576
[video4linux2,v4l2 @ 0x20e00a0] Trying to set codec:rawvideo pix_fmt:yuv420p
    Last message repeated 1 times
[video4linux2,v4l2 @ 0x20e00a0] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x20e00a0] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x20e00a0] The V4L2 driver is using the interlaced mode
[video4linux2,v4l2 @ 0x20e00a0] Current standard: PAL, id: ff,
frameperiod: 1/25
[video4linux2,v4l2 @ 0x20e00a0] All info found
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 37609.172398, bitrate: 165888 kb/s
    Stream #1:0, 1, 1/1000000: Video: rawvideo, 1 reference frame (YUY2
/ 0x32595559), yuyv422, 720x576, 1/1000000, 165888 kb/s, 25 fps, 25 tbr,
1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: output file /Store3/Test/t_20151122_2006.mkv.
Applying option c:v (codec name) with argument ffv1.
Applying option aspect (set aspect ratio (4:3, 16:9 or 1.3333, 1.7777))
with argument 4:3.
Applying option pix_fmt (set pixel format) with argument yuv422p.
Applying option top (top=1/bottom=0/auto=-1 field first) with argument 0.
Applying option c:a (codec name) with argument pcm_s16le.
Applying option channel_layout (set channel layout) with argument stereo.
Successfully parsed a group of options.
Opening an output file: /Store3/Test/t_20151122_2006.mkv.
Successfully opened the file.
detected 8 logical cores
[graph 0 input from stream 1:0 @ 0x20eea20] Setting 'video_size' to
value '720x576'
[graph 0 input from stream 1:0 @ 0x20eea20] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 1:0 @ 0x20eea20] Setting 'time_base' to value
'1/1000000'
[graph 0 input from stream 1:0 @ 0x20eea20] Setting 'pixel_aspect' to
value '0/1'
[graph 0 input from stream 1:0 @ 0x20eea20] Setting 'sws_param' to value
'flags=2'
[graph 0 input from stream 1:0 @ 0x20eea20] Setting 'frame_rate' to
value '25/1'
[graph 0 input from stream 1:0 @ 0x20eea20] w:720 h:576 pixfmt:yuyv422
tb:1/1000000 fr:25/1 sar:0/1 sws_param:flags=2
[format @ 0x20f87c0] compat: called with args=[yuv422p]
[format @ 0x20f87c0] Setting 'pix_fmts' to value 'yuv422p'
[auto-inserted scaler 0 @ 0x20f94a0] Setting 'flags' to value 'bicubic'
[auto-inserted scaler 0 @ 0x20f94a0] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x20f87c0] auto-inserting filter 'auto-inserted scaler 0'
between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x20f6fa0] query_formats: 4 queried, 2 merged, 1
already done, 0 delayed
[auto-inserted scaler 0 @ 0x20f94a0] w:720 h:576 fmt:yuyv422 sar:0/1 ->
w:720 h:576 fmt:yuv422p sar:0/1 flags:0x4
[graph 1 input from stream 0:0 @ 0x2108680] Setting 'time_base' to value
'1/48000'
[graph 1 input from stream 0:0 @ 0x2108680] Setting 'sample_rate' to
value '48000'
[graph 1 input from stream 0:0 @ 0x2108680] Setting 'sample_fmt' to
value 's16'
[graph 1 input from stream 0:0 @ 0x2108680] Setting 'channel_layout' to
value '0x3'
[graph 1 input from stream 0:0 @ 0x2108680] tb:1/48000 samplefmt:s16
samplerate:48000 chlayout:0x3
[audio format for output stream 0:1 @ 0x2108c00] Setting 'sample_fmts'
to value 's16'
[audio format for output stream 0:1 @ 0x2108c00] Setting
'channel_layouts' to value '0x3'
[AVFilterGraph @ 0x20f93c0] query_formats: 4 queried, 9 merged, 0
already done, 0 delayed
Output #0, matroska, to '/Store3/Test/t_20151122_2006.mkv':
  Metadata:
    encoder         : Lavf57.14.100
    Stream #0:0, 0, 1/1000: Video: ffv1, 1 reference frame (FFV1 /
0x31564646), yuv422p, 720x576 [SAR 16:15 DAR 4:3], 1/25, q=2-31, 200
kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.15.100 ffv1
    Stream #0:1, 0, 1/1000: Audio: pcm_s16le ([1][0][0][0] / 0x0001),
48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc57.15.100 pcm_s16le
Stream mapping:
  Stream #1:0 -> #0:0 (rawvideo (native) -> ffv1 (native))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per
stream)
    Last message repeated 2 times
[matroska @ 0x20e1c00] Writing block at offset 965, size 65472, pts 0,
dts 0, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 66445, size 65472, pts
341, dts 341, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 131925, size 65472, pts
682, dts 682, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 197405, size 48316, pts
1023, dts 1023, duration 252, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 245729, size 65472, pts
1275, dts 1275, duration 341, keyframe 1
[matroska @ 0x20e1c00] Starting new cluster at offset 311209 bytes, pts
1720dts 1720
[matroska @ 0x20e1c00] Writing block at offset 311225, size 42564, pts
1616, dts 1616, duration 222, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 353797, size 268536, pts
1720, dts 1720, duration 40, keyframe 1
Cliping frame in rate conversion by 0.501961
[matroska @ 0x20e1c00] Starting new cluster at offset 622341 bytes, pts
1760dts 1760
[matroska @ 0x20e1c00] Writing block at offset 622357, size 194462, pts
1760, dts 1760, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500298
[matroska @ 0x20e1c00] Starting new cluster at offset 816827 bytes, pts
1800dts 1800
[matroska @ 0x20e1c00] Writing block at offset 816843, size 194860, pts
1800, dts 1800, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500069
[matroska @ 0x20e1c00] Starting new cluster at offset 1011711 bytes, pts
1840dts 1840
[matroska @ 0x20e1c00] Writing block at offset 1011727, size 65472, pts
1837, dts 1837, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 1077207, size 194519, pts
1840, dts 1840, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500511
[matroska @ 0x20e1c00] Starting new cluster at offset 1271734 bytes, pts
1880dts 1880
[matroska @ 0x20e1c00] Writing block at offset 1271750, size 194648, pts
1880, dts 1880, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500648
[matroska @ 0x20e1c00] Starting new cluster at offset 1466406 bytes, pts
1920dts 1920
[matroska @ 0x20e1c00] Writing block at offset 1466422, size 194529, pts
1920, dts 1920, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500771
[matroska @ 0x20e1c00] Starting new cluster at offset 1660959 bytes, pts
1960dts 1960
[matroska @ 0x20e1c00] Writing block at offset 1660975, size 194453, pts
1960, dts 1960, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500893
[matroska @ 0x20e1c00] Starting new cluster at offset 1855436 bytes, pts
2000dts 2000
[matroska @ 0x20e1c00] Writing block at offset 1855452, size 194683, pts
2000, dts 2000, duration 40, keyframe 1
Cliping frame in rate conversion by 0.502495
[matroska @ 0x20e1c00] Starting new cluster at offset 2050143 bytes, pts
2040dts 2040
[matroska @ 0x20e1c00] Writing block at offset 2050159, size 194618, pts
2040, dts 2040, duration 40, keyframe 1
Cliping frame in rate conversion by 0.500923
[matroska @ 0x20e1c00] Starting new cluster at offset 2244785 bytes, pts
2080dts 2080
[matroska @ 0x20e1c00] Writing block at offset 2244801, size 194546, pts
2080, dts 2080, duration 40, keyframe 1
Cliping frame in rate conversion by 0.501289
[matroska @ 0x20e1c00] Starting new cluster at offset 2439355 bytes, pts
2120dts 2120
[matroska @ 0x20e1c00] Writing block at offset 2439371, size 194605, pts
2120, dts 2120, duration 40, keyframe 1
Cliping frame in rate conversion by 0.501396
[matroska @ 0x20e1c00] Starting new cluster at offset 2633984 bytes, pts
2160dts 2160
[matroska @ 0x20e1c00] Writing block at offset 2634000, size 196705, pts
2160, dts 2160, duration 40, keyframe 1
Cliping frame in rate conversion by 0.501549
[matroska @ 0x20e1c00] Starting new cluster at offset 2830713 bytes, pts
2200dts 2200
[matroska @ 0x20e1c00] Writing block at offset 2830729, size 65472, pts
2178, dts 2178, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 2896209, size 194728, pts
2200, dts 2200, duration 40, keyframe 1
Cliping frame in rate conversion by 0.501640
[matroska @ 0x20e1c00] Starting new cluster at offset 3090945 bytes, pts
2240dts 2240

...

[matroska @ 0x20e1c00] Writing block at offset 9723070, size 194792, pts
3560, dts 3560, duration 40, keyframe 1
Cliping frame in rate conversion by 0.505836
[matroska @ 0x20e1c00] Starting new cluster at offset 9917870 bytes, pts
3600dts 3600
[matroska @ 0x20e1c00] Writing block at offset 9917886, size 18400, pts
3579, dts 3579, duration 96, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 9936294, size 194379, pts
3600, dts 3600, duration 40, keyframe 1
*** dropping frame 48 from stream 0 at ts -940187
    Last message repeated 9 times
[matroska @ 0x20e1c00] Starting new cluster at offset 10130681 bytes,
pts 4000dts 4000
[matroska @ 0x20e1c00] Writing block at offset 10130697, size 65472, pts
3675, dts 3675, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 10196177, size 195039,
pts 4000, dts 4000, duration 40, keyframe 1
[matroska @ 0x20e1c00] Starting new cluster at offset 10391224 bytes,
pts 4040dts 4040=0 drop=10

...

pts 5120dts 5120
[matroska @ 0x20e1c00] Writing block at offset 15851032, size 65472, pts
5081, dts 5081, duration 341, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 15916512, size 194417,
pts 5120, dts 5120, duration 40, keyframe 1
*** dropping frame 77 from stream 0 at ts -940187
    Last message repeated 7 times
[matroska @ 0x20e1c00] Starting new cluster at offset 16110937 bytes,
pts 5480dts 5480
[matroska @ 0x20e1c00] Writing block at offset 16110953, size 17352, pts
5422, dts 5422, duration 90, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 16128313, size 194850,
pts 5480, dts 5480, duration 40, keyframe 1
[matroska @ 0x20e1c00] Starting new cluster at offset 16323171 bytes,
pts 5520dts 5520=0 drop=18
[matroska @ 0x20e1c00] Writing block at offset 16323187, size 9140, pts
5512, dts 5512, duration 48, keyframe 1
[matroska @ 0x20e1c00] Writing block at offset 16332334, size 194906,
pts 5520, dts 5520, duration 40, keyframe 1
[matroska @ 0x20e1c00] end duration = 5560
[matroska @ 0x20e1c00] stream 0 end duration = 5560
[matroska @ 0x20e1c00] stream 1 end duration = 5560
frame=   79 fps= 15 q=-0.0 Lsize=   16141kB time=00:00:05.56
bitrate=23782.4kbits/s dup=0 drop=18
video:15095kB audio:1042kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.027566%
Input file #0 (alsa_input.pci-0000_00_14.2.analog-stereo):
  Input stream #0:0 (audio): 21 packets read (1067444 bytes); 21 frames
decoded (266861 samples);
  Total: 21 packets (1067444 bytes) demuxed
Input file #1 (/dev/video0):
  Input stream #1:0 (video): 97 packets read (80455680 bytes); 97 frames
decoded;
  Total: 97 packets (80455680 bytes) demuxed
Output file #0 (/Store3/Test/t_20151122_2006.mkv):
  Output stream #0:0 (video): 79 frames encoded; 79 packets muxed
(15456778 bytes);
  Output stream #0:1 (audio): 21 frames encoded (266861 samples); 21
packets muxed (1067444 bytes);
  Total: 100 packets (16524222 bytes) muxed
118 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x20f6bc0] Statistics: 496 seeks, 848 writeouts


More information about the ffmpeg-user mailing list