Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
This repository was archived by the owner on May 13, 2026. It is now read-only.

Make '--ffmpeg-ss' much quicker. #274

@mhertz

Description

@mhertz

As title, I was annoyed about often needing wait 15+ minutes when needing seek in --tomp4 mode, as the option is added to ffmeg after the '-i -', and also would crash when the seek was over 35m.

I patched the source(in a dep to castnow) to apply that '-ss' option, when given, before the '-i -' input assignment, so starts in few secs instead often 15+ minutes, and doesn't crash. Note '-ss' is still left also after the input assignment here, but doesn't matter I tested, so was lazy and just left as is, when no ill effect regardless. Last, I added a '-copyts' arg because needed to not loose sync with subs when '-ss' before the input.

Here's my patch: ('/usr/lib/node_modules/castnow/node_modules/stream-transcoder/lib/transcoder.js')

--- transcoder-orig.js	2023-10-03 13:32:38.024691518 +0200
+++ transcoder.js	2023-10-03 13:28:21.004696398 +0200
@@ -243,6 +243,7 @@
 		
 		if ('string' == typeof this.source) a = [ '-i', this.source ].concat(a);
 		else a = [ '-i', '-' ].concat(a);
+		if (this.args['ss']) a = [ '-ss', this.args['ss'].pop(), '-copyts' ].concat(a);
 		
 		//console.log('Spawning ffmpeg ' + a.join(' '));
 		

Btw, here's my castnow shell-function for chromecast unsupported video, with subs and optional seek time as extra arg:

castnow2() {
	time="00:00:00"
	[[ "$2" != "" ]] && time="$2"
	sub=$(echo "$1" | sed -e 's/\.[^.]*$//').srt
	file "$sub" | grep UTF >/dev/null || (iconv -f iso-8859-1 -t utf-8 "$sub" -o tmp.srt && mv tmp.srt "$sub")
	[[ -e "$sub" ]] && cp "$sub" ~/video/out.srt
	if [[ ${1: -4} == ".mp4" ]]; then
		qt-faststart "$1" ~/video/out.mp4 >/dev/null
		[[ -e "$sub" ]] && castnow --command down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,up,up,up,up,up --tomp4 --ffmpeg-ss "$time" --ffmpeg-f matroska --ffmpeg-preset ultrafast --ffmpeg-tune fastdecode --ffmpeg-vf "subtitles=/home/martin/video/out.srt:force_style='BorderStyle=3'" --ffmpeg-ac 2 --ffmpeg-af dynaudnorm=f=75:g=11 ~/video/out.mp4
		[[ -e "$sub" ]] || castnow --command down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,up,up,up,up,up --tomp4 --ffmpeg-ss "$time" --ffmpeg-f matroska --ffmpeg-preset ultrafast --ffmpeg-tune fastdecode --ffmpeg-ac 2 --ffmpeg-af dynaudnorm=f=75:g=11 ~/video/out.mp4
		rm ~/video/out.mp4
	else
		[[ -e "$sub" ]] && castnow --command down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,up,up,up,up,up --tomp4 --ffmpeg-ss "$time" --ffmpeg-f matroska --ffmpeg-preset ultrafast --ffmpeg-tune fastdecode --ffmpeg-vf "subtitles=/home/martin/video/out.srt:force_style='BorderStyle=3'" --ffmpeg-ac 2 --ffmpeg-af dynaudnorm=f=75:g=11 $1
		[[ -e "$sub" ]] || castnow --command down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,down,up,up,up,up,up --tomp4 --ffmpeg-ss "$time" --ffmpeg-f matroska --ffmpeg-preset ultrafast --ffmpeg-tune fastdecode --ffmpeg-ac 2 --ffmpeg-af dynaudnorm=f=75:g=11 $1
	fi
	[[ -e "$sub" ]] && rm ~/video/out.srt
}

It has some fixes for videos not otherwise working transcoded(qt-faststart, subs-fix and forcing mkv), and I added a volume normalization filter, and need those down/up commands to not blow out my speakers/ears as don't use my TV remote which is at max.

Then just:
castnow2 <video> [xx:xx:xx]
(For seeking no need pad with 0's or specify hour if under an hour, e.g '32:9' , is '00:32:09' etc. - Srt subs with same name, except extension, auto-loaded)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions