Opened 11 years ago

Last modified 11 years ago

#2176 new defect

mencoder skips most frames when recording from v4l2 (linux)

Reported by: jarekczek@… Owned by:
Priority: normal Component: streaming
Version: HEAD Severity: normal
Keywords: Cc:
Blocked By: Blocking:
Reproduced by developer: no Analyzed by developer: no

Description

Command:

mencoder tv:// -o /m/temp.avi -ovc raw -endpos 1 -v

Output:

[...]
Skipping frame!
VPos: 0.2s APos:-9223372036854775808.0s 8f ( 0%) 0fps Trem: 0min 0mb A-V:0.000 [0:0] A/Vms 0/5 D/B/S 0/4/4
VPos: 0.2s APos:-9223372036854775808.0s 9f ( 0%) 0fps Trem: 0min 0mb A-V:0.000 [0:0] A/Vms 0/4 D/B/S 0/4/4

Skipping frame!
VPos: 0.2s APos:-9223372036854775808.0s 10f ( 0%) 0fps Trem: 0min 0mb A-V:0.000 [0:0] A/Vms 0/4 D/B/S 0/5/5
VPos: 0.2s APos:-9223372036854775808.0s 11f ( 0%) 0fps Trem: 0min 0mb A-V:0.000 [0:0] A/Vms 0/4 D/B/S 0/5/5
[...]

Mencoder skips 35 out of 61 frames. Recording takes 2.7 seconds, while it was told to record only 1 second.

Analyze:

Seems like the problem started when Linux kernel changed the way timestamps are generated in video for linux drivers. Previously it was using realtime clock, now it is monotonic clock. The change is dated 2012-12-21 and probably introduced in kernel 3.10. I cannot reproduce the problem on kernel 3.2. This is a list of commits of one of kernel developers, the related commits are from 2012-12-21. These 2 are the most notable: introduced monotonic timestamps, flags for timestamps types.

Mencoder assumes that timestamps are from realtime clock and compares them to the ones generated using gettimeofday(). I prepared a patch to detect (from v4l2 buffer flags) what kind of clock is used and apply suitable clock calls to get relevant timestamps using clock_gettime(). With this patch I can record from tv on both old and new kernels. The patch will be sent to the list.

Change History (1)

comment:1 by jarekczek@…, 11 years ago

Note: See TracTickets for help on using tickets.