FriendTeamInc / VodBot

A command line interface VOD and Clip manager for Twitch.
MIT License
14 stars 1 forks source link

Failing to form videos with copyright-related muted segments #51

Closed NotQuiteApex closed 2 years ago

NotQuiteApex commented 2 years ago

The video in question is from Alchana's stream of Ocarina of Time Master Quest. Video may not be available after writing due to Twitch's VOD lifetime policy. https://www.twitch.tv/videos/1545657956

image

An early section of the video got claimed by a supposed copyright holder, marked in the timeline in red, and thus was muted to prevent issue by Twitch automatically. Since VodBot pulls stream data from Twitch's public web player, the muted audio persists into the downloaded VOD.

This caused a very odd issue where VodBot uploaded an incomplete VOD with the sections in red being completely absent in the YouTube upload.

NotQuiteApex commented 2 years ago
C:\Users\Apex\Desktop\Projects-Software\vodbot>vodbot pull vods
* vodbot 1.0.5 (c) 2020-21 Logan "NotQuiteApex" Hickok-Dickson *
Loading config... Loading channel data...
Pulling VOD list: alkana... 1 VODSs
Total VODs to download: 1

Downloading alkana's videos...
VOD Chat `1545657956` (100%); Done, now to write... Done
VOD `1545657956` pt1406/1406, 6.4GB/~6.4GB (100%); at ~75.7MB/s; ~0 sec left      Done, now to ffmpeg join...
[hls @ 0000016817dde880] Failed to open segment 72 of playlist 0trate=3552.9kbits/s speed= 689x    
[hls @ 0000016817dde880] Failed to open segment 73 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 74 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 75 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 76 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 77 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 78 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 79 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 80 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 81 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 82 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 83 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 84 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 85 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 86 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 87 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 88 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 89 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 90 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 91 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 92 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 93 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 94 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 95 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 96 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 97 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 98 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 99 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 100 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 101 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 102 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 103 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 104 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 105 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 106 of playlist 0
[hls @ 0000016817dde880] Failed to open segment 107 of playlist 0
[mpegts @ 0000016817df8040] Packet corrupt (stream = 1, dts = 70378470).
[hls @ 0000016817dde880] Packet corrupt (stream = 1, dts = 70376940).
C:\Users\Apex\.vodbot\temp\1545657956\playlist.m3u8: corrupt input packet in stream 1
frame=821663 fps=31045 q=-1.0 Lsize= 6213105kB time=03:48:17.03 bitrate=3716.0kbits/s speed= 518x    

* All done, goodbye! *

Ran a pull on my local windows machine. Verified that the segments in red are being downloaded but clearly FFMPEG is failing to concat it all together, claiming packet corruption? I have not investigated the segments in question. Perhaps FFMPEG is mistaking a lack of an audio track as corruption when all the other segments have audio tracks?

NotQuiteApex commented 2 years ago

image

Nevermind, it appears that the audio track does, in fact, exist and its just silent the whole time. Not sure why mpegts has issue opening the video when Premiere, VLC, and even Windows Media Player can open and view the video just fine. Definitely out of the scope of VodBot's code, but maybe some special flags need to be added for FFMPEG to work with silent audio?

NotQuiteApex commented 2 years ago

https://github.com/FriendTeamInc/VodBot/blob/3c8b3fafe52371c9cfb532ee4505005ceb82f5ba/vodbot/itd/download.py#L83-L87

Here is VodBot's command that opens FFMPEG to concat all the segments together with the help of the m3u8 file (which is the playlist_path in this case). Nothing explicitly declares that FFMPEG is opening an m3u8 file so it's figuring out what it needs to use (mpegts, in this case) on its own. The path variable is just the output file path, and everything after that is just to make FFMPEG output lightweight info.

NotQuiteApex commented 2 years ago
...
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\70.ts' for reading
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\71.ts' for reading
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\72-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 72 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\73-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 73 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\74-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 74 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\75-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 75 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\76-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 76 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\77-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 77 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\78-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 78 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\79-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 79 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\80-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 80 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\81-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 81 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\82-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 82 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\83-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 83 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\84-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 84 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\85-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 85 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\86-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 86 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\87-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 87 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\88-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 88 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\89-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 89 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\90-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 90 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\91-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 91 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\92-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 92 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\93-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 93 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\94-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 94 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\95-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 95 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\96-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 96 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\97-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 97 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\98-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 98 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\99-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 99 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\100-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 100 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\101-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 101 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\102-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 102 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\103-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 103 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\104-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 104 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\105-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 105 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\106-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 106 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\107-muted.ts' for reading
[hls @ 000001df3e577f00] Failed to open segment 107 of playlist 0
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\108.ts' for reading
[mpegts @ 000001df3e5a8200] Packet corrupt (stream = 1, dts = 70378470).
[hls @ 000001df3e577f00] Packet corrupt (stream = 1, dts = 70376940).
C:\Users\Apex\.vodbot\temp\1545657956\playlist.m3u8: corrupt input packet in stream 1
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\109.ts' for reading712x
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\110.ts' for reading
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\111.ts' for reading
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\112.ts' for reading
[hls @ 000001df3e577f00] Opening 'C:\Users\Apex\.vodbot\temp\1545657956\113.ts' for reading
...

I removed the set of commands from the cmd to show full output. The issue is now clear as day, the muted sections of the VOD are meant to have a suffix of "-muted", which they don't get when downloaded! The culprit is in here:

https://github.com/FriendTeamInc/VodBot/blob/3c8b3fafe52371c9cfb532ee4505005ceb82f5ba/vodbot/itd/worker.py#L123

Here, the targets for downloads are generated, but they are incorrectly labeled as unmuted when their paths are generated. Instead they rely on a loop generating their indices, rather than their actual paths. This should be an easy-enough fix, simply changing from using indices to actually manipulating the URL string to give the appropriate output file name.

NotQuiteApex commented 2 years ago

Minor reminder for myself tomorrow morning to open issues to allow a CLI toggle to switch off temp folder removal and enable FFMPEG full output.

NotQuiteApex commented 2 years ago

This should be fixed now, however I was not able to fully test the changes before the VOD got unmuted by Twitch from the counterclaim Alchana submitted this morning. Will keep an eye on things for the next few months.