monsieurvideo / get-flash-videos

Download or play videos from various Flash-based video hosting sites, without having to use the Flash player.
Apache License 2.0
240 stars 68 forks source link

FlashVideo::HLSDownloader appends last ts segment 4 or 5 times to Pbs m3u8 playlist #175

Closed pcwalden closed 8 years ago

pcwalden commented 8 years ago

I am trying to get the Site/Pbs.com plugin to use the HLSDownloader and have been largely successful.

However, every mp4 file result from the pbs.com site appears to have the very last ts segment repeated at least 4 times.

I am not that familiar with the m3u8 format and the final ffmpeg assembly process, so I am asking if this a defect in the HLSDownloader?

Here is a sample pbs m3u8 playlist:

http://ga.video.cdn.pbs.org/videos/american-experience/e18374b9-4708-4c33-bc0e-02eb047d5bb3/211414/hd-1080p-mezzanine-16x9/1b2912c5_amex2710-16x9-hls-400-2500k_858.m3u8

karjonas commented 8 years ago

I am guessing it is the last few lines in the m3u8 that are parsed incorrectly

...
#EXTINF:5.87253,
1b2912c5_amex2710-16x9-hls-2500k-01130.ts
#EXTINF:6.77343,
1b2912c5_amex2710-16x9-hls-2500k-01131.ts
#ZEN-TOTAL-DURATION:6708.23438
#ZEN-AVERAGE-BANDWIDTH:2595210
#ZEN-MAXIMUM-BANDWIDTH:6180103
#EXT-X-ENDLIST

The #ZEN line will be incorrectly treated like a segment leading to 3 failed downloads which will add the last segment 3 times at the end. You can try to change HLSDownloader.pm:44 to

    if ($line !~ /#/) {

and see if that works. I have not tested this though. Also, If you add the --debug command you can see exactly what URLs are downloaded.

pcwalden commented 8 years ago

That appears to solve the problem. I'll test it some more and add that change to my next pull request.

Thanks