Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#4279 closed defect (invalid)

DTS < PCR error when using muxrate option in mpegts

Reported by: Zach Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: mpegts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When trying to encode any slate video source that contains still pictures that transition with a cut. Particularly on slides of solid colors, or other easy to compress frames.

How to reproduce:

% ffmpeg -i cut_encode_test.mp4 -f mpegts -mpegts_pmt_start_pid 0x40 -mpegts_start_pid 0x45 -vf "fps=29.97,scale=704x480" -muxrate 1000k -vcodec mpeg2video -threads 0 -tune zerolatency -pix_fmt yuv420p -b:v 500k -acodec ac3 -ar 48000 -b:a 50k -me_method epzs out.ts

ffmpeg-20150122-git-6c559a0-win64-static
built by zeranoe

Attachments (1)

cut_encode_test.mp4 (2.0 MB ) - added by Zach 9 years ago.

Change History (7)

by Zach, 9 years ago

Attachment: cut_encode_test.mp4 added

comment:1 by Zach, 9 years ago

Here is an updated simplified command with verbose mode console output.

ffmpeg -v 9 -loglevel 99 -i cut_encode_test.mp4 -f mpegts -muxrate 1000k -vcodec mpeg2video -b:v 500k -acodec ac3 -ar 48000 -b:a 50k out.ts

ffmpeg version N-69190-g6c559a0 Copyright (c) 2000-2015 the FFmpeg developers
built on Jan 22 2015 03:13:44 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avis
ynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable
-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --en
able-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmo
dplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger
--enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enab
le-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis -
-enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-li
bx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable
-zlib
libavutil 54. 17.100 / 54. 17.100
libavcodec 56. 20.100 / 56. 20.100
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 8.101 / 5. 8.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100

For help run: ffmpeg -h
For formats run: ffmpeg -formats | more
For codecs run: ffmpeg -codecs | more

Current directory is now: "C:\Users\Zach\Development\ffmpeg-20150122-git-6c559a0
-win64-static\bin"
The bin directory has been added to PATH

ffmpeg -v 9 -loglevel 99 -i cut_encode_test.mp4 -f mpegts -muxrate 1000k -vcode

c mpeg2video -b:v 500k -acodec ac3 -ar 48000 -b:a 50k out.ts
ffmpeg version N-69190-g6c559a0 Copyright (c) 2000-2015 the FFmpeg developers

built on Jan 22 2015 03:13:44 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av

isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis

--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-

libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab
le-zlib

libavutil 54. 17.100 / 54. 17.100
libavcodec 56. 20.100 / 56. 20.100
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 8.101 / 5. 8.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 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 'cut_encode_test.mp4
'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'mpeg
ts'.
Reading option '-muxrate' ... matched as AVOption 'muxrate' with argument '1000k
'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('cop
y' to copy stream)) with argument 'mpeg2video'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)
) with argument '500k'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('cop
y' to copy stream)) with argument 'ac3'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)
) with argument '48000'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)
) with argument '50k'.
Reading option 'out.ts' ... 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 cut_encode_test.mp4.
Successfully parsed a group of options.
Opening an input file: cut_encode_test.mp4.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002be8be0] Format mov,mp4,m4a,3gp,3g2,mj2 prob
ed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002be8be0] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002be8be0] Before avformat_find_stream_info()
pos: 2123942 bytes read:73458 seeks:1
[h264 @ 0000000002bf9e80] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002be8be0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002be8be0] After avformat_find_stream_info() p
os: 1406 bytes read:106226 seeks:2 frames:3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cut_encode_test.mp4':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.23.103

Duration: 00:00:35.80, start: 0.033333, bitrate: 474 kb/s

Stream #0:0(eng), 2, 1/30000: Video: h264 (High 4:2:2) (avc1 / 0x31637661),

yuv422p(left), 720x486 (720x496) [SAR 10:11 DAR 400:297], 1001/60000, 337 kb/s,
29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)

Metadata:

handler_name : VideoHandler

Stream #0:1(eng), 1, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,

stereo, fltp, 128 kb/s (default)

Metadata:

handler_name : SoundHandler

Successfully opened the file.
Parsing a group of options: output file out.ts.
Applying option f (force format) with argument mpegts.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument

mpeg2video.

Applying option b:v (video bitrate (please use -b:v)) with argument 500k.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument

ac3.

