stashapp / stash

An organizer for your porn, written in Go. Documentation: https://docs.stashapp.cc
https://stashapp.cc/
GNU Affero General Public License v3.0
8.93k stars 782 forks source link

[Bug Report] Problems playing scenes. #1070

Closed ghost closed 3 years ago

ghost commented 3 years ago

The problem occurs in Firefox, Chrome, Brave and Safari(ios). The video stick constantly and the player has to reload. But when I call the stream directly via the link "File info" -> "Stream" the videos run without problems. I checked the files with ffmpeg and it found no errors.

File Size 774.82MB Duration 15:54 Dimensions 1920 x 1080 Frame Rate 23.98 frames per second Bit Rate 6.81 megabits per second Video Codec h264 Audio Codec ac3

bnkai commented 3 years ago

Can you try to force stash to transcode the video? From the player select Webm HD or Webm Standard for example. (I am guessing there is an issue when trying to copy the stream and only transcode the audio,, if the file was in a mkv container) EDIT: a log of tthe ffmpeg commands run when playing, obtained by setting the configurattion-> log level to debug in stash would help.

ghost commented 3 years ago

Even if the player transcodes the video, playback stutters regardless of which setting I select. The container of the video file is an mp4

bnkai commented 3 years ago

Can you provide some logs? or a sample clip from the file ? ffmpeg -i file.mp4 -t 60 -c:a copy -c:v copy sample.mp4 Make sure to scan and try the sample again to see it has the same problem.

ghost commented 3 years ago

021-01-21 11:49:04 Info
[stream] transcoding video file to video/webm 2021-01-21 11:49:04 Debug
Streaming via: /usr/bin/ffmpeg -hide_banner -v error -i /media/fehler/video_01.mp4 -c:v libvpx-vp9 -vf scale=iw:-2 -deadline realtime -cpu-used 5 -row-mt 1 -crf 30 -b:v 0 -ac 2 -f webm pipe: 2021-01-21 11:49:04 Debug
Streaming as video/webm 2021-01-21 11:49:04 Debug
SQL: SELECT DISTINCT galleries.id FROM galleries left join performers_galleries as performers_join on performers_join.gallery_id = galleries.id left join studios as studio on studio.id = galleries.studio_id left join galleries_tags as tags_join on tags_join.gallery_id = galleries.id left join galleries_images as images_join on images_join.gallery_id = galleries.id left join images on images_join.image_id = images.id GROUP BY galleries.id ORDER BY galleries.path ASC LIMIT 40 OFFSET 0 , args: [] 2021-01-21 11:49:01 Debug
SQL: SELECT DISTINCT scenes.id FROM scenes left join scene_markers on scene_markers.scene_id = scenes.id left join performers_scenes as performers_join on performers_join.scene_id = scenes.id left join movies_scenes as movies_join on movies_join.scene_id = scenes.id left join studios as studio on studio.id = scenes.studio_id left join galleries as gallery on gallery.scene_id = scenes.id left join scenes_tags as tags_join on tags_join.scene_id = scenes.id left join scene_stash_ids on scene_stash_ids.scene_id = scenes.id GROUP BY scenes.id ORDER BY scenes.updated_at DESC, bitrate DESC, framerate DESC, scenes.rating DESC, scenes.duration DESC LIMIT 40 OFFSET 0 , args: [] 2021-01-21 11:49:01 Debug
SQL: SELECT DISTINCT scenes.id FROM scenes left join scene_markers on scene_markers.scene_id = scenes.id left join performers_scenes as performers_join on performers_join.scene_id = scenes.id left join movies_scenes as movies_join on movies_join.scene_id = scenes.id left join studios as studio on studio.id = scenes.studio_id left join galleries as gallery on gallery.scene_id = scenes.id left join scenes_tags as tags_join on tags_join.scene_id = scenes.id left join scene_stash_ids on scene_stash_ids.scene_id = scenes.id GROUP BY scenes.id ORDER BY scenes.date ASC, bitrate DESC, framerate DESC, scenes.rating DESC, scenes.duration DESC LIMIT 40 OFFSET 0 , args: [] 2021-01-21 11:48:53 Info
Retrieved latest hash: 093b997 2021-01-21 11:48:42 Info
stash is running at http://localhost:9999/ 2021-01-21 11:48:42 Info
stash is listening on 0.0.0.0:9999 2021-01-21 11:48:42 Info
Version: (093b997) is already the latest released.

bnkai commented 3 years ago

The log seems normal. Unless you have a low power cpu where you are running stash ( 1080p vp9 needs a bit of cpu power ) you shouldnt have an issue. Have you tried forcing lower resolutions eg 480p? or using the mp4 profiles ?

EDIT You could also try this

 /usr/bin/ffmpeg -i /media/fehler/video_01.mp4 -c:v copy -ac 2  /media/fehler/video_01_aac.mp4

This should keep the video as is and only transcode the audio. The new file should play directly ( no live transcoding needed ) in stash as the only reason it is now transcoded is the ac3 audio part.

ghost commented 3 years ago

CPU(s) 4 x Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz

The same problem occurs with the Sample.mp4. But why does it run without a problem when I call up the stream via the link under "File info" -> "Stream"?

Edit: I try the suggestion and get in touch.

" You could also try this

/usr/bin/ffmpeg -i /media/fehler/video_01.mp4 -c:v copy -ac 2 /media/fehler/video_01_aac.mp4 This should keep the video as is and only transcode the audio. The new file should play directly ( no live transcoding needed ) in stash as the only reason it is now transcoded is the ac3 audio part."

bnkai commented 3 years ago

The Stream only serves the file it doesnt process it.

ghost commented 3 years ago

It works very well with the new audio codec. I thank you.

ghost commented 3 years ago

We should probably do a better job of remuxing and optionally reencoding audio when the video is h264. I've got a bunch of flv files that are h264/aac for instance, which get fully transcoded.

bnkai commented 3 years ago

Yeah i tried something a lot of iterations of the transcoding process ago, the only thing left from then is that if the original contaier was an mkv and the video codec is supported stash will try to only transocde the audio part in a new mkv container. The main issue was that at that time i couldnt remux the video to another container except mkv and keep the file streamable ( i think i had some issues with the movflags when trying to copy the stream). Seeing that the movflags work now it might be worth it to revisit the issue. Flvs should be doable if movflags work with the copy only, ts files tend to have issues though