ihabunek / twitch-dl

CLI tool for downloading videos from Twitch.
GNU General Public License v3.0
664 stars 83 forks source link

Downloaded video length is wrong; not the same as real video on twitch #122 #149

Closed asdxasfaxafx closed 2 months ago

asdxasfaxafx commented 8 months ago

When I download a video, the length of my downloaded video is different than the video on the internet.

For example: twitch-dl download https://www.twitch.tv/videos/2089705076

gives me a time that changes even based on the quality I choose to download it at, but this time is never accurate to the video's real length. This problem seems to be happening with videos and not clips... The higher I choose the quality the longer my output video is, the lower the quality the shorter it is. That time ranges from being significantly shorter than the real video or a bit longer than the real video.

I need these times to be spot on to the real video due to the project I am trying to make. Any ideas? Or is this a bug for twitch-dl?

Code: twitch-dl download 2089705076 -f mp4 -q source -s 01:23:00 -e 01:26:00 size= 192221kB time=00:03:12.57 bitrate=8176.7kbits/s speed= 647x

Why is 00:03:12.57 3 minutes, 12 seconds? I asked him to download only 3 minutes.

@ihabunek

ihabunek commented 8 months ago

@asdxasfaxafx twitch-dl rounds the requested start/end to the nearest chunk, so it may be several seconds off. And it will be different depending on selected quality since chunks are not the same length. When Implementing this feature I didn't envision someone needing exact offsets, it was originally planned for downloading chapters where the exact offset is not crucial.

I'll leave this as a feature request. Can't guarantee a timeline though.

For now you could download from start of video until -e 01:26:00 and use ffmpeg to extract the desired chunk. Not optimal I know.

mohasaid commented 6 months ago

Hello @ihabunek is there any planning for this feature? I could work on it if you need help. I would like to do an optimal solution that downloads the clip from a video with the exact offset at the same speed that it does right now.

ihabunek commented 3 months ago

@mohasaid Sorry, I missed your comment. If you're still interested I'd welcome some help. My guess is you need to add options to the ffmpeg commands to chop off the extra length of video from start and end.

ihabunek commented 2 months ago

@asdxasfaxafx @mohasaid I have implemented the changes in 2.8.0.

To test I downloaded a chunk of a video in all available qualities:

$ twitch-dl download 2242294769 --start 00:30:06 --end 00:33:13 -q 1080p60 -o 1080p60.mp4
$ twitch-dl download 2242294769 --start 00:30:06 --end 00:33:13 -q 720p60 -o 720p60.mp4
$ twitch-dl download 2242294769 --start 00:30:06 --end 00:33:13 -q 480p -o 480p.mp4
$ twitch-dl download 2242294769 --start 00:30:06 --end 00:33:13 -q 360p -o 360p.mp4

Then I printed the video length for each chunk using ffprobe:

$ alias video-length="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -sexagesimal"

$ video-length 360p.mp4 
0:03:07.032333

$ video-length 480p.mp4 
0:03:07.032333

$ video-length 720p60.mp4 
0:03:07.014667

$ video-length 1080p60.mp4 
0:03:07.032667

Lengths are not exactly the same but within 33ms of the desired duration of 3:07, so I'm calling it good enough.

If you're still having issues, please reopen and provide steps to reproduce.