Opened 4 years ago

Last modified 2 years ago

#5184 open defect

Incorrect pts at start of avi file

Reported by: Misaki Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: avi dts
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no


The included file is .avi, and therefore has to presentation timestamps, only decoding timestamps. Maybe the video codec is part of the reason. ffprobe shows a pts only for the first frame, no others have one.




(the rest continue)




(the rest continue)

The bug might be that the decoder is giving the first frame a dts of 1 instead of 0, while still keeping the pts at 0, and so later frames are also one timestamp late. Since they don't have a pts, they are assigned the same value as the dts.

ffmpeg -i (video) -vf showinfo -t 0.2 -an -f null -hide_banner - :

[Parsed_showinfo_0 @ 0x2601240] n: 0 pts: 0 pts_time:0 pos: 165604 fmt:yuv420p sar:1/1 s:1800x1004 i:P iskey:1 type:I checksum:4B4CD06C plane_checksum:[911ACB2B CFADC078 44C544BA] mean:[96 123 141] stdev:[17.9 5.3 7.3]
[Parsed_showinfo_0 @ 0x2601240] side data - pan/scan
[null @ 0x2608420] Encoder did not produce proper pts, making some up.
[Parsed_showinfo_0 @ 0x2601240] n: 1 pts: 2 pts_time:0.0666667 pos: 314468 fmt:yuv420p sar:1/1 s:1800x1004 i:P iskey:0 type:P checksum:572F13E7 plane_checksum:[AB01FD9B E4B0AFBF 64BC666F] mean:[96 123 141] stdev:[17.8 5.3 7.3]
[Parsed_showinfo_0 @ 0x2601240] side data - pan/scan
[Parsed_showinfo_0 @ 0x2601240] n: 2 pts: 3 pts_time:0.1 pos: 351150 fmt:yuv420p sar:1/1 s:1800x1004 i:P iskey:0 type:P checksum:2EB120B0 plane_checksum:[39B5068A 516DB19C F3B3687B] mean:[96 123 141] stdev:[17.8 5.3 7.3]
[Parsed_showinfo_0 @ 0x2601240] side data - pan/scan
[Parsed_showinfo_0 @ 0x2601240] n: 3 pts: 4 pts_time:0.133333 pos: 356674 fmt:yuv420p sar:1/1 s:1800x1004 i:P iskey:0 type:P checksum:13EDC4DB plane_checksum:[A5F2511C 3A8F893F 8C8BEA71] mean:[96 123 141] stdev:[17.4 5.2 7.2]

It's a little bit confusing because showinfo says they have a pts, but null output says they don't. I'm guessing showinfo is wrong. (In another, unsubmitted bug, the value of 'pos' shown by showinfo differs from that used by the select filter in some cases..~)

I don't know if this bug affects all avi files, but it affects all files in a sample of 9 similar avi files from the same source.

As it seems that -show_frames is correct, the simple solution is to use a setpts=N filter, but this isn't an obvious bug. A group of 6 avi files, a subset of the 9, all had a duplicate frame at the start (the example file doesn't). lavf/lavc isn't mentioned in the file metadata, but it suggests another program could be producing duplicate frames in a similar way.

Some lines from the avi demuxer using -v trace:

[avi @ 0x1d0ae60] overriding invalid dshow_block_align of 1
[avi @ 0x1d0ae60] movi_end=0x11d99bc
[avi @ 0x1d0ae60] Before avformat_find_stream_info() pos: 165012 bytes read:65536 seeks:3
[avi @ 0x1d0ae60] dts:0 offset:0 1000/24000000 smpl_siz:1 base:1000000 st:1 size:576
[avi @ 0x1d0ae60] dts:0 offset:0 10000/300000 smpl_siz:0 base:1000000 st:0 size:148272
[avi @ 0x1d0ae60] All info found
[avi @ 0x1d0ae60] 0: start_time: 0.000 duration: 0.000
[avi @ 0x1d0ae60] 1: start_time: 0.000 duration: -9223372036854.775
[avi @ 0x1d0ae60] stream: start_time: 0.000 duration: 2.567 bitrate=6383 kb/s

encoder : BandiAviMuxer? 1.0

Duration: 00:00:02.57, start: 0.000000, bitrate: 6383 kb/s

Stream #0:0, 1, 1/30: Video: mpeg1video, 1 reference frame (MPEG / 0x4745504D), yu[...]

[avi @ 0x1d0ae60] dts:1 offset:1 10000/300000 smpl_siz:0 base:1000000 st:0 size:35505
[null @ 0x1d11400] Encoder did not produce proper pts, making some up.
[avi @ 0x1d0ae60] dts:2 offset:2 10000/300000 smpl_siz:0 base:1000000 st:0 size:4931
[avi @ 0x1d0ae60] dts:3 offset:3 10000/300000 smpl_siz:0 base:1000000 st:0 size:30745
[avi @ 0x1d0ae60] dts:4 offset:4 10000/300000 smpl_siz:0 base:1000000 st:0 size:313
[avi @ 0x1d0ae60] dts:5 offset:5 10000/300000 smpl_siz:0 base:1000000 st:0 size:21891
[avi @ 0x1d0ae60] dts:6 offset:6 10000/300000 smpl_siz:0 base:1000000 st:0 size:25706

Attachments (1)

Shadow Hearts IIカレン動画 - パンチラ見るだけ (2)-sample.avi (2.0 MB) - added by Misaki 4 years ago.
avi file with no pts, leading to bug

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by Misaki

avi file with no pts, leading to bug

comment:1 Changed 4 years ago by Misaki

  • Version changed from unspecified to 2.7.3

comment:2 Changed 4 years ago by cehoyos

Please test current FFmpeg git head and provide the command line that allows to reproduce the issue together with the complete, uncut console output to make this a valid ticket.

comment:3 Changed 4 years ago by cehoyos

  • Keywords avi dts added
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from 2.7.3 to git-master
$ ffmpeg -i Shadow\ Hearts\ IIカレン動画\ -\ パンチラ見るだけ\ \(2\)-sample.avi -vcodec copy -an out.mkv
ffmpeg version N-81038-gd688f39 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 50.100 / 57. 50.100
  libavformat    57. 44.100 / 57. 44.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, avi, from 'Shadow Hearts IIカレン動画 - パンチラ見るだけ (2)-sample.avi':
    encoder         : BandiAviMuxer 1.0
  Duration: 00:00:02.57, start: 0.000000, bitrate: 6383 kb/s
    Stream #0:0: Video: mpeg1video (MPEG / 0x4745504D), yuv420p(tv), 1800x1004 [SAR 1:1 DAR 450:251], 104857 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 192 kb/s
[matroska @ 0x26b91a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, matroska, to 'out.mkv':
    encoder         : Lavf57.44.100
    Stream #0:0: Video: mpeg1video (mpg1 / 0x3167706D), yuv420p(tv), 1800x1004 [SAR 1:1 DAR 450:251], q=2-31, 104857 kb/s, 30 fps, 30 tbr, 1k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x26b91a0] 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
[matroska @ 0x26b91a0] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument
frame=    2 fps=0.0 q=-1.0 Lsize=     145kB time=00:00:00.03 bitrate=35041.4kbits/s speed= 141x
video:179kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

comment:4 Changed 2 years ago by cehoyos

Workaround is to use -fflags +genpts

Note: See TracTickets for help on using tickets.