OvenMediaEngine icon indicating copy to clipboard operation
OvenMediaEngine copied to clipboard

Streaming record muxer error

Open kage212 opened this issue 2 years ago • 29 comments

Hello OME team,

Describe the bug While streaming and recording with a drone, Application provided invalid, non monotonically increasing dts to muxer in stream, Then if you check the record you can see a tmp file with a few kb

To Reproduce Steps to reproduce the behavior:

<Server version="8">
        <Name>OvenMediaEngine</Name>
        <!-- Host type (origin/edge) -->
        <Type>origin</Type>
        <!-- Specify IP address to bind (* means all IPs) -->
        <IP>*</IP>
        <PrivacyProtection>false</PrivacyProtection>
        <!--
        To get the public IP address(mapped address of stun) of the local server.
        This is useful when OME cannot obtain a public IP from an interface, such as AWS or docker environment.
        If this is successful, you can use ${PublicIP} in your settings.
        -->
        <StunServer>stun.l.google.com:19302</StunServer>
        <!-- Settings for the ports to bind -->
        <Bind>
                <!-- Enable this configuration if you want to use API Server -->
                <Managers>
                        <API>
                                <Port>8081</Port>
                                <WorkerCount>1</WorkerCount>
                        </API>
                </Managers>
                <Providers>
                        <!-- Pull providers -->
                        <RTSPC>
                                <WorkerCount>1</WorkerCount>
                        </RTSPC>
                        <OVT>
                                <WorkerCount>1</WorkerCount>
                        </OVT>
                        <!-- Push providers -->
                        <RTMP>
                                <Port>${env:OME_RTMP_PROV_PORT:1935}</Port>
                                <WorkerCount>1</WorkerCount>
                        </RTMP>
                        <SRT>
                                <Port>${env:OME_SRT_PROV_PORT:9999}</Port>
                                <WorkerCount>1</WorkerCount>
                        </SRT>
                        <MPEGTS>
                                <!--
                                        Listen on port 4000-4005
                                        This is just a demonstration to show that you can configure the port in several ways
                                -->
                                <Port>${env:OME_MPEGTS_PROV_PORT:4000/udp}</Port>
                        </MPEGTS>
                        <WebRTC>
                                <Signalling>
                                        <Port>${env:OME_SIGNALLING_PORT:3333}</Port>
                                        <WorkerCount>1</WorkerCount>
                                        <!-- If you want to use TLS, specify the TLS port -->
                                        <TLSPort>3334</TLSPort>
                                </Signalling>
                                <IceCandidates>
                                        <TcpRelay>${env:OME_TCP_RELAY_ADDRESS:*:3478}</TcpRelay>
                                        <TcpForce>true</TcpForce>
                                        <TcpRelayWorkerCount>1</TcpRelayWorkerCount>
                                        <IceCandidate>${env:OME_ICE_CANDIDATES:*:10006/udp}</IceCandidate>
                                </IceCandidates>
                        </WebRTC>
                </Providers>
                <Publishers>
                        <!-- The OVT is protocol for ORIGIN-EDGE -->
                        <OVT>
                                <Port>${env:OME_ORIGIN_PORT:9000}</Port>
                                <WorkerCount>1</WorkerCount>
                        </OVT>
                        <HLS>
                                <Port>${env:OME_HLS_STREAM_PORT:8080}</Port>
                                <WorkerCount>1</WorkerCount>
                                <!-- If you want to use TLS, specify the TLS port -->
                                <!-- <TLSPort>443</TLSPort> -->
                        </HLS>
                        <DASH>
                                <Port>${env:OME_DASH_STREAM_PORT:8080}</Port>
                                <WorkerCount>1</WorkerCount>
                                <!-- If you want to use TLS, specify the TLS port -->
                                <!-- <TLSPort>443</TLSPort> -->
                        </DASH>
                        <WebRTC>
                                <Signalling>
                                        <Port>${env:OME_SIGNALLING_PORT:3333}</Port>
                                        <WorkerCount>1</WorkerCount>
                                        <!-- If you want to use TLS, specify the TLS port -->
                                        <TLSPort>3334</TLSPort>
                                </Signalling>
                                <IceCandidates>
                                        <TcpRelay>${env:OME_TCP_RELAY_ADDRESS:*:3478}</TcpRelay>
                                        <TcpForce>true</TcpForce>
                                        <TcpRelayWorkerCount>1</TcpRelayWorkerCount>
                                        <IceCandidate>${env:OME_ICE_CANDIDATES:*:10006/udp}</IceCandidate>
                                </IceCandidates>
                        </WebRTC>
                </Publishers>
        </Bind>
        <Managers>
                <Host>
                        <Names>
                                <Name>*</Name>
                </Names>
                </Host>
                <API>
                <AccessToken>test64</AccessToken>
        </API>
        </Managers>
        <VirtualHosts>
                <!--
                        You can include multiple XML files by doing the following:
                        <VirtualHost include="sites-enabled/*.xml" />
                -->
                <VirtualHost include="VHost*.xml" />
                <VirtualHost>
                        <Name>default</Name>
                        <!--Distribution is a value that can be used when grouping the same vhost distributed across multiple servers. This value is output to the events log, so you can use it to aggregate statistics. -->
                        <Distribution>ovenmediaengine.com</Distribution>
                        <!-- Settings for multi ip/domain and TLS -->
                        <Host>
                                <Names>
                                        <!-- Host names
                                                <Name>stream1.airensoft.com</Name>
                                                <Name>stream2.airensoft.com</Name>
                                                <Name>*.sub.airensoft.com</Name>
                                                <Name>192.168.0.1</Name>
                                        -->
                                        <Name>*</Name>
                                </Names>
                                <TLS>
                                        <CertPath>test.crt</CertPath>
                                        <KeyPath>test.key</KeyPath>
                                        <!-- <ChainCertPath>path/to/file.crt</ChainCertPath> -->
                                </TLS>
                        </Host>
                        <AdmissionWebhooks>
                                <ControlServerUrl>http://192.168.110.140:3000/api/admissions/add</ControlServerUrl>
                                <!-- <ControlServerUrl>http://192.168.1.52:3000/api/admissions/add</ControlServerUrl> -->
                                <SecretKey>z3vG#hvK</SecretKey>
                                <Timeout>3000</Timeout>
                                <Enables>
                                        <Providers>rtmp,webrtc,srt</Providers>
                                        <Publishers>webrtc,hls,dash,lldash</Publishers>
                                </Enables>
                        </AdmissionWebhooks>
                        <SignedPolicy>
                                <PolicyQueryKeyName>policy</PolicyQueryKeyName>
                                <SignatureQueryKeyName>signature</SignatureQueryKeyName>
                                <SecretKey>z3vG#hvK</SecretKey>
                                <Enables>
                                        <Providers>rtmp,webrtc,srt</Providers>
                                        <Publishers>webrtc,hls,dash,lldash</Publishers>
                                </Enables>
                        </SignedPolicy>
                        <!-- Settings for applications -->
                        <Applications>
                                <Application>
                                        <Name>app</Name>
                                        <!-- Application type (live/vod) -->
                                        <Type>live</Type>
                                        <OutputProfiles>
                                                <OutputProfile>
                                                        <Name>bypass_stream</Name>
                                                        <OutputStreamName>${OriginStreamName}</OutputStreamName>
                                                        <Encodes>
                                                                <Audio>
                                                                        <Bypass>true</Bypass>
                                                                </Audio>
                                                                <Video>
                                                                        <Bypass>true</Bypass>
                                                                </Video>
                                                                <Audio>
                                                                        <Codec>opus</Codec>
                                                                        <Bitrate>128000</Bitrate>
                                                                        <Samplerate>48000</Samplerate>
                                                                        <Channel>2</Channel>
                                                                </Audio>
                                                        </Encodes>
                                                </OutputProfile>
                                        </OutputProfiles>
                                        <Providers>
                                                <OVT />
                                                <WebRTC />
                                                <RTMP />
                                                <SRT />
                                                <RTSPPull />
                                                <MPEGTS>
                                                        <StreamMap>
                                                                <!--
                                                                        Set the stream name of the client connected to the port to "stream_${Port}"
                                                                        For example, if a client connets to port 4000, OME creates a "stream_4000" stream
                                                                        <Stream>
                                                                                <Name>stream_${Port}</Name>
                                                                                <Port>4000,4001-4004</Port>
                                                                        </Stream>
                                                                        <Stream>
                                                                                <Name>stream_4005</Name>
                                                                                <Port>4005</Port>
                                                                        </Stream>
                                                                -->
                                                                <Stream>
                                                                        <Name>stream_${Port}</Name>
                                                                        <Port>4000</Port>
                                                                </Stream>
                                                        </StreamMap>
                                                </MPEGTS>
                                        </Providers>
                                        <Publishers>
                                                <AppWorkerCount>1</AppWorkerCount>
                                                <StreamWorkerCount>8</StreamWorkerCount>
                                                <OVT />
                                                <WebRTC>
                                                        <Timeout>30000</Timeout>
                                                        <Rtx>false</Rtx>
                                                        <Ulpfec>false</Ulpfec>
                                                        <JitterBuffer>false</JitterBuffer>
                                                </WebRTC>
                                                <HLS>
                                                        <SegmentDuration>5</SegmentDuration>
                                                        <SegmentCount>3</SegmentCount>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                </HLS>
                                                <DASH>
                                                        <SegmentDuration>5</SegmentDuration>
                                                        <SegmentCount>3</SegmentCount>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                        <UTCTiming />
                                                </DASH>
                                                <LLDASH>
                                                        <SegmentDuration>5</SegmentDuration>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                        <UTCTiming />
                                                </LLDASH>
                                                <Thumbnail>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                </Thumbnail>
                                                <FILE>
                                                        <RootPath>/mnt/shared_volumes</RootPath>
                                                        <FilePath>/${VirtualHost}/${Application}/${Stream}/${StartTime:YYYYMMDDhhmmss}_${EndTime:YYYYMMDDhhmmss}.ts</FilePath>
                                                        <InfoPath>/${VirtualHost}/${Application}/${Stream}.xml</InfoPath>
                                                </FILE>
                                        </Publishers>
                                </Application>
                        </Applications>
                </VirtualHost>
        </VirtualHosts>
