faissaloo / SponSkrub

Strip advertisements from downloaded YouTube videos
GNU General Public License v3.0
178 stars 7 forks source link

--keep-metadata sometimes causes 'Chapter end time X before start Y' #27

Open faissaloo opened 3 years ago

faissaloo commented 3 years ago

I downloaded via youtube-dl with keep metadata and since it ends up trying to cut the chapters on the video down we end up with this mess, might be a good opportunity to make cuts more precise: [ffmetadata @ 0x55912b9f8c00] Chapter end time 69 before start 70

[{"category":"intro","segment":[0,8.433314],"UUID":"b4140d233b26ec9fe0eaed7235ffb595fbc00aeeaa17b209ff0f4c2616d4d3bc"},{"category":"sponsor","segment":[201,238],"UUID":"5f68d51c6b713fdf25c551abc3ebcccfa45ec99ef885f5036329ea5ef678712c"}]

chapters on the video as of writing are:

{
    "chapters": [
        {
            "id": 0,
            "time_base": "1/1000",
            "start": 0,
            "start_time": "0.000000",
            "end": 8000,
            "end_time": "8.000000",
            "tags": {
                "title": "The timeline we're living in"
            }
        },
        {
            "id": 1,
            "time_base": "1/1000",
            "start": 8000,
            "start_time": "8.000000",
            "end": 78000,
            "end_time": "78.000000",
            "tags": {
                "title": "NFTs are taking over"
            }
        },
        {
            "id": 2,
            "time_base": "1/1000",
            "start": 78000,
            "start_time": "78.000000",
            "end": 139000,
            "end_time": "139.000000",
            "tags": {
                "title": "Ethereum phasing out mining"
            }
        },
        {
            "id": 3,
            "time_base": "1/1000",
            "start": 139000,
            "start_time": "139.000000",
            "end": 201000,
            "end_time": "201.000000",
            "tags": {
                "title": "Exchange server exploits"
            }
        },
        {
            "id": 4,
            "time_base": "1/1000",
            "start": 201000,
            "start_time": "201.000000",
            "end": 238000,
            "end_time": "238.000000",
            "tags": {
                "title": "Seasonic"
            }
        },
        {
            "id": 5,
            "time_base": "1/1000",
            "start": 238000,
            "start_time": "238.000000",
            "end": 243000,
            "end_time": "243.000000",
            "tags": {
                "title": "QUICK BITS"
            }
        },
        {
            "id": 6,
            "time_base": "1/1000",
            "start": 243000,
            "start_time": "243.000000",
            "end": 279000,
            "end_time": "279.000000",
            "tags": {
                "title": "RX 5700 XT better than RTX 3090?"
            }
        },
        {
            "id": 7,
            "time_base": "1/1000",
            "start": 279000,
            "start_time": "279.000000",
            "end": 323000,
            "end_time": "323.000000",
            "tags": {
                "title": "Bethesda games exclusivity"
            }
        },
        {
            "id": 8,
            "time_base": "1/1000",
            "start": 323000,
            "start_time": "323.000000",
            "end": 361000,
            "end_time": "361.000000",
            "tags": {
                "title": "Roblox is bigger than EA"
            }
        },
        {
            "id": 9,
            "time_base": "1/1000",
            "start": 361000,
            "start_time": "361.000000",
            "end": 401000,
            "end_time": "401.000000",
            "tags": {
                "title": "WOULD YE LOIKE SOME LEEK SOUP"
            }
        },
        {
            "id": 10,
            "time_base": "1/1000",
            "start": 401000,
            "start_time": "401.000000",
            "end": 439000,
            "end_time": "439.000000",
            "tags": {
                "title": "uNhACkaBLE cHiP"
            }
        }
    ]
}

https://www.youtube.com/watch?v=I8ac9hzagbs There will probably be other instances of this being an issue so just dump 'em here so we have a wide range of samples

pukkandan commented 3 years ago

I thought ffmpeg automatically handles this. I know that it does for -ss -to cutting atleast. Idk if it works for complex filter.

faissaloo commented 3 years ago

Hmm what specifically is ffmpeg handling in those cases? I don't know of any reasonable way that ffmpeg could automatically handle this. Either way it's most definitely a problem on Sponskrub's side, we should be giving ffmpeg good data.

I'm guessing the issue has something to do with the fact that ffmpeg rounds times containing fractional parts and we run into that because Sponsorblock doesn't send back times in PTS format but rather as timestamps with a fractional part.

I've sent a message to the Sponsorblock Discord either way since the lack of PTS formatted times in an issue that would be good to get addressed independently of whether or not it's the specific cause here.

pukkandan commented 3 years ago

oh, nevermind. Seems like I didnt correctly understand the issue. Sorry

faissaloo commented 3 years ago

It's cool :)