Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#4532 closed defect (fixed)

ffmpeg (vers. 2.3.4 or 2.6.2) - "-timestamp" option doesn't work any more

Reported by: wolfi Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: timestamp regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:

In earlier versions (I have: "ffmpeg version 0.7.13-rpmfusion" ) the option "-timestamp '2015-05-01 12:34:56'" correctly set the output-file's metadata.
The newer version "ffmpeg version 2.3.4" - or even 2.6.2-static just bails out with:

Option timestamp (set the recording timestamp ('now' to set the current time)) cannot be applied to output file /tmp/x.mp4 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for output file /tmp/x.mp4.
Error opening output files: Invalid argument

How to reproduce:

% ffmpeg -i input.file -timestamp "2015-05-01 12:34:56" /tmp/output.mp4


EXAMPLE OF WORKING VERSION:

$>  ffmpeg -v 9 -loglevel 99 -i 2015-05-01-Taufe-Matilda-3.MTS -timestamp "2015-05-01 12:34:56" /tmp/x.mp4
ffmpeg version 0.7.13-rpmfusion, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 13 2012 10:31:41 with gcc 4.6.3 20120306 (Red Hat 4.6.3-2)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --extra-version=rpmfusion --enable-bzlib --enable-libcelt --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil    50. 43. 0 / 50. 43. 0
  libavcodec   52.123. 0 / 52.123. 0
  libavformat  52.111. 0 / 52.111. 0
  libavdevice  52.  5. 0 / 52.  5. 0
  libavfilter   1. 80. 0 /  1. 80. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
[mpegts @ 0x1e8a2a0] Format mpegts probed with size=2048 and score=100
[mpegts @ 0x1e8a2a0] stream=0 stream_type=1b pid=1011 prog_reg_desc=HDPR
[mpegts @ 0x1e8a2a0] stream=1 stream_type=81 pid=1100 prog_reg_desc=HDPR
[mpegts @ 0x1e8a2a0] stream=2 stream_type=90 pid=1200 prog_reg_desc=HDPR
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2500
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2499
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2498
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2497
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2496
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2495
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2494
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2493
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2492
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2491
[mpegts @ 0x1e8a2a0] probing stream 2 pp:2490
[mpegts @ 0x1e8a2a0] probed stream 2 failed
[h264 @ 0x1e90340] no picture
[mpegts @ 0x1e8a2a0] Probe buffer size limit 5000000 reached
Input #0, mpegts, from '2015-05-01-Taufe-Matilda-3.MTS':
  Duration: 00:00:21.11, start: 1.000011, bitrate: 26326 kb/s
  Program 1 
    Stream #0.0[0x1011], 83, 1/90000: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 1/100, 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0.1[0x1100], 46, 1/90000: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
    Stream #0.2[0x1200], 20, 1/90000: Data: [144][0][0][0] / 0x0090
[buffer @ 0x1e8a1e0] w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
Output #0, mp4, to '/tmp/x.mp4':
  Metadata:
    encoder         : Lavf52.111.0
    Stream #0.0, 0, 1/50: Video: mpeg4, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 1/50, q=2-31, 200 kb/s, 50 tbn, 50 tbc
    Stream #0.1, 0, 1/48000: Audio: aac, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
[h264 @ 0x1e90340] no picture
frame= 1056 fps=  8 q=31.0 Lsize=    7386kB time=00:00:21.12 bitrate=2864.8kbits/s    
video:7199kB audio:169kB global headers:0kB muxing overhead 0.237651%




and checking via 'exiftool' that the dates are in:

> exiftool /tmp/x.mp4 | grep 2015

File Modification Date/Time     : 2015:05:04 13:06:09+02:00
Create Date                     : 2015:05:01 10:34:56
Modify Date                     : 2015:05:01 10:34:56
Track Create Date               : 2015:05:01 10:34:56
Track Modify Date               : 2015:05:01 10:34:56
Media Create Date               : 2015:05:01 10:34:56
Media Modify Date               : 2015:05:01 10:34:56


------------------------------------------------------------------
NONWORKING (current) case:

