[FFmpeg-user] Bad A/V Sync Using ffmpeg on V4L2 Input Device
Leo L. Schwab
ewhac at ewhac.org
Tue Mar 25 09:23:28 CET 2014
On Mon, Mar 24, 2014 at 03:32:09PM -0800, Lou wrote:
> This -ts option is a v4l2 input option. I'm not sure if this option
> will solve your issue, but did you place it in the correct location?
>
> ffmpeg -f alsa -i hw:1 -f v4l2 -ts abs -i /dev/video0 ...
>
Yes, I tried that, but the resulting output file has the same sync
issue (video leads the audio by about a half second). Here's the console
output from that run. (In this run, the capture device shows up as
/dev/video1.)
Schwab
----
sh$ ffmpeg -f alsa -i hw:1 -f v4l2 -ts abs -i /dev/video1 -acodec libfaac -b:a 128k -vcodec libx264 -b:v 12M -g 1 -preset ultrafast SYNCTEST.mp4
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Feb 24 2014 08:21:48 with gcc 4.8 (Debian 4.8.2-16)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --enable-libiec61883 --enable-libfdk-aac --enable-vaapi --enable-libdc1394 --disable-altivec --disable-armv5te --disable-armv6 --disable-vis --shlibdir=/usr/lib/x86_64-linux-gnu
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1':
Duration: N/A, start: 1395735487.163647, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2,v4l2 @ 0xdd4c00] Detected monotonic timestamps, converting
Input #1, video4linux2,v4l2, from '/dev/video1':
Duration: N/A, start: 1395735487.663812, bitrate: 165722 kb/s
Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x480, 165722 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0xdd73a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 0xdd73a0] profile High 4:2:2 Intra, level 3.0, 4:2:2 8-bit
[libx264 @ 0xdd73a0] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=1 keyint_min=1 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=12000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'SYNCTEST.mp4':
Metadata:
encoder : Lavf55.19.104
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p, 720x480, q=-1--1, 12000 kb/s, 30k tbn, 29.97 tbc
Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo -> libx264)
Stream #0:0 -> #0:1 (pcm_s16le -> libfaac)
Press [q] to stop, [?] for help
frame= 300 fps= 30 q=-1.0 Lsize= 14975kB time=00:00:10.49 bitrate=11688.8kbits/s
video:14797kB audio:165kB subtitle:0 global headers:0kB muxing overhead 0.088501%
[libx264 @ 0xdd73a0] frame I:300 Avg QP:22.12 size: 50504
[libx264 @ 0xdd73a0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0xdd73a0] final ratefactor: 14.18
[libx264 @ 0xdd73a0] coded y,uvDC,uvAC intra: 71.2% 71.5% 42.3%
[libx264 @ 0xdd73a0] i16 v,h,dc,p: 44% 24% 14% 18%
[libx264 @ 0xdd73a0] i8c dc,h,v,p: 44% 16% 28% 12%
[libx264 @ 0xdd73a0] kb/s:12108.91
More information about the ffmpeg-user
mailing list