[FFmpeg-user] Choppy (hanging) video when writing C920 h264 to a file (no issues streaming)

Peter Rabbitson rabbit+list at rabbit.us
Fri Dec 5 11:34:45 CET 2014


I am completely baffled. I have a Logitech C920 which is capable of 
providing a hardware encoded h264 stream. If I capture video from it as 
described below, I can see properl smooth video on my laptop screen. But 
the resulting rec.mkv has a small ~0.5s freeze every ~2.5 secs. I 
uploaded the raw result to vimeo with the full description, it can be 
found here:

https://vimeo.com/113692822

Repeating the text from there for the sake of the archives:

Problem (best seen from 0:55 onwards) - I can capture proper h264 from 
the Logitech C920, I can *see* non-choppy excellent video on screen. At 
the same time the recording made from the very same stream (via -c:v 
copy) freezes every ~2.5 secs as seen above.

Command that created this video:
ffmpeg -y \
   -r 30 -f v4l2 -s 1024x576 -vcodec h264 -i 
/dev/v4l/by-id/usb-*_HD_Pro_Webcam_C920_* \
   -c:v copy -f matroska /dev/shm/rec.mkv \
   -c:v copy -f matroska - | \
ffplay -i -

There are no CPU utilization issues (remember - we are just copying 264 
around, the only CPU use is from ffplay itself, about 15~20% cpu). There 
are no IO issues either - the file is laughably small, and I saved it to 
/dev/shm to make sure there are no fsync side-effects.

Output during muxing:
Input #0, video4linux2,v4l2, from '/dev/v4l/by-id/usb-*HD_Pro_Webcam_C920*':
   Duration: N/A, start: 67317.039046, bitrate: N/A
     Stream #0:0: Video: h264 (Constrained Baseline), yuvj420p(pc), 
1024x576 [SAR 1:1 DAR 16:9], -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 60 tbc
Output #0, matroska, to '/dev/shm/rec.mkv':
   Metadata:
     encoder         : Lavf56.4.101
     Stream #0:0: Video: h264 (H264 / 0x34363248), yuvj420p, 1024x576 
[SAR 1:1 DAR 16:9], q=2-31, -5 kb/s, 30 fps, 1k tbn, 30 tbc
Output #1, matroska, to 'pipe:':
   Metadata:
     encoder         : Lavf56.4.101
     Stream #1:0: Video: h264 (H264 / 0x34363248), yuvj420p, 1024x576 
[SAR 1:1 DAR 16:9], q=2-31, -5 kb/s, 30 fps, 1k tbn, 30 tbc
Stream mapping:
   Stream #0:0 -> #0:0 (copy)
   Stream #0:0 -> #1:0 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -367; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 0, current: -367; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -303; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 0, current: -303; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -235; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 0, current: -235; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -167; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 0, current: -167; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -103; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 0, current: -103; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -35; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 0, current: -35; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 97, current: -3; changing to 97. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 97, current: -3; changing to 97. This may result in incorrect 
timestamps in the output file.
Input #0, matroska,webm, from 'pipe:':
   Metadata:
     ENCODER         : Lavf56.4.101
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Video: h264 (Constrained Baseline), yuvj420p(pc), 
1024x576 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
[swscaler @ 0x7fec9414a3c0] deprecated pixel format used, make sure you 
did set range correctly
[matroska @ 0x13ebd00] Non-monotonous DTS in output stream 0:0; 
previous: 97, current: 57; changing to 97. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x13e1660] Non-monotonous DTS in output stream 1:0; 
previous: 97, current: 57; changing to 97. This may result in incorrect 
timestamps in the output file.
frame= 1179 fps= 16 q=-1.0 Lq=-1.0 size=   27384kB time=00:01:14.12 
bitrate=3026.5kbits/s
video:54748kB audio:0kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: unknown

(Ctrl+C here)

Raw video version (27MB as uploaded from /dev/shm) is available for 
downaload above - sha1: 85fa43123b474e259342ea0ff0da1358afa0697d

My ffmpeg version:
rabbit at Ahasver:~$ ffmpeg -version
ffmpeg version 2.4.3-1 Copyright (c) 2000-2014 the FFmpeg developers
built on Nov  5 2014 00:18:23 with gcc 4.9.1 (Debian 4.9.1-14)
configuration: --prefix=/usr --extra-version=1 --build-suffix=-ffmpeg 
--toolchain=hardened --extra-cflags= --extra-cxxflags= 
--libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu 
--incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared 
--disable-stripping --enable-avresample --enable-avisynth 
--enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass 
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio 
--enable-libflite --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-libspeex 
--enable-libssh --enable-libtheora --enable-libtwolame 
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp 
--enable-opengl --enable-x11grab --enable-libxvid --enable-libdc1394 
--enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r 
--enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv
libavutil      54.  7.100 / 54.  7.100
libavcodec     56.  1.100 / 56.  1.100
libavformat    56.  4.101 / 56.  4.101
libavdevice    56.  0.100 / 56.  0.100
libavfilter     5.  1.100 /  5.  1.100
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  0.100 /  3.  0.100
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  0.100 / 53.  0.100


More information about the ffmpeg-user mailing list