[FFmpeg-devel] Grabbing from H264 Webcam - Timestamps are unset

Manuel Tonella manuel.concorsi at gmail.com
Tue Jan 17 11:47:27 EET 2017


Hello,

I'm using ffmpeg to capture video from a webcam (H264 source) and save it
in a container (MP4) without re-encoding.

Often I get wrong frame timestamp in output video, so it starts not from
0(zero) but from the "machine uptime"(something like 16:29:08 ...).(so
the video-playback pogressbar start from 16:29:08 )

When the output file timestamp is wrong I get the following warning in
ffmpeg during encode:

"Timestamps are unset in a packet for stream 0. This is deprecated and
will stop working in the future. Fix your code to set the timestamps
properly"

How to fix it ?

Platform: ARM
Linux: 3.16
Webcam: Sonix SN9C292
Driver: UVC

ffmpeg -report -probesize 32  -rtbufsize 10000k  -pix_fmt yuv420p -r
10 -s 1280x720 -framerate 10  -vcodec h264 -f v4l2  -i /dev/video1
-vcodec copy 	-r 10 -reset_timestamps 1 -frag_duration 1000000
-movflags empty_moov+omit_tfhd_offset+frag_keyframe+default_base_moof
-f MP4 -y test.mp4

ffmpeg started on 2017-01-17 at 09:33:58
Report written to "ffmpeg-20170117-093358.log"
Command line:
ffmpeg -report -probesize 32 -rtbufsize 10000k -pix_fmt yuv420p -r 10
-s 1280x720 -framerate 10 -vcodec h264 -f v4l2 -i /dev/video1 -vcodec
copy -r 10 -reset_timestamps 1 -frag_duration 1000000 -movflags
empty_moov+omit_tfhd_offset+frag_keyframe+default_base_moof -f MP4 -y
/tmp/test.mp4
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (Buildroot 2016.02)
  configuration: --enable-cross-compile
--cross-prefix=/projects/V4_bis/V4/src/tools/buildroot/output/host/usr/bin/arm-buildroot-linux-gnueabi-
--sysroot=/projects/V4_bis/V4/src/tools/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot
--host-cc=/usr/bin/gcc --arch=arm --target-os=linux
--disable-stripping
--pkg-config=/projects/V4_bis/V4/src/tools/buildroot/output/host/usr/bin/pkg-config
--disable-static --enable-shared --prefix=/usr --enable-avfilter
--disable-version3 --enable-logging --enable-optimizations
--disable-extra-warnings --enable-avdevice --enable-avcodec
--enable-avformat --disable-x11grab --enable-network --disable-gray
--enable-swscale-alpha --disable-small --enable-dct --enable-fft
--enable-mdct --enable-rdft --disable-crystalhd --disable-vdpau
--disable-dxva2 --enable-runtime-cpudetect --disable-hardcoded-tables
--disable-memalign-hack --disable-mipsdsp --disable-mipsdspr2
--disable-msa --enable-hwaccels --disable-avisynth --disable-frei0r
--disable-libopencore-amrnb --disable-li  libavutil      55. 34.100 /
55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a
report) with argument '1'.
Reading option '-probesize' ... matched as AVOption 'probesize' with
argument '32'.
Reading option '-rtbufsize' ... matched as AVOption 'rtbufsize' with
argument '10000k'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
format) with argument 'yuv420p'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz
value, fraction or abbreviation)) with argument '10'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or
abbreviation)) with argument '1280x720'.
Reading option '-framerate' ... matched as AVOption 'framerate' with
argument '10'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video
codec ('copy' to copy stream)) with argument 'h264'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'v4l2'.
Reading option '-i' ... matched as input url with argument '/dev/video1'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video
codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz
value, fraction or abbreviation)) with argument '10'.
Reading option '-reset_timestamps' ... matched as AVOption
'reset_timestamps' with argument '1'.
Reading option '-frag_duration' ... matched as AVOption
'frag_duration' with argument '1000000'.
Reading option '-movflags' ... matched as AVOption 'movflags' with
argument 'empty_moov+omit_tfhd_offset+frag_keyframe+default_base_moof'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'MP4'.
Reading option '-y' ... matched as option 'y' (overwrite output files)
with argument '1'.
Reading option '/tmp/test.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /dev/video1.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Applying option r (set frame rate (Hz value, fraction or
abbreviation)) with argument 10.
Applying option s (set frame size (WxH or abbreviation)) with argument 1280x720.
Applying option vcodec (force video codec ('copy' to copy stream))
with argument h264.
Applying option f (force format) with argument v4l2.
Successfully parsed a group of options.
Opening an input file: /dev/video1.
[video4linux2,v4l2 @ 0x585d0] fd:4 capabilities:84000001
[video4linux2,v4l2 @ 0x585d0] Current input_channel: 0, input_name:
Camera 1, input_std: 0
[video4linux2,v4l2 @ 0x585d0] Trying to set codec:h264 pix_fmt:none
[video4linux2,v4l2 @ 0x585d0] Setting time per frame to 1/10
[h264 @ 0x596b0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x596b0] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x596b0] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x596b0] Reinit context to 1280x720, pix_fmt: yuv420p
[video4linux2,v4l2 @ 0x585d0] Probe buffer size limit of 32 bytes reached
[video4linux2,v4l2 @ 0x585d0] decoding for stream 0 failed
Input #0, video4linux2,v4l2, from '/dev/video1':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/1000000: Video: h264 (Main),
yuv420p(progressive), 1280x720, -1 kb/s, 10 fps, 10 tbr, 1000k tbn,
2000k tbc
Successfully opened the file.
Parsing a group of options: output url /tmp/test.mp4.
Applying option vcodec (force video codec ('copy' to copy stream))
with argument copy.
Applying option r (set frame rate (Hz value, fraction or
abbreviation)) with argument 10.
Applying option f (force format) with argument MP4.
Successfully parsed a group of options.
Opening an output file: /tmp/test.mp4.
[file @ 0x67150] Setting default whitelist 'file,crypto'
Successfully opened the file.
[mp4 @ 0x90fb0] Empty MOOV enabled; disabling automatic bitstream filtering
Output #0, mp4, to '/tmp/test.mp4':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #0:0, 0, 1/10240: Video: h264 (Main) ([33][0][0][0] /
0x0021), yuv420p(progressive), 1280x720, q=2-31, -1 kb/s, 10 fps, 10
tbr, 10240 tbn, 10 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[mp4 @ 0x90fb0] Timestamps are unset in a packet for stream 0. This is
deprecated and will stop working in the future. Fix your code to set
the timestamps properly
frame=   15 fps=0.0 q=-1.0 size=     539kB time=16:29:08.33 bitrate=
0.1kbits/s speed=1.16e+05x
frame=   20 fps= 20 q=-1.0 size=     539kB time=16:29:08.84 bitrate=
0.1kbits/s speed=5.82e+04x
frame=   25 fps= 16 q=-1.0 size=    1319kB time=16:29:09.35 bitrate=
0.2kbits/s speed=3.91e+04x
frame=   30 fps= 15 q=-1.0 size=    1319kB time=16:29:09.85 bitrate=
0.2kbits/s speed=2.94e+04x
frame=   35 fps= 14 q=-1.0 size=    2102kB time=16:29:10.36 bitrate=
0.3kbits/s speed=2.35e+04x
frame=   40 fps= 13 q=-1.0 size=    2102kB time=16:29:10.87 bitrate=
0.3kbits/s speed=1.96e+04x
frame=   45 fps= 13 q=-1.0 size=    2564kB time=16:29:11.38 bitrate=
0.4kbits/s speed=1.68e+04x
frame=   50 fps= 12 q=-1.0 size=    2564kB time=16:29:11.88 bitrate=
0.4kbits/s speed=1.47e+04x
frame=   55 fps= 12 q=-1.0 size=    3286kB time=16:29:12.39 bitrate=
0.5kbits/s speed=1.3e+04x
frame=   60 fps= 12 q=-1.0 size=    3286kB time=16:29:12.90 bitrate=
0.5kbits/s speed=1.17e+04x
frame=   65 fps= 12 q=-1.0 size=    4015kB time=16:29:13.40 bitrate=
0.6kbits/s speed=1.07e+04x
frame=   70 fps= 12 q=-1.0 size=    4015kB time=16:29:13.91 bitrate=
0.6kbits/s speed=9.76e+03x
frame=   75 fps= 11 q=-1.0 size=    4613kB time=16:29:14.42 bitrate=
0.6kbits/s speed=8.99e+03x
frame=   80 fps= 11 q=-1.0 size=    4613kB time=16:29:14.93 bitrate=
0.6kbits/s speed=8.34e+03x
frame=   85 fps= 11 q=-1.0 Lsize=    5559kB time=16:29:15.43 bitrate=
 0.8kbits/s speed=7.77e+03x
video:5557kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.048155%
Input file #0 (/dev/video1):
  Input stream #0:0 (video): 85 packets read (5689945 bytes);
  Total: 85 packets (5689945 bytes) demuxed
Output file #0 (/tmp/test.mp4):
  Output stream #0:0 (video): 85 packets muxed (5689945 bytes);
  Total: 85 packets (5689945 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x6f1d0] Statistics: 0 seeks, 180 writeouts

[image: Immagine incorporata 1]

Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 8889 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170117/aa5b3062/attachment.png>


More information about the ffmpeg-devel mailing list