t440:/mnt/nasbox/videos/ORIG > ffmpeg -v 9 -loglevel 99 -i 2015-05-01-Taufe-Matilda-3.MTS -timestamp "2015-05-01 14:33:01" /tmp/x.mp4
ffmpeg started on 2015-05-04 at 13:02:01
Report written to "ffmpeg-20150504-130201.log"
ffmpeg version 2.3.4 Copyright (c) 2000-2014 the FFmpeg developers
  built on Feb 25 2015 16:24:30 with gcc 4.8.2 (GCC) 20140120 (Red Hat 4.8.2-16)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-libass --enable-libcdio --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      52. 92.100 / 52. 92.100
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 48.100 / 55. 48.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.100 /  4. 11.100
  libavresample   1.  3.  0 /  1.  3.  0
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument '2015-05-01-Taufe-Matilda-3.MTS'.
Reading option '-timestamp' ... matched as option 'timestamp' (set the recording timestamp ('now' to set the current time)) with argument '2015-05-01 14:33:01'.
Reading option '/tmp/x.mp4' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file 2015-05-01-Taufe-Matilda-3.MTS.
Successfully parsed a group of options.
Opening an input file: 2015-05-01-Taufe-Matilda-3.MTS.
[mpegts @ 0x1060cc0] Format mpegts probed with size=2048 and score=99
[mpegts @ 0x1060cc0] stream=0 stream_type=1b pid=1011 prog_reg_desc=HDPR
[mpegts @ 0x1060cc0] stream=1 stream_type=81 pid=1100 prog_reg_desc=HDPR
[mpegts @ 0x1060cc0] stream=2 stream_type=90 pid=1200 prog_reg_desc=HDPR
[mpegts @ 0x1060cc0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0
[mpegts @ 0x1060cc0] parser not found for codec hdmv_pgs_subtitle, packets or times may be invalid.
[mpegts @ 0x1060cc0] All programs have pmt, headers found
[mpegts @ 0x1060cc0] parser not found for codec hdmv_pgs_subtitle, packets or times may be invalid.
[mpegts @ 0x1060cc0] Non-increasing DTS in stream 2: packet 2 with DTS 85877, packet 3 with DTS 85877
[h264 @ 0x1064d40] unknown SEI type 128
[h264 @ 0x1064d40] no picture 
[mpegts @ 0x1060cc0] All info found
[mpegts @ 0x1060cc0] After avformat_find_stream_info() pos: 0 bytes read:1478800 seeks:2 frames:33
Input #0, mpegts, from '2015-05-01-Taufe-Matilda-3.MTS':
  Duration: 00:00:21.12, start: 1.020000, bitrate: 26326 kb/s
  Program 1 
    Stream #0:0[0x1011], 21, 1/90000: Video: h264 (High) (HDPR / 0x52504448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1/100, 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0:1[0x1100], 7, 1/90000: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1200], 5, 1/90000: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Successfully opened the file.
Parsing a group of options: output file /tmp/x.mp4.

Option timestamp (set the recording timestamp ('now' to set the current time)) cannot be applied to output file /tmp/x.mp4 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for output file /tmp/x.mp4.

Error opening output files: Invalid argument
[AVIOContext @ 0x1058680] Statistics: 1478800 bytes read, 2 seeks


...as you can see - it fails at the option-parse stage already.

The 'severity' here is, that you can't set essential metadata on the output.


and - what versions are showing this ?
well - 2.3.4 - and also 2.6.2-static show this.




Change History (3)

comment:1 by wolfi, 9 years ago

Ok - further looked at this:

the source shows the workaround - tested and works:

ffmpeg_opt.c: opt_recording_timestamp():

av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "

"tag instead.\n", opt);

and indeed - that works. e.g: -metadata 'creation_time=2015-05-01 11:22:00'
does correctly set it - as it's verifiable via 'exiftool':

exiftool /tmp/zz.mp4 | grep 2015

File Modification Date/Time : 2015:05:04 15:38:15+02:00
File Access Date/Time : 2015:05:04 15:38:16+02:00
File Inode Change Date/Time : 2015:05:04 15:38:15+02:00
Create Date : 2015:05:01 11:22:00
Modify Date : 2015:05:01 11:22:00
Track Create Date : 2015:05:01 11:22:00
Track Modify Date : 2015:05:01 11:22:00
Media Create Date : 2015:05:01 11:22:00
Media Modify Date : 2015:05:01 11:22:00

...now - what remains from this bug:

a.) the - man-page of (git head) ffmpeg still says:

-timestamp date (output)

Set the recording timestamp in the container.

date must be a time duration specification,
see the Date section in the ffmpeg-utils(1) manual.

...which is quite misleading - as it's not working that way.

comment:2 by Michael Niedermayer, 9 years ago

Reproduced by developer: set
Resolution: fixed
Status: newclosed

comment:3 by Carl Eugen Hoyos, 9 years ago

Keywords: timestamp regression added; -timestamp removed
Version: 2.3.5git-master
Note: See TracTickets for help on using tickets.