Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recorded video is slower 3x-10x than streaming one #3461

Closed
1 of 13 tasks
onorua opened this issue Jun 12, 2024 · 2 comments
Closed
1 of 13 tasks

Recorded video is slower 3x-10x than streaming one #3461

onorua opened this issue Jun 12, 2024 · 2 comments
Labels
question Further information is requested

Comments

@onorua
Copy link

onorua commented Jun 12, 2024

Which version are you using?

v1.8.2-27-g42724987

Which operating system are you using?

  • Linux amd64 standard
  • Linux amd64 Docker
  • Linux arm64 standard
  • Linux arm64 Docker
  • Linux arm7 standard
  • Linux arm7 Docker
  • Linux arm6 standard
  • Linux arm6 Docker
  • Windows amd64 standard
  • Windows amd64 Docker (WSL backend)
  • macOS amd64 standard
  • macOS amd64 Docker
  • Other (please describe)

Describe the issue

config for recording:

  # Record streams to disk.
  record: yes
  # Path of recording segments.
  # Extension is added automatically.
  # Available variables are %path (path name), %Y %m %d %H %M %S %f %s (time in strftime format)
  recordPath: ./recordings/%path/%Y-%m-%d_%H-%M-%S-%f
  # Format of recorded segments.
  # Available formats are "fmp4" (fragmented MP4) and "mpegts" (MPEG-TS).
  recordFormat: fmp4
  # fMP4 segments are concatenation of small MP4 files (parts), each with this duration.
  # MPEG-TS segments are concatenation of 188-bytes packets, flushed to disk with this period.
  # When a system failure occurs, the last part gets lost.
  # Therefore, the part duration is equal to the RPO (recovery point objective).
  recordPartDuration: 1s
  # Minimum duration of each segment.
  recordSegmentDuration: 10m
  # Delete segments after this timespan.
  # Set to 0s to disable automatic deletion.
  recordDeleteAfter: 0s

According to the recordSegmentDuration: 10m new file should be created every 10 minutes. In fact new file created every ~3 minutes:

-rw-r--r-- 1 root root  37380737 Jun 12 18:56 2024-06-12_18-53-09-669902.mp4
-rw-r--r-- 1 root root  37553051 Jun 12 18:59 2024-06-12_18-56-29-339693.mp4
-rw-r--r-- 1 root root  37385706 Jun 12 19:03 2024-06-12_18-59-48-849732.mp4
-rw-r--r-- 1 root root  37396771 Jun 12 19:06 2024-06-12_19-03-08-000495.mp4
-rw-r--r-- 1 root root  37531342 Jun 12 19:09 2024-06-12_19-06-28-429795.mp4
-rw-r--r-- 1 root root  37340709 Jun 12 19:13 2024-06-12_19-09-46-560372.mp4
-rw-r--r-- 1 root root  37528050 Jun 12 19:16 2024-06-12_19-13-04-710220.mp4
-rw-r--r-- 1 root root  37437132 Jun 12 19:19 2024-06-12_19-16-22-910126.mp4
-rw-r--r-- 1 root root  37544076 Jun 12 19:22 2024-06-12_19-19-40-519848.mp4
-rw-r--r-- 1 root root  37358610 Jun 12 19:26 2024-06-12_19-22-58-720533.mp4

During realtime stream that I can see from WebRTC client - the video showed in normal speed. But the recorded one is like 3-4 times slower than it should be. In fact, the recorded file that created every 3 minutes, in VLC has 10 minutes length.

Describe how to replicate the issue

  1. enable recording
  2. start the server
  3. gst-launch-1.0 -v videotestsrc ! clockoverlay ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=ultrafast key-int-max=30 ! mpegtsmux alignment=1 ! srtsink wait-for-connection=false sync=false enable-last-sample=true "uri=srt://{serverIP}:8890?mode=caller&streamid=publish:room502&udp-mss=1200"
  4. check WebRTC - it should be fine.
  5. Check recorded file with VLC or any MPEG4 player - it shows 3-10x slower than original video.

Did you attach the server logs?

no

Did you attach a network dump?

no, but I have attached video file with configuration to write segment every minute.

2024-06-12_19-32-34-573750.mp4
@onorua onorua changed the title Recorded video is slower than 3x Recorded video is slower than streaming one 3x-10x Jun 12, 2024
@onorua onorua changed the title Recorded video is slower than streaming one 3x-10x Recorded video is slower 3x-10x than streaming one Jun 12, 2024
@aler9
Copy link
Member

aler9 commented Jun 12, 2024

Hello, thanks for providing detailed instructions on how to replicate the issue, however, this happens because you set the sync flag to false:

gst-launch-1.0 -v videotestsrc ! clockoverlay !  videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=ultrafast key-int-max=30  ! mpegtsmux alignment=1  ! srtsink wait-for-connection=false sync=false enable-last-sample=true  "uri=srt://{serverIP}:8890?mode=caller&streamid=publish:room502&udp-mss=1200"

With sync=false, video frames are not sent in real time, but as soon as they are generated, and since the generation speed on your machine is greater than the clock time, you are sending 10 minutes of video in 3 minutes, resulting in 10 minutes-files generated every 3 minutes, as expected.

We never supported streaming non-realtime video, even though there are some clients that allow it.

Is there something i'm missing here?

@aler9 aler9 added the question Further information is requested label Jun 12, 2024
@onorua
Copy link
Author

onorua commented Jun 13, 2024

Thank you, you are right, I've added is-live=1 to my videotestsrc and it is working as expected now. We are considering mediamtx for our realtime event.
The sync=false option introduced by me to avoid client side delays during comparison of media servers. Hence I needed to have "full speed". Obviously I was wrong :)

@onorua onorua closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants