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
9.24k stars 794 forks source link

[Bug Report] This video file cannot be played. (Error Code: 224003) #354

Closed victorhooi closed 4 years ago

victorhooi commented 4 years ago

Describe the bug When trying to play certain videos in the interface, I get an error:

This video file cannot be played.
(Error Code: 224003)

To Reproduce Steps to reproduce the behavior:

  1. Open up Stash
  2. Click on a video to open it
  3. Click on the "Play" arrow to start playback

Expected behavior Video should play

Screenshots If applicable, add screenshots to help explain your problem please ensure that your screenshots are SFW or at least appropriately censored.

Desktop (please complete the following information):

According to the FIleinfo tab, the codec type is h264. (for my reference - e.g. checksum 8c15c34eb54244659c75e213887a317b).

Here is the output from ffprobe:

$ ffprobe test.mp4
ffprobe version 4.1.4-1~deb10u1 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mpegts @ 0x55ef7f6f4000] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from 'test.mp4':
  Duration: 02:36:51.19, start: 0.999000, bitrate: 7451 kb/s
  Program 1
    Stream #0:0[0x810]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x814](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 196 kb/s
victorhooi commented 4 years ago
$ ffprobe  -show_format -show_streams test.mp4
ffprobe version 4.1.4-1~deb10u1 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=r
esample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreety
pe --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-li
bshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libx
ml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --
enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mpegts @ 0x560cd923d000] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from 'test.mp4':
  Duration: 02:36:51.19, start: 0.999000, bitrate: 7451 kb/s
  Program 1
    Stream #0:0[0x810]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x814](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 196 kb/s
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1001/60000
codec_tag_string=[27][0][0][0]
codec_tag=0x001b
width=1920
height=1080
coded_width=1920
coded_height=1088
has_b_frames=1
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=tv
color_space=bt709
color_transfer=bt709                                                                                                                                                                                                                
color_primaries=bt709
chroma_location=left
field_order=tt
timecode=N/A
refs=1
is_avc=false
nal_length_size=0
id=0x810
r_frame_rate=60000/1001
avg_frame_rate=30000/1001
time_base=1/90000
start_pts=89910
start_time=0.999000
duration_ts=847006660
duration=9411.185111
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[15][0][0][0]
codec_tag=0x000f
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=0x814
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=89910
start_time=0.999000
duration_ts=846958080
duration=9410.645333
duration_ts=846958080                                                                                                                                                                                                              
duration=9410.645333
bit_rate=196500
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:language=eng
[/STREAM]
[FORMAT]
filename=test.mp4
nb_streams=2
nb_programs=1
format_name=mpegts
format_long_name=MPEG-TS (MPEG-2 Transport Stream)
start_time=0.999000
duration=9411.185111
size=8765571072
bit_rate=7451194
probe_score=50
[/FORMAT]
victorhooi commented 4 years ago
$ file test.mp4
test.mp4: data
bnkai commented 4 years ago

From the logs it seems that they are not mp4 files but .ts files renamed to mp4 or at least the container is ts / not a valid mp4.

It seems that the free version of jwplayer doesn't support mpegts container directly. https://stackoverflow.com/questions/48662572/view-mpeg-ts-stream-in-browser

Edit Converting the specific files to mp4 using ffmpeg fmpeg -i test.mp4 -c:v copy -c:a copy test_copy.mp4 makes the resulting files play through JW player verifying that while the codecs are supported the container isn't . This is limited to JWPlayer as ffmpeg has no problem creating the screenshots,sprites,thumbnails and previews for the "mpegts" mp4 files.

victorhooi commented 4 years ago

Thanks bnkai for summarising.

So it seems like, assuming we don't go for the paid JW Player, we could either find an alternative web-based video player to play these files, or do some kind of transcoding/conversion/copying in Stash during the scan process for any MPEGTS files it finds.

bnkai commented 4 years ago

Ok as discussed a possible future fix for that:

Ffprobe already parses the info we need.

FormatName     string `json:"format_name"`