Applying option ar (set audio sampling rate (in Hz)) with argument 48000.
Applying option b:a (video bitrate (please use -b:v)) with argument 50k.
Successfully parsed a group of options.
Opening an output file: out.ts.
Successfully opened the file.
detected 2 logical cores
[graph 0 input from stream 0:0 @ 0000000002bcd9a0] Setting 'video_size' to value

'720x486'

[graph 0 input from stream 0:0 @ 0000000002bcd9a0] Setting 'pix_fmt' to value '4
'
[graph 0 input from stream 0:0 @ 0000000002bcd9a0] Setting 'time_base' to value
'1/30000'
[graph 0 input from stream 0:0 @ 0000000002bcd9a0] Setting 'pixel_aspect' to val
ue '10/11'
[graph 0 input from stream 0:0 @ 0000000002bcd9a0] Setting 'sws_param' to value
'flags=2'
[graph 0 input from stream 0:0 @ 0000000002bcd9a0] Setting 'frame_rate' to value

'30000/1001'

[graph 0 input from stream 0:0 @ 0000000002bcd9a0] w:720 h:486 pixfmt:yuv422p tb
:1/30000 fr:30000/1001 sar:10/11 sws_param:flags=2
[format @ 0000000002d28040] compat: called with args=[yuv420p|yuv422p]
[format @ 0000000002d28040] Setting 'pix_fmts' to value 'yuv420p|yuv422p'
[AVFilterGraph @ 0000000002d28ae0] query_formats: 4 queried, 3 merged, 0 already

done, 0 delayed

No pixel format specified, yuv422p for MPEG-2 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[graph 1 input from stream 0:1 @ 0000000002d2d120] Setting 'time_base' to value
'1/48000'
[graph 1 input from stream 0:1 @ 0000000002d2d120] Setting 'sample_rate' to valu
e '48000'
[graph 1 input from stream 0:1 @ 0000000002d2d120] Setting 'sample_fmt' to value

'fltp'

[graph 1 input from stream 0:1 @ 0000000002d2d120] Setting 'channel_layout' to v
alue '0x3'
[graph 1 input from stream 0:1 @ 0000000002d2d120] tb:1/48000 samplefmt:fltp sam
plerate:48000 chlayout:0x3
[audio format for output stream 0:1 @ 0000000002d2d2a0] Setting 'sample_fmts' to

value 'fltp'

[audio format for output stream 0:1 @ 0000000002d2d2a0] Setting 'sample_rates' t
o value '48000'
[audio format for output stream 0:1 @ 0000000002d2d2a0] Setting 'channel_layouts
' to value '0x4|0x3|0x103|0x7|0x603|0x33|0x107|0x607|0x37|0xc|0xb|0x10b|0xf|0x60
b|0x3b|0x10f|0x60f|0x3f'
[AVFilterGraph @ 0000000002d2c300] query_formats: 4 queried, 9 merged, 0 already

done, 0 delayed

[mpeg2video @ 0000000002bfb5a0] intra_quant_bias = 96 inter_quant_bias = 0
[mpegts @ 000000000570f0c0] muxrate 1000000, pcr every 13 pkts, sdt every 332, p
at/pmt every 66 pkts
Output #0, mpegts, to 'out.ts':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.19.100
Stream #0:0(eng), 0, 1/90000: Video: mpeg2video, yuv422p(left), 720x486 [SAR

10:11 DAR 400:297], 1001/30000, q=2-31, 500 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
(default)

Metadata:

handler_name : VideoHandler
encoder : Lavc56.20.100 mpeg2video

Stream #0:1(eng), 0, 1/90000: Audio: ac3, 48000 Hz, stereo, fltp, 48 kb/s (d

efault)

Metadata:

handler_name : SoundHandler
encoder : Lavc56.20.100 ac3

Stream mapping:

Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
Stream #0:1 -> #0:1 (aac (native) -> ac3 (native))

Press [q] to stop, ? for help
[h264 @ 0000000005623600] no picture
[h264 @ 0000000005624580] no picture
* 1 dup!
Cliping frame in rate conversion by 0.000999

Last message repeated 31 times

frame= 34 fps=0.0 q=2.0 size= 131kB time=00:00:01.17 bitrate= 908.5kbits/s
Cliping frame in rate conversion by 0.000999

Last message repeated 27 times

frame= 62 fps= 61 q=1.6 size= 252kB time=00:00:02.10 bitrate= 978.1kbits/s
Cliping frame in rate conversion by 0.000999

Last message repeated 32 times

