yocker 1546 Posted May 14 Posted May 14 (edited) About time this plugin gets it's own page instead just being mentioned in the EmbyCredits thread. This is a plugin for editing time marks metadata in Emby heavily inspired by ChapterAPI (with permission) and with idea from @GrimReaper While similar to ChapterAPI this plugin has some extra filters, a video preview with fint tuning option and other things to help editing time marks in videos. Download at: Releases · yocksers/TimeMarkEdit Please report any bugs you may find. As always, while i have tested and use the plugin my self it is USE AT YOUR OWN RISK! Edited Friday at 06:50 PM by yocker 4 1
rbjtech 5355 Posted May 14 Posted May 14 Nice - have you thought about ever writing this data directly to the MKV, MP4 or chapters.xml file to make it portable ? One of the key problems with spending a lot of time perfecting chapters/intro's etc is to then lose them all on a metadata refresh - yes you can have db backup's etc, but simply saving them into the MKV chapter table is so much more permanent - and an emby library rebuild will simply then import them .. Yes you need to use an external library to do this - but it's instant as you just write to the MKV header as I'm sure you are aware. Not 100% sure for other containers. This is we did for the MediaInfo Plugin (but not for chapters).
crusher11 1194 Posted Thursday at 07:20 PM Posted Thursday at 07:20 PM Writing it into the MKV file means markers that should be invisible, and purely used as triggers, end up displaying in the UI though. I do have a bunch of markers I lost when I renamed all my files to include aspect ratio information in the filenames; I had them backed up to the NFOs with Cheesegeezer's plugin but can't restore them because that plugin no longer works. But a functionality like that makes more sense to me than writing them into the MKV directly.
Aleas 89 Posted Thursday at 07:51 PM Posted Thursday at 07:51 PM (edited) 2 hours ago, rbjtech said: Nice - have you thought about ever writing this data directly to the MKV, MP4 or chapters.xml file to make it portable ? One of the key problems with spending a lot of time perfecting chapters/intro's etc is to then lose them all on a metadata refresh - yes you can have db backup's etc, but simply saving them into the MKV chapter table is so much more permanent - and an emby library rebuild will simply then import them .. Yes you need to use an external library to do this - but it's instant as you just write to the MKV header as I'm sure you are aware. Not 100% sure for other containers. This is we did for the MediaInfo Plugin (but not for chapters). One thing I do, is whenever Sonarr or Radarr imports media, I strip all chapters and make new ones every 5min. Here's the script it's pretty simple. you just go into those 2 apps and under settings -> Connect create a custom script to execute on file import and upgrade. After that I let Emby and it's plugins do the intro's, credits, etc markers. But this plugin so far is great for fine tuning certain things. But yes it would be nice if we could have an option to save directly to the mkv. (Note: this script was written for the binhex docker containers which run under arch linux.) #!/bin/bash # ========================================== # 1. Dependency Check # ========================================== # Check if mkvpropedit exists. If not, install the package. # This ensures it survives Docker container updates/rebuilds if ! command -v mkvpropedit &> /dev/null; then echo "mkvpropedit not found. Installing mkvtoolnix..." pacman -S mkvtoolnix-cli --noconfirm > /dev/null 2>&1 fi # ========================================== # 2. File Validation # ========================================== # Grab the file path from Sonarr/Radarr, OR fallback to $1 for manual testing FILE_PATH="${sonarr_episodefile_path:-${radarr_moviefile_path:-$1}}" # Check if the file exists and is an MKV if [[ ! -f "$FILE_PATH" || "$FILE_PATH" != *.mkv ]]; then echo "No valid MKV file found at: $FILE_PATH" exit 0 fi # ========================================== # 3. Chapter Generation & Injection # ========================================== # Get the total duration of the video in seconds using ffprobe DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$FILE_PATH") # Round down duration to the nearest whole integer DURATION=${DURATION%.*} # If duration couldn't be extracted, safely exit if [[ -z "$DURATION" ]]; then echo "Could not determine video duration. Exiting." exit 1 fi # Create a temporary text file to hold the new OGM-formatted chapter data CHAPTER_FILE=$(mktemp) # Loop through the duration in 300-second (5 minute) intervals CURRENT_SEC=0 CHAPTER_NUM=1 while [ $CURRENT_SEC -lt $DURATION ]; do # Format current seconds into HH:MM:SS.000 HOURS=$(printf "%02d" $((CURRENT_SEC / 3600))) MINS=$(printf "%02d" $(((CURRENT_SEC % 3600) / 60))) SECS=$(printf "%02d" $((CURRENT_SEC % 60))) # Zero-pad the chapter ID (e.g., 01, 02, 03) CHAP_ID=$(printf "%02d" $CHAPTER_NUM) # Write the timestamps and names to the temporary file echo "CHAPTER${CHAP_ID}=${HOURS}:${MINS}:${SECS}.000" >> "$CHAPTER_FILE" echo "CHAPTER${CHAP_ID}NAME=Chapter ${CHAPTER_NUM}" >> "$CHAPTER_FILE" # Increment by 5 minutes (300 seconds) and increase chapter counter CURRENT_SEC=$((CURRENT_SEC + 300)) CHAPTER_NUM=$((CHAPTER_NUM + 1)) done # Inject the newly generated chapters into the MKV file # (NOTE: This automatically overwrites any existing chapters) mkvpropedit "$FILE_PATH" --chapters "$CHAPTER_FILE" # Clean up the temporary file so it doesn't leave trash around rm "$CHAPTER_FILE" echo "Successfully replaced chapters with 5-minute intervals for $FILE_PATH" Edited Thursday at 08:47 PM by Aleas 1
yocker 1546 Posted Thursday at 11:09 PM Author Posted Thursday at 11:09 PM 4 hours ago, rbjtech said: Nice - have you thought about ever writing this data directly to the MKV, MP4 or chapters.xml file to make it portable ? One of the key problems with spending a lot of time perfecting chapters/intro's etc is to then lose them all on a metadata refresh - yes you can have db backup's etc, but simply saving them into the MKV chapter table is so much more permanent - and an emby library rebuild will simply then import them .. Yes you need to use an external library to do this - but it's instant as you just write to the MKV header as I'm sure you are aware. Not 100% sure for other containers. This is we did for the MediaInfo Plugin (but not for chapters). It's just meant as a slightly enhanced ChapterAPI that @GrimReapercame up with the idea for. Not dismissing your idea but i don't really feel like making it into more, as there are a lot of external programs for editing the metadata of the mkv them self. 1 1
rbjtech 5355 Posted Friday at 07:47 AM Posted Friday at 07:47 AM 12 hours ago, crusher11 said: Writing it into the MKV file means markers that should be invisible, and purely used as triggers, end up displaying in the UI though. I do have a bunch of markers I lost when I renamed all my files to include aspect ratio information in the filenames; I had them backed up to the NFOs with Cheesegeezer's plugin but can't restore them because that plugin no longer works. But a functionality like that makes more sense to me than writing them into the MKV directly. Done properly (as in the original Introskip Plugin) the chapters should be re-ordered so they do not necessarily need to be triggers in the first place. ie you 'insert' an 'Intro' or 'Credits' chapter into the existing chapters by realigning (retiming) the existing chapters surrounding the inserted ones. ie if your chapters were at 05:00 and 10:00 etc and your intro was at 04:50 then you simply change chapter 1 to be 04:50 add an Intro chapter at 05:00 That way, they are available for any other application that wants to use them, not just emby. In the MKV container, different types of chapters are supported (ie hidden etc), but ffmpeg/emby sadly do not support this. Open Source of Metadata updates is the way to go here - Proprietary/Closed Emby only database Metadata changes are never a good solution. Years of trying has taught us that. Anyway - @yockerwon't be adding and I am not supporting Cheeze's Plugin that did this as I don't have the source, so I guess we can conclude this suggestion anyway ...
rbjtech 5355 Posted Friday at 07:52 AM Posted Friday at 07:52 AM 11 hours ago, Aleas said: One thing I do, is whenever Sonarr or Radarr imports media, I strip all chapters and make new ones every 5min. Here's the script it's pretty simple. you just go into those 2 apps and under settings -> Connect create a custom script to execute on file import and upgrade. After that I let Emby and it's plugins do the intro's, credits, etc markers. But this plugin so far is great for fine tuning certain things. But yes it would be nice if we could have an option to save directly to the mkv. (Note: this script was written for the binhex docker containers which run under arch linux.) Yes, been doing this for many years .. the consistency of chapters in MKV's has always been poor .. 1
crusher11 1194 Posted Friday at 07:30 PM Posted Friday at 07:30 PM All my existing chapters are either the existing chapters from the disc release of a movie/TV show, or they're chapters I've inserted at the start of each quarter of NBA games and the like. I definitely have no desire to replace them.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now