Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#4789 closed defect (invalid)

v4l2 -ts abs not always working

Reported by: basinilya Owned by:
Priority: normal Component: undetermined
Version: 2.7 Keywords: v4l2
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When capturing from stk1160-based DVR, frames PTS start with zero regardless of -ts option.

How to reproduce:
Not sure, whether it's possible without the device.
The issue occurs on my laptop with 32bit Arch Linux.
Tried with v4l2loopback on vbox, but PTS were correct.

[il@mar ~]$ ffmpeg -loglevel info -y -f video4linux2 -ts default -t 0.2 -i /dev/video0 -vf "showinfo" -f rawvideo - >/dev/null
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 83594.430406, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
[Parsed_showinfo_0 @ 0x997c380] config in time_base: 1/1000000, frame_rate: 25/1
[Parsed_showinfo_0 @ 0x997c380] config out time_base: 0/0, frame_rate: 0/0
Output #0, rawvideo, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.41.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[Parsed_showinfo_0 @ 0x997c380] n:   0 pts:      0 pts_time:0       pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:3AB03E64 plane_checksum:[3AB03E64] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x997c380] n:   1 pts:  40025 pts_time:0.040025 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:8139611B plane_checksum:[8139611B] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x997c380] n:   2 pts:  80026 pts_time:0.080026 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:CC8E5A2F plane_checksum:[CC8E5A2F] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x997c380] n:   3 pts: 120026 pts_time:0.120026 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:15DF85CC plane_checksum:[15DF85CC] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x997c380] n:   4 pts: 160026 pts_time:0.160026 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:B12C62CE plane_checksum:[B12C62CE] mean:[133] stdev:[19.0]
frame=    5 fps=0.0 q=0.0 Lsize=    4050kB time=00:00:00.20 bitrate=165888.0kbits/s
video:4050kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
[il@mar ~]$ ffmpeg -loglevel info -y -f video4linux2 -ts abs -t 0.2 -i /dev/video0 -vf "showinfo" -f rawvideo - >/dev/null
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[video4linux2,v4l2 @ 0x9e76ae0] Detected monotonic timestamps, converting
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1440149031.144507, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
[Parsed_showinfo_0 @ 0x9e67380] config in time_base: 1/1000000, frame_rate: 25/1
[Parsed_showinfo_0 @ 0x9e67380] config out time_base: 0/0, frame_rate: 0/0
Output #0, rawvideo, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.41.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[Parsed_showinfo_0 @ 0x9e67380] n:   0 pts:      0 pts_time:0       pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:4AE93264 plane_checksum:[4AE93264] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e67380] n:   1 pts:  40010 pts_time:0.04001 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:BCAC168B plane_checksum:[BCAC168B] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e67380] n:   2 pts:  80043 pts_time:0.080043 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:23F7AA94 plane_checksum:[23F7AA94] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e67380] n:   3 pts: 120016 pts_time:0.120016 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:C91BC157 plane_checksum:[C91BC157] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e67380] n:   4 pts: 160042 pts_time:0.160042 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:1EB54BC1 plane_checksum:[1EB54BC1] mean:[133] stdev:[19.0]
frame=    5 fps=0.0 q=0.0 Lsize=    4050kB time=00:00:00.20 bitrate=165888.0kbits/s
video:4050kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
[il@mar ~]$ ffmpeg -loglevel info -y -f video4linux2 -ts mono2abs -t 0.2 -i /dev/video0 -vf "showinfo" -f rawvideo - >/dev/null
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[video4linux2,v4l2 @ 0x9e5cae0] Detected monotonic timestamps, converting
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1440149036.582784, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
[Parsed_showinfo_0 @ 0x9e4d380] config in time_base: 1/1000000, frame_rate: 25/1
[Parsed_showinfo_0 @ 0x9e4d380] config out time_base: 0/0, frame_rate: 0/0
Output #0, rawvideo, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.41.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[Parsed_showinfo_0 @ 0x9e4d380] n:   0 pts:      0 pts_time:0       pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:2ABDB2D5 plane_checksum:[2ABDB2D5] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e4d380] n:   1 pts:  40027 pts_time:0.040027 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:3EE35436 plane_checksum:[3EE35436] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e4d380] n:   2 pts:  80018 pts_time:0.080018 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:15E5CFF4 plane_checksum:[15E5CFF4] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e4d380] n:   3 pts: 120039 pts_time:0.120039 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:2A4976EA plane_checksum:[2A4976EA] mean:[133] stdev:[19.0]
[Parsed_showinfo_0 @ 0x9e4d380] n:   4 pts: 160020 pts_time:0.16002 pos:       -1 fmt:uyvy422 sar:0/1 s:720x576 i:P iskey:1 type:I checksum:E105B4F8 plane_checksum:[E105B4F8] mean:[133] stdev:[19.0]
frame=    5 fps=0.0 q=0.0 Lsize=    4050kB time=00:00:00.20 bitrate=165888.0kbits/s
video:4050kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

Change History (3)

comment:1 in reply to: ↑ description ; follow-up: Changed 4 years ago by cehoyos

  • Keywords v4l2 added

Replying to basinilya:

Please test current FFmpeg git head before reporting issues and please tell us if https://ffmpeg.org/bugreports.html is unclear!

Summary of the bug:
When capturing from stk1160-based DVR, frames PTS start with zero regardless of -ts option.

$ ffmpeg -loglevel info -y -f video4linux2 -ts default -t 0.2 -i /dev/video0

  Duration: N/A, start: 83594.430406, bitrate: 165888 kb/s
$ ffmpeg -loglevel info -y -f video4linux2 -ts abs -t 0.2 -i /dev/video0

  Duration: N/A, start: 1440149031.144507, bitrate: 165888 kb/s

It seems to me that the -ts option works exactly as expected on your system.
What do I miss?

comment:2 in reply to: ↑ 1 Changed 4 years ago by basinilya

  • Resolution set to invalid
  • Status changed from new to closed

Replying to cehoyos:

Replying to basinilya:

Duration: N/A, start: 83594.430406, bitrate: 165888 kb/s

I was looking at:

pts: 0 pts_time:0

Nevertheless, you are right: there's a difference in ffplay and ffmpeg. When I grab /dev/video0 with ffplay, shown PTS starts with wallclock, while in ffmpeg PTS starts with zero. I didn't use ffplay directly with real device, because it crashes the device driver. Instead I piped ffmpeg to ffplay and saw zero PTS, which confused me.

Sorry for that.

Since I do need wallclock PTS in filter expressions (but not 'time(0)', because it's laggy) in ffmpeg, I found a workaround:

-vf "setpts='PTS+(RTCSTART/(TB*1000000))',do stuff...,setpts='PTS-(RTCSTART/(TB*1000000))'"

comment:3 Changed 4 years ago by Cigaes

The default for ffmpeg is to reset the timestamp to a 0 start-time. You can disable it with -copyts.

Note: See TracTickets for help on using tickets.