</Server>

Expected behavior A record from the drone or camera streaming

Logs [2022-04-21 15:09:29.454] E [AW-HLS0:44] Writer | writer.cpp:721 | [0x7fcea4073630] Could not write the frame: Invalid argument [2022-04-21 15:09:29.454] E [AW-DASH0:45] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7fce8000bec0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 6099536 >= 6099536 [2022-04-21 15:09:29.454] E [AW-DASH0:45] Writer | writer.cpp:721 | [0x7fcea40b3bd0] Could not write the frame: Invalid argument [2022-04-21 15:09:29.464] E [AW-HLS0:44] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7fceac01a040] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 34318350 >= 34318350 [2022-04-21 15:09:29.464] E [AW-HLS0:44] Writer | writer.cpp:721 | [0x7fcea4073630] Could not write the frame: Invalid argument [2022-04-21 15:09:29.464] E [AW-DASH0:45] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7fce8000bec0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 6101040 >= 6101040 [2022-04-21 15:09:29.464] E [AW-DASH0:45] Writer | writer.cpp:721 | [0x7fcea40b3bd0] Could not write the frame: Invalid argument [2022-04-21 15:09:29.467] E [AW-HLS0:44] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7fceac01a040] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 34323120 >= 34323120 [2022-04-21 15:09:29.467] E [AW-HLS0:44] Writer | writer.cpp:721 | [0x7fcea4073630] Could not write the frame: Invalid argument [2022-04-21 15:09:29.467] E [AW-DASH0:45] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7fce8000bec0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 6101888 >= 6101888

