[Bug] ffmpeg still running after stoped playing #157

Closed
opened 2026-04-24 22:59:39 +02:00 by adam · 4 comments
Owner

Originally created by @yangkghjh on GitHub (Jan 2, 2022).

# ps -aux | sort -k4nr | head -1
root      9540  5.7 24.1 1964276 1887112 ?     D    02:25  67:37 /usr/bin/ffmpeg -seek_timestamp 1 -f concat -safe 0 -ss 449.4s -noaccurate_seek -i /metadata/streams/str_kh021aipqaeuz0by1p/files.txt -y -loglevel error -map 0:a -c:a copy -f hls -copyts -avoid_negative_ts make_non_negative -max_delay 5000000 -max_muxing_queue_size 2048 -hls_time 6 -hls_segment_type mpegts -start_number 303 -hls_playlist_type vod -hls_list_size 0 -hls_allow_cache 0 -hls_segment_filename /metadata/streams/str_kh021aipqaeuz0by1p/output-%d.ts /metadata/streams/str_kh021aipqaeuz0by1p/final-output.m3u8
Originally created by @yangkghjh on GitHub (Jan 2, 2022). ``` # ps -aux | sort -k4nr | head -1 root 9540 5.7 24.1 1964276 1887112 ? D 02:25 67:37 /usr/bin/ffmpeg -seek_timestamp 1 -f concat -safe 0 -ss 449.4s -noaccurate_seek -i /metadata/streams/str_kh021aipqaeuz0by1p/files.txt -y -loglevel error -map 0:a -c:a copy -f hls -copyts -avoid_negative_ts make_non_negative -max_delay 5000000 -max_muxing_queue_size 2048 -hls_time 6 -hls_segment_type mpegts -start_number 303 -hls_playlist_type vod -hls_list_size 0 -hls_allow_cache 0 -hls_segment_filename /metadata/streams/str_kh021aipqaeuz0by1p/output-%d.ts /metadata/streams/str_kh021aipqaeuz0by1p/final-output.m3u8 ```
adam closed this issue 2026-04-24 22:59:40 +02:00
Author
Owner

@advplyr commented on GitHub (Jan 2, 2022):

What do you mean after you stopped playing?
Did you just press pause? Close the browser tab?

@advplyr commented on GitHub (Jan 2, 2022): What do you mean after you stopped playing? Did you just press pause? Close the browser tab?
Author
Owner

@yangkghjh commented on GitHub (Jan 3, 2022):

I just press pause and the tab in background.

@yangkghjh commented on GitHub (Jan 3, 2022): I just press pause and the tab in background.
Author
Owner

@advplyr commented on GitHub (Jan 3, 2022):

I'm sure there are more optimal ways to handle this, but this is how it works right now:

When you open a stream for the first time the FFmpeg command transcodes the audiobook to HLS (stored in /metadata/streams/).
That transcode will run to completion and takes anywhere from a few seconds to a few minutes.

The transcode is canceled only if you open a new audiobook stream OR you close the stream via the X on the audio player.

When opening a new stream or closing a current stream the HLS transcode is deleted.

This means you don't need to transcode every time you press play, only when you first start the stream.
Hope that made sense.

@advplyr commented on GitHub (Jan 3, 2022): I'm sure there are more optimal ways to handle this, but this is how it works right now: When you open a stream for the first time the FFmpeg command transcodes the audiobook to HLS (stored in `/metadata/streams/`). That transcode will run to completion and takes anywhere from a few seconds to a few minutes. The transcode is canceled only if you open a new audiobook stream OR you close the stream via the X on the audio player. When opening a new stream or closing a current stream the HLS transcode is deleted. This means you don't need to transcode every time you press play, only when you first start the stream. Hope that made sense.
Author
Owner

@yangkghjh commented on GitHub (Jan 3, 2022):

Thank you for your reply.

I think the way to transcode it at first time is fine.

The problem is that my device doesn't have enough memory to transcode. Ffmpeg used all memory and swap. Then transcoding task becomes so low and will never stop.

I will try to add some resource limit on container to avoid swap problem.

@yangkghjh commented on GitHub (Jan 3, 2022): Thank you for your reply. I think the way to transcode it at first time is fine. The problem is that my device doesn't have enough memory to transcode. Ffmpeg used all memory and swap. Then transcoding task becomes so low and will never stop. I will try to add some resource limit on container to avoid swap problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#157