Closed pukkandan closed 4 years ago
Good idea, lemme scribble some notes down:
https://ffmpeg.org/ffmpeg-formats.html#Metadata-1
-map_metadata 1 -map_chapters 1 with -i with a file that looks like
;FFMETADATA1
[CHAPTER]
TIMEBASE=1/1
START=0
END=199
title=Good stuff
[CHAPTER]
TIMEBASE=1/1
START=199.38502
END=260.493937
title=Cringe
E.g: ffmpeg -i "in.mp4" -i test.ffm -map_metadata 1 -map_chapters 1 out.mp4
Felt cute might implement it to tomorrow idk
All done! Let me know if you have any issues, new building instructions are in the README, I've also made a release for once: https://github.com/faissaloo/SponSkrub/releases/tag/v2.0.0
There seems to be a few minor issues:
std.file.FileException@std\file.d(1065): jzdgf0-metadata.ffm: The process cannot access the file because it is being used by another process.
https://www.youtube.com/watch?v=hlsdQPykb5Y works as a good example for all these cases. It has an "intermission" section and a sponsor at 0:00 that don't get marked. It also has chapters. (Both YouTube and youtube-dl extracts the timestamps from description to create chapters)
The method to get the different categories is documented in the API
As for temporary files, I am sure I don't have the files open elsewhere since I am able to delete the same files manually. I am using WIndows, if that is any help. Here's the full output:
sponskrub.exe -chpater hlsdQPykb5Y 1.webm 2.webm
Downloading video sponsor data
Marking the shilling...
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
<FFMPEG STUFF>
frame=14550 fps=1467 q=-1.0 Lsize= 10831kB time=00:09:42.04 bitrate= 152.4kbits/s speed=58.7x
video:5029kB audio:5504kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.833732%
std.file.FileException@std\file.d(1065): qgtl5g-metadata.ffm: The process cannot access the file because it is being used by another process.
----------------
0x00000001400575E7 in @trusted int std.file.cenforce!(int).cenforce(int, scope const(char)[], scope const(wchar)*, immutable(char)[], ulong)
0x00000001400457B9 in @trusted void std.file.removeImpl(scope const(char)[], scope const(wchar)*)
0x0000000140029616 in std.file.remove!string.remove at D:\D_Lang\dmd2\windows\bin64\..\..\src\phobos\std\file.d(1032)
0x000000014002875F in ffwrap.add_ffmpeg_metadata at D:\SponSkrub-master\src\sponskrub\ffwrap.d(44)
0x0000000140037340 in D main at D:\SponSkrub-master\src\sponskrub\sponskrub.d(107)
0x000000014005EF73 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll().__lambda1()
0x000000014005EDFC in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate())
0x000000014005EEDB in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll()
0x000000014005EDFC in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate())
0x000000014005ED43 in d_run_main2
0x00000001400511B0 in d_run_main
0x0000000140037D72 in sponskrub._d_cmain!().main at D:\D_Lang\dmd2\windows\bin64\..\..\src\druntime\import\core\internal\entrypoint.d(29)
0x000000014012B6BE in mainCRTStartup
0x00007FFF40B06FD4 in BaseThreadInitThunk
0x00007FFF4231CEC1 in RtlUserThreadStart
I've just pushed some changes.
ydl
's arguments have changed so you now have to pass in sponskrub
arguments as its own string. Also what version of youtube-dl are you using and with what options, I don't get chapters on mine? I'm on 2020.09.14
The chapter extractor seems to be broken in the recent versions of youtube-dl. I am using a custom fork with 2020.09.20
merged with this pull request. I should have let you know this sooner, but I assumed the extractor would have been fixed by now in master
considering the solution was proposed over a month ago.
The only switch needed to get the chapters is --add-metadata
I will try out your fixes and let you know.
It still removes the existing chapters in the video. Everything else works now.
On a sidenote, I noticed a couple of typos in the Usage:
part of the help.
-include-nonmusic
is written as -include-music
-dl-args
is written as -ydl-args
Thanks, I've installed that youtube-dl fix locally and I've just implemented and pushed chapter merging. It seems to work fine although it gets weird when the section and an existing chapter overlay exactly. Give it a go and lemme know what you think.
Everything works fine now, Thanks.
I plan to make a few pull requests with some very minor improvements. Have a look at them when you have the time
Could you add the ability to mark the sponsor sections as chapters instead of completely cutting them out of the video?
This would provide a non-destructive method for skipping these sections without worrying about the actual content getting removed due to some mistake in the user-submitted database.