Server (please complete the following information):

  • OvenMediaEngine Version: v0.13.2

Thanks Regards

kage212 avatar Apr 22 '22 10:04 kage212

What protocol does the drone send the stream over (although it doesn't matter if it's a drone)? The timestamp value of the incoming stream seems to be incorrect. Please explain in more detail why you think this is a bug in OME.

getroot avatar Apr 22 '22 14:04 getroot

Protocol: RTMP - Record: TS files

The bug is not itself OME but ffmpeg? I dont know if is a bug or not thats why I publish here that. I saw this issue before: https://github.com/AirenSoft/OvenMediaEngine/issues/645 And you said this: I think the best solution would be to make ffmpeg send the correct pts and dts. How we can correct from drone or camera? Is there anyway to see what ffmpeg executes to record/stream?

Thanks

kage212 avatar Apr 25 '22 13:04 kage212

@kage212

Streaming to OME with ffmpeg from a drone? could you please share the ffmpeg command you used to send to OME? I am trying to reproduce it with the same command. I think the dts is being transmitted in duplicate. I want to find out why.

Thanks

Keukhan avatar Apr 25 '22 14:04 Keukhan

Could you please explain in more detail what "force another codec" means?

getroot avatar Apr 27 '22 12:04 getroot

Hello,

The problem happends when the stream that is provided to OME, has non monotonically increasing dts in consecutive frames. In this case the visualization works fine but if you try to record the stream you will get the following warning and the recording file is corrupted: [2022-04-21 15:09:29.464] E [AW-DASH0:45] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7fce8000bec0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 6101040 >= 6101040