We just have to add this as an extra column to the scenes table and insert during the scan. Then we can create a isValidContainer function to combine with isValidCodec. If the codec is not valid we transcode anyway. If the codec is valid but the container not we can hopefully skip the transcode and live stream the file, copying the streams intact into a supported container as in the ffmpeg example above.

Also we need to find a way (tbd) so on the first run after the update we populate the container for our already existing files.

Updating with another combination: mkv container and h264 as codec. An easy way to find samples using the database select id FROM scenes WHERE path like "%.mkv" and video_codec like "h264" ;

so the black list should include (as reported by ffprobe's format_name) for now

matroska,webm
mpegts

with

h264
h264

as the respective codec

matroska,webm is valid as a container if vp8 or vp9 is the respective codec so the logic mentioned above for choosing what is valid might need to be adjusted a bit

bnkai commented 4 years ago

ffprobe doesn't differentiate between mkv and webm. (edit we can complement ffprobe with a magic_number read for cases like this e.g. using https://github.com/h2non/filetype or a custom made per case function from us) For both it returns the same container matroska,webm even though it is not actually the same. Mediainfo for example returns different. The issue with this is that jwplayer in firefox cannot play vp8,vp9 files in mkv container while it does in webm. I haven't encountered any actual vp8, vp9 mkv files though, i generated those with ffmpeg.

To make things more complicated chrome, opera and i think most of the chromium based browsers support mkv playback ( and thus jwplayer also ) if the codec is supported. E.g. mkv and h264 or mkv and vp9 are valid combinations for them.

Leopere commented 4 years ago

Checksum | REDACTED
-- | --
Path | file:///stash/REDACTED.avi
Stream | https://stash.REDACTED/scene/348/stream.mp4
File Size | 3.62 GB
Duration | 32:04
Dimensions | 1280 x 720
Frame Rate | 60 frames per second
Bit Rate | 16.15 megabits per second
Video Codec | h264
Audio Codec | mp3

I get the same playing an AVI it will stream on that .mp4 transcode url.

bnkai commented 4 years ago

Yes thats another one format_name=avi codec=h264

ghost commented 4 years ago

https://github.com/video-dev/hls.js/ with this player the H264 (FLV File) stream works.

bnkai commented 4 years ago

@hassaffe we use the player for a lot of stuff already so changing player is not an option afaik. A PR is on the way for this issue so it's just a matter of time for those files to play as they should

format_name=flv codec=h264 also blacklist

bnkai commented 4 years ago

@hassaffe @victorhooi i made a simple PR (384) facing the isssues , if you want to try it the binaries compiled and uploaded by travis are here stash-osx uploaded to url: https://transfer.sh/12SS2/stash-osx stash-win.exe uploaded to url: https://transfer.sh/t6nAu/stash-win.exe stash-linux uploaded to url:https://transfer.sh/2v1Jy/stash-linux It should detect and transcode all the files listed here

ghost commented 4 years ago

I tested the version. The files are played. The player says "Live". The log shows that an attempt is being made to transcord the file during playback. Unfortunately, the playback is very jerky. From the concept of transcoding in play, I find it better than transcoding all unsupported formats.

Good Work.

The processor and the graphics card of the server show no increase in performance. So the server is not overloaded.

bnkai commented 4 years ago

The PR as it is now only makes the detection possible so that the files are transcoded instead of left as they are. Did you try adjusting Maximum streaming transcode size in the settings to see if the jerkiness goes away?

ghost commented 4 years ago

I reduced the maximum streaming transcode size and it ran smoothly without jerking. I converted the film for trial via FFmpeg (on the server), this was faster than real time.

ghost commented 4 years ago

Since the codec is H264, I simply put the files in a new container. (Without encoding)

ffmpeg -i INPUT -map 0 -c:v copy -c:a copy OUTPUT

bnkai commented 4 years ago

@hassaffe thats what i plan to do for the (h264) transcodes during the generation task. I would leave out the -c:a copy part to make sure that the resulting mp4 files have aac as the audio codec.