[FFmpeg-user] Using the asyncts filter
Dainius (GreatEmerald)
pastas4 at gmail.com
Sat Aug 25 22:33:52 CEST 2012
> I don't think it can be used for audio-only output files.
>
> Generally, while explaining what you tried is usually a good idea
> (but that normally means posting a command line together with
> complete, uncut console output), it is even more important that
> you explain what you want to achieve.
> (And that should not be "using the asyncts" filter.)
Well, first and foremost I want to understand what it can be used for
:) But if speaking about what I want to achieve, it is to synchronise
a video file to an audio file, where an audio file has gone out of
sync from the video file. The problem with synchronising the streams
at the time of recording is that if I attempt to do that, the
recording starts dropping a lot of frames, and usually they don't get
synchronised anyway (since the timestamps of the streams that get
recorded are different, one uses relative time, the other uses
absolute time). So, to synchronise these streams, ideally I would
process them after recording, and have FFmpeg deduce how to make the
audio fit the video (or vice versa) by looking at timestamps. From the
description in the manual, the asyncts filter looked closest to the
method of getting that done.
As for the output, well, this is what I used to try out the filter
(got the same file as input both times):
ffmpeg -i Video.mkv -i AudioA.wav -map 0 -y null.mkv -filter:1
'asyncts=max_comp=48000' -codec:a pcm_s16le -y ASyncTS.wav # Slow due
to video output
ffmpeg -i Video.mkv -i AudioA.wav -vn -filter:1
'asyncts=max_comp=48000' -codec:a pcm_s16le -y ASyncTS.wav # Near
instantaneous
The output of these doesn't seem to be all that interesting, it's just
standard processing output.
And as for how the reported timestamps seemingly don't match when
recording, well, see this:
--
> ffmpeg -xerror \
> -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
> -f x11grab -r 30 -s 640x480 -i :0.0+4,24 \
> -y test.mkv
ffmpeg version N-43686-g5296d7b Copyright (c) 2000-2012 the FFmpeg developers
built on Aug 18 2012 12:50:28 with gcc 4.7 (SUSE Linux)
configuration: --disable-shared --enable-static --prefix=/opt
--disable-doc --disable-debug --extra-cflags='-march=native'
--enable-gpl --enable-x11grab --enable-version3 --enable-pthreads
--enable-libpulse --enable-libx264 --disable-ffplay --disable-ffserver
--disable-ffprobe
libavutil 51. 70.100 / 51. 70.100
libavcodec 54. 53.100 / 54. 53.100
libavformat 54. 25.100 / 54. 25.100
libavdevice 54. 2.100 / 54. 2.100
libavfilter 3. 10.100 / 3. 10.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[pulse @ 0x2896260] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, pulse, from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor':
Duration: N/A, start: 0.052322, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[x11grab @ 0x28934e0] device: :0.0+4,24 -> display: :0.0 x: 4 y: 24
width: 640 height: 480
[x11grab @ 0x28934e0] shared memory extension found
[x11grab @ 0x28934e0] Estimating duration from bitrate, this may be inaccurate
Input #1, x11grab, from ':0.0+4,24':
Duration: N/A, start: 1345926003.088931, bitrate: 294912 kb/s
Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 640x480,
294912 kb/s, 30 tbr, 1000k tbn, 30 tbc
[libx264 @ 0x2892f20] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2 AVX
[libx264 @ 0x2892f20] profile High 4:4:4 Predictive, level 3.0, 4:4:4 8-bit
[libx264 @ 0x2892f20] 264 - core 125 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2012 - http://www.videolan.org/x264.html - options:
cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4
threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf54.25.100
Stream #0:0: Video: h264, yuv444p, 640x480, q=-1--1, 1k tbn, 30 tbc
Stream #0:1: Audio: ac3, 48000 Hz, stereo, flt, 192 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo -> libx264)
Stream #0:0 -> #0:1 (pcm_s16le -> ac3)
Press [q] to stop, [?] for help
frame= 175 fps= 30 q=32766.0 Lsize= 182kB time=00:00:05.76
bitrate= 257.9kbits/s
video:41kB audio:138kB subtitle:0 global headers:0kB muxing overhead 1.630919%
[libx264 @ 0x2892f20] frame I:1 Avg QP:22.84 size: 34156
[libx264 @ 0x2892f20] frame P:44 Avg QP:26.89 size: 66
[libx264 @ 0x2892f20] frame B:130 Avg QP:29.00 size: 30
[libx264 @ 0x2892f20] consecutive B-frames: 0.6% 1.1% 0.0% 98.3%
[libx264 @ 0x2892f20] mb I I16..4: 51.7% 3.7% 44.7%
[libx264 @ 0x2892f20] mb P I16..4: 0.1% 0.0% 0.0% P16..4: 0.4%
0.0% 0.0% 0.0% 0.0% skip:99.5%
[libx264 @ 0x2892f20] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 0.6%
0.0% 0.0% direct: 0.0% skip:99.3% L0:41.4% L1:58.6% BI: 0.0%
[libx264 @ 0x2892f20] 8x8 transform intra:12.2% inter:16.7%
[libx264 @ 0x2892f20] coded y,u,v intra: 24.3% 5.6% 5.8% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x2892f20] i16 v,h,dc,p: 46% 54% 0% 0%
[libx264 @ 0x2892f20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 2% 4% 90% 1%
0% 0% 0% 0% 3%
[libx264 @ 0x2892f20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 39% 18% 2%
3% 2% 4% 2% 3%
[libx264 @ 0x2892f20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x2892f20] ref P L0: 62.1% 11.3% 25.1% 1.5%
[libx264 @ 0x2892f20] ref B L0: 53.0% 46.2% 0.8%
[libx264 @ 0x2892f20] ref B L1: 97.5% 2.5%
[libx264 @ 0x2892f20] kb/s:56.06
--
Notice how Input #0 has "start: 0.052322" and Input #1 has "start:
1345926003.088931".
More information about the ffmpeg-user
mailing list