frame= 95 fps= 61 q=1.6 size= 440kB time=00:00:03.22 bitrate=1117.7kbits/s
Cliping frame in rate conversion by 0.000999

Last message repeated 11 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 5 times

Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 5 times

frame= 108 fps= 50 q=2.0 size= 543kB time=00:00:03.64 bitrate=1220.5kbits/s
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 3 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 23 times

frame= 119 fps= 42 q=1.6 size= 620kB time=00:00:04.02 bitrate=1261.3kbits/s
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 4 times

Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 1 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 25 times

frame= 131 fps= 38 q=1.6 size= 707kB time=00:00:04.41 bitrate=1312.8kbits/s
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 4 times

Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 1 times

Cliping frame in rate conversion by 0.000999

Last message repeated 1 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 1 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 25 times

frame= 143 fps= 34 q=1.6 size= 797kB time=00:00:04.82 bitrate=1352.0kbits/s
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 4 times

Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 1 times

Cliping frame in rate conversion by 0.000999

Last message repeated 1 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 2 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid
Cliping frame in rate conversion by 0.000999

Last message repeated 1 times

[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 25 times

frame= 155 fps= 31 q=1.6 size= 887kB time=00:00:05.21 bitrate=1393.8kbits/s
Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 4 times

Cliping frame in rate conversion by 0.000999
[mpegts @ 000000000570f0c0] dts < pcr, TS is invalid

Last message repeated 1 times

frame= 157 fps= 31 q=2.8 Lsize= 907kB time=00:00:05.27 bitrate=1408.3kbits/
s dup=1 drop=0
video:552kB audio:31kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 55.425217%
Input file #0 (cut_encode_test.mp4):

Input stream #0:0 (video): 160 packets read (348977 bytes); 157 frames decoded

;

Input stream #0:1 (audio): 248 packets read (84650 bytes); 248 frames decoded

(253952 samples);

Total: 408 packets (433627 bytes) demuxed

Output file #0 (out.ts):

Output stream #0:0 (video): 157 frames encoded; 157 packets muxed (565734 byte

s);

Output stream #0:1 (audio): 165 frames encoded (253440 samples); 165 packets m

uxed (31680 bytes);

Total: 322 packets (597414 bytes) muxed

409 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0000000002bf1d40] Statistics: 0 seeks, 175 writeouts
[AVIOContext @ 0000000002bf1520] Statistics: 532293 bytes read, 2 seeks
Received signal 2: terminating.

comment:2 by Zach, 9 years ago

So after simplifying the command further by removing the audio, and playing with the bit rates I noticed some weird behavior. I went to using the original source file I recorded on a hyperdeck shuttle, because I was not sure if the source bit rate effected anything. That file is too large to upload here, but the mp4 I uploaded shows the same behavior at a slightly lower bit rate.

The error does not happen when I have the muxrate 50k more then three times the video bit rate for this test file. If I omit the -b:v argument, then I can go down to 1401k. This also happens with audio present at higher bit rates with more complex video. This appears to be the encoder or mux breaking down for some reason, but I am not sure what to pursue as the cause.

I will experiment further with more complex video. My goal is to encode video in the 2-3 Mbps range for use on ATSC TV, hence the requirement for a tight pcr interval that FFmpeg only does when using the muxrate command.

ffmpeg -v 9 -loglevel 99 -i "C:/Users/Zach/Development/Test Files/Capture0000.mov" -f mpegts -muxrate 1000k -vcodec mpeg2video -b:v 500k -an out.ts

and

ffmpeg -v 9 -loglevel 99 -i "C:/Users/Zach/Development/Test Files/Capture0000.mov" -f mpegts -muxrate 1401k -vcodec mpeg2video -an out.ts

comment:4 by Roger Pack, 9 years ago

I know there were some complaints in the comments here: http://www.waveguide.se/?article=creating-dvb-t-compatible-mpeg2-streams-using-ffmpeg (which may contain some other helpful info) about ffmpeg's TS muxer being broken? Same thing?

comment:5 by Michael Niedermayer, 9 years ago

Resolution: invalid
Status: newclosed

No max rate and VBV buffer size is set so the bitrate can exceed the muxrate and fail.
its impossible to store a stream that exceeds the muxrate in the VBV sense significantly with said muxrate. To avoid such cases the parameters have to be set up correctly, the exact parameters depend on the target one encodes for ...

comment:6 by Carl Eugen Hoyos, 9 years ago

Keywords: mpegts added
Note: See TracTickets for help on using tickets.