@Keukhan To reproduce this:

  1. Create a POST requesting to create a record.
  2. Download this .ts file from here https://trac.ffmpeg.org/attachment/ticket/960/sample-non-monotonic-dts_cut.ts
  3. Execute this command: ffmpeg -re -stream_loop -1 -i /your-path/sample-non-monotonic-dts_cut.ts -vcodec copy -preset ultrafast -b:v 1500k -acodec aac -b:a 256k -ar 96000 -f flv "rtmp://**********:1935/app/**************"
  4. See logs

If you use nginx-rtmp-module for example you can record without this problem.

Thanks Regards

kage212 avatar Apr 29 '22 10:04 kage212

@Keukhan Hello, did you try?

kage212 avatar May 04 '22 10:05 kage212

@kage212

I'm too busy with other things these days. However, I do not forget this issue. I will find a solution soon and contact you. Thanks

Keukhan avatar May 04 '22 10:05 Keukhan

@kage212

In this case, it would be more helpful if you share the configuration information of nginx-rtmp, which was recorded with nginx-rtmp without any problems.

getroot avatar May 04 '22 10:05 getroot

My conf is this:

rtmp { server { listen 1935; chunk_size 4096; application ${STREAM} { live on; record all; record_path /tmp/rec; record_unique on; push rtmp://${OME_HOST}:${OME_PORT}/${STREAM}/; } } }

In this case nginx-rtmp records the stream (in .flv) and the stream its pushed to OME, I tried with different sources without any problems, all was recorded.

kage212 avatar May 04 '22 15:05 kage212

Also happen with WebRtc with low connections

kage212 avatar Jun 01 '22 08:06 kage212

OME uses the incoming timestamp as-is. The browser's WebRTC player will also consider this to be an invalid frame and drop it. I'm not yet sure if it is possible and necessary to correct the wrong timestamp in OME. I'll think about it.

Now, OME works normally only when a normal stream comes in.

getroot avatar Jun 01 '22 09:06 getroot

I also have the same problem, registering in this way is not usable because you may find yourself at any moment without registering. With the use of the API it is possible to verify when the recording goes in error and if necessary restart it, but the file recorded up to that moment will be corrupt and operations will have to be carried out to be able to recover it. At the moment I use OME for webrtc streams and ffmpeg for recording the main stream without any problem, but it doesn't seem like the best solution. I also look forward to a solution to this problem.

I am also attaching my log even if it is not needed since the problem is perfectly the same.

[2022-07-06 02:31:35.135] E [AW-HLS0:30034] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f8d08022dc0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 4739179410 >= 4739179410 [2022-07-06 02:31:35.135] E [StreamWorker:30070] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f8d2800ef00] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 98610576 >= 98610576 [2022-07-06 02:31:35.147] E [AW-HLS0:30034] Writer | writer.cpp:721 | [0x55fc27b2e0d0] Could not write the frame: Invalid argument [2022-07-06 02:31:35.147] E [StreamWorker:30070] FileWriter | file_writer.cpp:398 | error = -22

This is the command I use to send the stream to OME

ffmpeg -thread_queue_size 2048 -i 'rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&unicast=true' -f alsa -thread_queue_size 2048 -i hw:1 -ac 2 -acodec aac -vcodec copy -f flv -ar 44100 rtmp://127.0.0.1:1935/app/camera1

This is the output of ffmpeg over time

Input #0, rtsp, from 'rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&unicast=true': Metadata: title : Media Server Duration: N/A, start: 0.040000, bitrate: N/A Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709, progressive), 1280x720, 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp Guessed Channel Layout for Input Stream #1.0 : stereo Input #1, alsa, from 'hw:1': Duration: N/A, start: 1657014837.473599, bitrate: 1536 kb/s Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native)) Press [q] to stop, [?] for help Output #0, flv, to 'rtmp://127.0.0.1:1935/app/camera1': Metadata: title : Media Server encoder : Lavf58.20.100 Stream #0:0: Video: h264 (Baseline) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive), 1280x720, q=2-31, 25 fps, 25 tbr, 1k tbn, 90k tbc Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.35.100 aac [flv @ 0x5635af166d00] Non-monotonous DTS in output stream 0:0; previous: 360, current: 160; changing to 360. This may result in incorrect timestamps in the output file. [flv @ 0x5635af166d00] Non-monotonous DTS in output stream 0:0; previous: 360, current: 200; changing to 360. This may result in incorrect timestamps in the output file. [flv @ 0x5635af166d00] Non-monotonous DTS in output stream 0:0; previous: 360, current: 240; changing to 360. This may result in incorrect timestamps in the output file. [flv @ 0x5635af166d00] Non-monotonous DTS in output stream 0:0; previous: 360, current: 280; changing to 360. This may result in incorrect timestamps in the output file. [flv @ 0x5635af166d00] Non-monotonous DTS in output stream 0:0; previous: 360, current: 320; changing to 360. This may result in incorrect timestamps in the output file. [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.6kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 5 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.5kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 4 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.4kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 3 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.3kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 3 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.4kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 5 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.4kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 5 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetate=2238.5kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 4 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetrate=2237.7kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 2 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packet [rtsp @ 0x5635af0f4940] RTP: missed 3 packets [rtsp @ 0x5635af0f4940] max delay reached. need to consume packetrate=2237.3kbits/s speed= 1x [rtsp @ 0x5635af0f4940] RTP: missed 3 packets [flv @ 0x5635af166d00] Failed to update header with correct duration.=2236.7kbits/s speed= 1x [flv @ 0x5635af166d00] Failed to update header with correct filesize. frame=1953692 fps= 25 q=-1.0 Lsize=21350406kB time=21:43:17.20 bitrate=2236.7kbits/s speed= 1x video:20007471kB audio:1248864kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.442554%

cl84 avatar Jul 06 '22 09:07 cl84

@kage212 @cl84

Fixed the problem that recording or packetizing failed due to non-monotonous dts. In fact, I did not solve the fundamental problem, but took temporary measures to avoid it. I tested it and the results are satisfactory.

Please test it on the latest version. https://github.com/AirenSoft/OvenMediaEngine/compare/c8760272e02c...06c7bb4e61ce

Thanks.

Keukhan avatar Jul 21 '22 11:07 Keukhan

@kage212 @cl84

Fixed the problem that recording or packetizing failed due to non-monotonous dts. In fact, I did not solve the fundamental problem, but took temporary measures to avoid it. I tested it and the results are satisfactory.

Please test it on the latest version. c876027...06c7bb4

Thanks.

I have installed version 0.14.4 and now in the logs it no longer gives any errors but the recording still goes into error

cl84 avatar Jul 22 '22 09:07 cl84

@cl84

Please share the full log. Let me find out the cause.

Keukhan avatar Jul 22 '22 09:07 Keukhan

I hadn't seen the logs well, it actually gave me these errors:

[2022-07-22 10:59:29.784] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.784] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(0), pts( 249625) dts( 249625) dur( -1/ -1), size(8642) [2022-07-22 10:59:29.785] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.785] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.785] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.785] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(0), pts( 249625) dts( 249625) dur( -1/ -1), size(8469) [2022-07-22 10:59:29.785] E [StreamWorker:11501] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e34028f40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 2968272 >= 2968272 [2022-07-22 10:59:29.785] E [StreamWorker:11501] FileWriter | file_writer.cpp:398 | error = -22 [2022-07-22 10:59:29.789] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.789] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.790] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.790] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(1), pts( 249625) dts( 249625) dur( -1/ -1), size(8542) [2022-07-22 10:59:29.791] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.791] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.793] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.793] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(1), pts( 249625) dts( 249625) dur( -1/ -1), size(8752) [2022-07-22 10:59:29.794] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.794] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.795] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.795] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(1), pts( 249625) dts( 249625) dur( -1/ -1), size(13061) [2022-07-22 10:59:29.796] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.796] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.800] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.800] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(1), pts( 249625) dts( 249625) dur( -1/ -1), size(9495) [2022-07-22 10:59:29.801] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.801] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.803] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.803] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(0), pts( 249625) dts( 249625) dur( -1/ -1), size(8676) [2022-07-22 10:59:29.804] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.804] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument [2022-07-22 10:59:29.805] W [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1091 | [#default#app/camera1] found invalid duration of packet. We need to find the cause of the incorrect Duration. [2022-07-22 10:59:29.805] I [OutboundWorker:11005] MediaRouter | mediarouter_stream.cpp:1164 | [#default#app/camera1] track_id( 0), type( 3), fmt( 1), flags(0), pts( 249625) dts( 249625) dur( -1/ -1), size(8360) [2022-07-22 10:59:29.808] E [AW-HLS0:11007] FFmpeg | third_parties.cpp:111 | [AVFormatContext: 0x7f9e382eb0c0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 22466160 >= 22466160 [2022-07-22 10:59:29.808] E [AW-HLS0:11007] Writer | writer.cpp:721 | [0x7f9e1c016b90] Could not write the frame: Invalid argument

cl84 avatar Jul 22 '22 09:07 cl84

@cl84

Can you dump the #default#app/camera1 stream and share the file? This is difficult to solve with log analysis.

Keukhan avatar Jul 22 '22 09:07 Keukhan

do you mean the file I recorded and it went into error?

cl84 avatar Jul 22 '22 10:07 cl84

however this is the output of ffmpeg when the registration failed:

[flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 248922; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 248962; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249002; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249042; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249082; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249122; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249162; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249202; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249242; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249282; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249322; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249362; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249402; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249442; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249482; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249522; changing to 249601. This may result in incorrect timestamps in the output file. [flv @ 0x5555a71fa200] Non-monotonous DTS in output stream 0:0; previous: 249601, current: 249562; changing to 249601. This may result in incorrect timestamps in the output file.

this instead is the command I use to create the stream to ffmpeg:

ffmpeg -thread_queue_size 2048 -i 'rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&unicast=true' -f alsa -thread_queue_size 2048 -i hw:1 -ac 2 -acodec aac -vcodec copy -f flv -ar 44100 rtmp://127.0.0.1:1935/app/camera1

cl84 avatar Jul 22 '22 10:07 cl84

It means to dump the camera source stream.

ffmpeg -thread_queue_size 2048 -i 'rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&unicast=true' -f alsa -thread_queue_size 2048 -i hw:1 -acodec aac -vcodec copy dump_filename.ts

I will wait for your reply

Keukhan avatar Jul 22 '22 10:07 Keukhan

dump_filename.zip

cl84 avatar Jul 22 '22 10:07 cl84

@cl84

I was surprised that the reply was so quick. I will find a solution and reply to you. give me time Thanks

Keukhan avatar Jul 22 '22 10:07 Keukhan

Ok

However this is the full ffmpeg output for the submitted dump:

Input #0, rtsp, from 'rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&unicast=true': Metadata: title : Media Server Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709, progressive), 1280x720, 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp Guessed Channel Layout for Input Stream #1.0 : stereo Input #1, alsa, from 'hw:1': Duration: N/A, start: 1658484581.651615, bitrate: 1536 kb/s Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native)) Press [q] to stop, [?] for help Output #0, mpegts, to 'dump_filename.ts': Metadata: title : Media Server encoder : Lavf58.20.100 Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709, progressive), 1280x720, q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.35.100 aac [mpegts @ 0x5638351ecac0] Non-monotonous DTS in output stream 0:0; previous: 25200, current: 7200; changing to 25201. This may result in incorrect timestamps in the output file. [mpegts @ 0x5638351ecac0] Non-monotonous DTS in output stream 0:0; previous: 25201, current: 10800; changing to 25202. This may result in incorrect timestamps in the output file. [mpegts @ 0x5638351ecac0] Non-monotonous DTS in output stream 0:0; previous: 25202, current: 14400; changing to 25203. This may result in incorrect timestamps in the output file. [mpegts @ 0x5638351ecac0] Non-monotonous DTS in output stream 0:0; previous: 25203, current: 18000; changing to 25204. This may result in incorrect timestamps in the output file. [mpegts @ 0x5638351ecac0] Non-monotonous DTS in output stream 0:0; previous: 25204, current: 21600; changing to 25205. This may result in incorrect timestamps in the output file. [mpegts @ 0x5638351ecac0] Non-monotonous DTS in output stream 0:0; previous: 25205, current: 25200; changing to 25206. This may result in incorrect timestamps in the output file. frame= 607 fps= 25 q=-1.0 Lsize= 7311kB time=00:00:24.34 bitrate=2460.7kbits/s speed=0.998x video:6295kB audio:393kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.318445% [aac @ 0x5638352fd100] Qavg: 25282.062 Exiting normally, received signal 2.

cl84 avatar Jul 22 '22 10:07 cl84

ok i will take note of this.

Keukhan avatar Jul 22 '22 10:07 Keukhan

@cl84

A problem occurred due to out-of-order DTS in a specific packet. I tried improving the DTS correction. As a result of my test, playback and recording work fine. Test it with the latest version. I look forward to your reply with good results.

Thanks.

https://github.com/AirenSoft/OvenMediaEngine/commit/590bf1e97fd718d14fcb77327bc039b18d2cbe93

Keukhan avatar Jul 23 '22 06:07 Keukhan

@cl84

A problem occurred due to out-of-order DTS in a specific packet. I tried improving the DTS correction. As a result of my test, playback and recording work fine. Test it with the latest version. I look forward to your reply with good results.

Thanks.

590bf1e

I have been recording continuously since 23 at the moment it has not given any errors during the recording even if from the logs it has detected some DTS errors.

As far as I am concerned, I can consider the problem solved.

Thank you

Instead I opened another bug a few days ago #818 and noticed that this has been showing up since pub namespace was added in the api.

Could you kindly check?

Thank you

cl84 avatar Jul 25 '22 07:07 cl84

@cl84

Let's close this issue. discuss it in thread https://github.com/AirenSoft/OvenMediaEngine/issues/818 :)

Thanks

Keukhan avatar Jul 27 '22 10:07 Keukhan

There are no more registration problems. Everything is OK.

For me it can be closed

cl84 avatar Jul 27 '22 15:07 cl84

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 26 '22 07:09 stale[bot]