emarsden / dash-mpd-cli

Download media content from a DASH-MPEG or DASH-WebM MPD manifest
https://emarsden.github.io/dash-mpd-cli/
MIT License
302 stars 33 forks source link

Ability to handle http errors: retrying, logging response #64

Closed rappongy closed 4 months ago

rappongy commented 6 months ago

Hello!

Thank you for your work. I'm downloading video course for my non-programmer-friend :) And your app is helping me a lot.

But I'm facing a smal problem with HTTP request error with some audio or video fragments. I'm not entirely sure what causes them. And I'm afraid fragments are missed because of them. So, the video and audio are out of sync.

I have encreased max-error-count a lot, so video can loaded, but it's not best workaround.

So my questions are:

  1. Are video-audio are desynced after HTTP errors?
  2. Is it possible to retry an HTTP request in case of an error?
  3. How can I see details of errored response?

My logs:

>dash-mpd-cli-windows.exe -v -v -v -o s01_06.mp4 --quality intermediate --muxer-preference mp4:vlc --max-error-count 1000 https://.../master.mpd
[0s] [>-------------------------------------------------] Fetching DASH manifest      
23:30:12  INFO Fetching the DASH manifest
23:30:13  INFO DASH manifest has 1 period
23:30:13  INFO Streams in period #1, duration 3612.067s:
23:30:13  INFO   audio mp4a.40.2         |   127 Kbps |    lang=? label=Unknown
23:30:13  INFO   video avc1.4D401F       |  2194 Kbps |  1280x720
23:30:13  INFO   video avc1.640028       |  3113 Kbps | 1920x1080
23:30:13  INFO   video avc1.4D401E       |   803 Kbps |   640x360
23:30:13  INFO   video avc1.4D401F       |  1227 Kbps |   852x480
23:30:13  INFO Preparing download for period #1
23:30:13  INFO   Using Representation>SegmentList addressing mode for audio representation
23:30:13  INFO   Using Representation>SegmentList addressing mode for video representation
23:30:13  INFO   Audio stream selected: bw=127 Kbps lang=? codec=mp4a.40.2
23:30:13  INFO   Video stream selected: bw=2194 Kbps resolution=1280x720 codec=avc1.4D401F
23:30:14  INFO Period #1: fetching 905 audio, 905 video and 0 subtitle segments

...

23:42:13 ERROR error sending request for url (https://...) fetching video segment https://...

...

23:43:30  INFO   Wrote 287.3MB to DASH video file (0.6 MB/s)
[13m] [#################################################>] Muxing audio and video    
23:43:30  INFO   Muxing audio and video streams
23:43:30  INFO   Muxer preference for mp4 is ["vlc"]
23:43:30  INFO   Trying muxer vlc
23:43:35  INFO   Muxing with vlc subprocess succeeded
23:43:35  INFO   Wrote 55.1MB to media file
[13m] [##################################################] Done
emarsden commented 6 months ago

dash-mpd-cli should be retrying network requests that suffer a "transient" failure. Transient errors include timeouts and specific HTTP error codes like REQUEST_TIMEOUT, TOO_MANY_REQUESTS, SERVICE_UNAVAILABLE, GATEWAY_TIMEOUT. These errors do not count towards the max-error-count.

Presumably your errors are not being recognized as transient. I can't tell you anything more from the log you have. Are you using the latest release? The latest version should report more information concerning network errors, which might be helpful.

I don't know enough to give a full answer to your question on desyncing. Fragments should contain timestamps, and the muxer should be able to resync. You might want to try other muxers than VLC, like ffmpeg our MP4Box, which might give better results.

rappongy commented 5 months ago

Thanks for response.

I'm using dash-mpd-cli 0.2.16. My errors count within max-error-count. What about extended http error logs?

And I will try other codecs, nice idea.

Right now each download attempt ends with different quality results, sometime only audio available, sometimes - only video. Depends on which fragments was missed.

rappongy commented 5 months ago

And also it will be nice if you will add option to retry errored requests :)

rappongy commented 5 months ago

Looks like I've found best options for me :) I added sleep-requests=1 and errors stopped appearing.

Can you add ability to use float values for that options? Like 0.5. error: invalid value '0.5' for '--sleep-requests <SECONDS>': invalid digit found in string

rappongy commented 5 months ago

Also I've figured out that mixer-preferences=mp4:ffmpeg handles desync problem. I have tried avi:ffmpeg, mp4:vlc, mpd:mp4box, they didn't help

rappongy commented 5 months ago

In the end I think features that I've mentioned are useful:

emarsden commented 5 months ago

Understood, thanks for the feedback. I should be able to implement these in future versions.

emarsden commented 5 months ago

Please try the latest release, v0.2.17, which should do segment retries and more detailed error logging.