Opened 4 years ago

Closed 4 years ago

#8415 closed defect (invalid)

image2 strftime %z not supported

Reported by: Alan Piszcz Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords: image2
Cc: alexandre.schmidt@gmail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

FFMPEG 4.2.1 Windows Build

ffmpeg
-rtsp_transport tcp

-i rtsp://.....
-f image2

-vf fps=fps=1
-strftime 1

"test\%%Y%%m%%d%%H%%M%%S%%z.jpg"

image2 encoder states strftime is supported. However using the %z option produces timezone name '%Z' and NOT the numeric offset for the timezone.

This parameter is not working properly.
%z The +hhmm or -hhmm numeric timezone (that is, the hour and

minute offset from UTC). (SU)

I also tested and NOTE that %s (epoch) is not supported.

http://man7.org/linux/man-pages/man3/strftime.3.html

IDEALLY there would be an OPTION so support UTC time.

Change History (6)

comment:1 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedavformat
Keywords: strftime removed
Version: 4.2unspecified

Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output to make this a valid ticket. Please avoid network input if it is not necessary to reproduce the issue.

comment:2 by Carl Eugen Hoyos, 4 years ago

Not an obvious duplicate of ticket #5402.

comment:3 by Alan Piszcz, 4 years ago

ffmpeg-20191206-b66a800-win64-shared\bin\ffmpeg -i testsrc.mpg -f image2 -vf fps=fps=1 -strftime 1 "test\%%Y%%m%%d%%H%%M%%S%%z.jpg"

ffmpeg version git-2019-12-06-b66a800 Copyright (c) 2000-2019 the FFmpeg developers

built with gcc 9.2.1 (GCC) 20191125
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 36.101 / 56. 36.101
libavcodec 58. 64.101 / 58. 64.101
libavformat 58. 35.101 / 58. 35.101
libavdevice 58. 9.101 / 58. 9.101
libavfilter 7. 67.100 / 7. 67.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100

Input #0, mpeg, from 'testsrc.mpg':

Duration: 00:00:09.97, start: 0.533333, bitrate: 634 kb/s

Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 104857 kb/s, 30 fps, 30 tbr, 90k tbn, 30 tbc

Stream mapping:

Stream #0:0 -> #0:0 (mpeg1video (native) -> mjpeg (native))

Press [q] to stop, ? for help
[swscaler @ 0000018ea61fdfc0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'test\%Y%m%d%H%M%S%z.jpg':

Metadata:

encoder : Lavf58.35.101
Stream #0:0: Video: mjpeg, yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
Metadata:

encoder : Lavc58.64.101 mjpeg

Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

frame= 10 fps=0.0 q=1.6 Lsize=N/A time=00:00:10.00 bitrate=N/A speed=47.6x
video:216kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

OUTPUT file name:
20191206124932Eastern Standard Time.jpg

It should be
20191206124932+0400.jpg (or similar)

comment:4 by Alexandre Heitor Schmidt, 4 years ago

I see your command line specifies output as this:

"test\%%Y%%m%%d%%H%%M%%S%%z.jpg"

It may be a typo, but the correct pattern should be this:

"test\%Y%m%d%H%M%S%z.jpg"

By inspecting the source code, you can see, at line 99, ffmpeg uses strftime() from the system's time.h, so, unless you have a problem with your system libs, it should work just fine.

I don't have a Windows box to test it, but in Linux, this command line:

ffmpeg -nostdin -loglevel debug -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 -y "/tmp/%Y%m%d%H%M%S%z.jpg"

generates this output files:

...
[image2 @ 0x555557c49b40] Opening '/tmp/20191218000441+0000.jpg' for writing
[file @ 0x555557cfadc0] Setting default whitelist 'file,crypto'
[AVIOContext @ 0x555557cfaec0] Statistics: 0 seeks, 1 writeouts
[rawvideo @ 0x555557c496c0] PACKET SIZE: 614400, STRIDE: 1280
[image2 @ 0x555557c49b40] Opening '/tmp/20191218000504+0000.jpg' for writing
...

I'm using the latest git version.

comment:5 by Alexandre Heitor Schmidt, 4 years ago

Cc: alexandre.schmidt@gmail.com added

comment:6 by Carl Eugen Hoyos, 4 years ago

Resolution: invalid
Status: newclosed

Not an issue that can be fixed in FFmpeg, I can reproduce with mingw32/mingw64 compiler version gcc 7.3-win32 (GCC) 20180312.

$ ffmpeg.exe -f lavfi -i testsrc2 -vframes 1 -strftime 1 %Y%m%d%H%M%S%z.jpg
ffmpeg version N-97021-gf39678b3a9 Copyright (c) 2000-2020 the FFmpeg developers
  built with Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28315 for x64
  configuration: --toolchain=msvc --enable-gpl
  libavutil      56. 42.101 / 56. 42.101
  libavcodec     58. 76.100 / 58. 76.100
  libavformat    58. 42.100 / 58. 42.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'testsrc2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 00000215ED341E80] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '%Y%m%d%H%M%S%z.jpg':
  Metadata:
    encoder         : Lavf58.42.100
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.76.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame=    1 fps=0.0 q=3.8 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.626x
video:9kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
$ ls *.jpg
20200320234505+0100.jpg
Note: See TracTickets for help on using tickets.