Opened 11 years ago

Last modified 11 years ago

#1979 new enhancement

Automatically set -fflags +genpts

Reported by: Carl Eugen Hoyos Owned by:
Priority: wish Component: ffmpeg
Version: git-master Keywords: av_interleaved_write_frame
Cc: ramitbhalla@gmail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Several tickets were opened by users who saw one of the following error messages when trying to remux: "first pts value must set" or "Can't write packet with unknown timestamp"
With the sample from ticket #1553:

$ ffmpeg -i Ts\ cannot\ be\ muxed\ to\ mkv.ts -vcodec copy -an out.mkv
ffmpeg version N-47291-g0b14c19 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 29 2012 21:54:38 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52.  9.102 / 52.  9.102
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 40.100 / 54. 40.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.104 /  3. 23.104
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x326b240] PES packet size mismatch
[mpegts @ 0x326b240] Could not find codec parameters for stream 2 (Audio: ac3 ([129][0][0][0] / 0x0081), 0 channels, s16): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[NULL @ 0x3270380] start time is not set in estimate_timings_from_pts
[mpegts @ 0x326b240] PES packet size mismatch
Input #0, mpegts, from 'Ts cannot be muxed to mkv.ts':
  Duration: 00:00:01.79, start: 58016.615744, bitrate: 9158 kb/s
  Program 1
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x34]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 384 kb/s
    Stream #0:2[0x35]: Audio: ac3 ([129][0][0][0] / 0x0081), 0 channels, s16
Output #0, matroska, to 'out.mkv':
  Metadata:
    encoder         : Lavf54.40.100
    Stream #0:0: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 29.97 fps, 1k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x3272ec0] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument

Adding -fflags +genpts fixes the problem, maybe this should be added automatically if necessary:

$ ffmpeg -fflags +genpts -i Ts\ cannot\ be\ muxed\ to\ mkv.ts -vcodec copy -an out.mkv
ffmpeg version N-47291-g0b14c19 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 29 2012 21:54:38 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52.  9.102 / 52.  9.102
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 40.100 / 54. 40.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.104 /  3. 23.104
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x195b340] PES packet size mismatch
[mpegts @ 0x195b340] Could not find codec parameters for stream 2 (Audio: ac3 ([129][0][0][0] / 0x0081), 0 channels, s16): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[NULL @ 0x1960540] start time is not set in estimate_timings_from_pts
[mpegts @ 0x195b340] PES packet size mismatch
Input #0, mpegts, from 'Ts cannot be muxed to mkv.ts':
  Duration: 00:00:01.79, start: 58016.615744, bitrate: 9158 kb/s
  Program 1
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x34]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 384 kb/s
    Stream #0:2[0x35]: Audio: ac3 ([129][0][0][0] / 0x0081), 0 channels, s16
Output #0, matroska, to 'out.mkv':
  Metadata:
    encoder         : Lavf54.40.100
    Stream #0:0: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 29.97 fps, 1k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   33 fps=0.0 q=-1.0 Lsize=    1440kB time=00:00:00.96 bitrate=12189.4kbits/s
video:1439kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.068458%

See also ticket #1415, #1552 and #1553.

Change History (7)

comment:1 by ramitb, 11 years ago

This may also be connected with Ticket #2054

comment:2 by ramitb, 11 years ago

Cc: ramitbhalla@gmail.com added

comment:3 by ramitb, 11 years ago

Any update on this, I'm coming a LOT of HD videos that are running into this issue, I need to manually set the genpts flags to get the conversion work.

comment:4 by Carl Eugen Hoyos, 11 years ago

I suggest you send a patch if you want this fixed.

comment:5 by ramitb, 11 years ago

:) - now I'm out of my league, I wouldn't know where to start. I hope I'm helping improve ffmpeg by submitting bugs. I can only request someone familiar with teh architecture/code to look at and fix this.

I will however be glad to test it and provide feedback on it.

comment:6 by reimar, 11 years ago

Maybe an easy first step would be to extend the error message to suggest using that flag?
I don't know how detecting whether genpts is necessary should be possible beforehand.

comment:7 by bernd_b, 11 years ago

I can't confirm that adding -fflags +genpts helps in every case:

ffmpeg -fflags +genpts -i Sport_HD_CUT_ntsc.264 -i Sport_HD_CUT_ntsc.ac3 -codec copy -map 0:0 -map 1:0 -f matroska  Sport_HD_CUT_ntsc.mkv
ffmpeg version 1.1.git Copyright (c) 2000-2013 the FFmpeg developers
  built on May  4 2013 13:30:41 with gcc 4.6.3 (Gentoo Hardened 4.6.3 p1.3, pie-0.5.2)
  configuration: --enable-avresample --enable-gpl --enable-libx264 --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-frei0r --enable-libsoxr --cpu=amd64 --arch=x86_64 --enable-version3
  libavutil      52. 28.100 / 52. 28.100
  libavcodec     55.  7.100 / 55.  7.100
  libavformat    55.  4.101 / 55.  4.101
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 63.101 /  3. 63.101
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[h264 @ 0x7fad8bf7f1c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'Sport_HD_CUT_ntsc.264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1200k tbn, 47.95 tbc
[ac3 @ 0x7fad8bf81480] max_analyze_duration 5000000 reached at 5024000 microseconds
[ac3 @ 0x7fad8bf81480] Estimating duration from bitrate, this may be inaccurate
Input #1, ac3, from 'Sport_HD_CUT_ntsc.ac3':
  Duration: 00:01:00.58, start: 0.000000, bitrate: 448 kb/s
    Stream #1:0: Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s
File 'Sport_HD_CUT_ntsc.mkv' already exists. Overwrite ? [y/N] y
Output #0, matroska, to 'Sport_HD_CUT_ntsc.mkv':
  Metadata:
    encoder         : Lavf55.4.101
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 1k tbn, 1200k tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 448 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x7fad8bf82240] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument

If it is of help, I can upload the example files I used. The .264 stream is a reencode done by ffmpeg itself.

Last edited 11 years ago by bernd_b (previous) (diff)
Note: See TracTickets for help on using tickets.