8ff / firescrew

Firescrew - Spotting moving objects on your RTSP network cameras faster than a caffeinated cat!
https://firescrew.com
GNU Affero General Public License v3.0
142 stars 11 forks source link

H265 will not play in Safari #7

Closed wehbs closed 1 year ago

wehbs commented 1 year ago

So h265 works great in chrome but would love to view on ios. I came across this post

https://www.reddit.com/r/ShinobiCCTV/comments/hh4ueo/howto_get_h265_playback_working_on_safari/?utm_source=share&utm_medium=ios_app&utm_name=ioscss&utm_content=2&utm_term=1

Seems like a simple solution?

chiefMarlin commented 1 year ago

Its worth trying it, you are suggesting that this be added to tje Onlyremuxmp4 parameters ? if globalConfig.Video.OnlyRemuxMp4 { cmd = exec.Command("ffmpeg", "-i", inputFile, "-c", "copy", outputFile)

wehbs commented 1 year ago

if globalConfig.Video.OnlyRemuxMp4 { cmd = exec.Command("ffmpeg", "-i", inputFile, "-c", "copy", "-hls_segment_type", "fmp4", outputFile) }

I think that should do it.

chiefMarlin commented 1 year ago

This has been implemented in the pre release i mentioned in the other issue

wehbs commented 1 year ago

Ok, so I tried it out but it still didn't work. Spent some time messing with ffmpeg and I finally got it to work. Can you please change to:

if globalConfig.Video.OnlyRemuxMp4 { cmd = exec.Command("ffmpeg", "-i", inputFile, "-c:v", "copy", "-c:a", "aac", "-tag:v", "hvc1", "-movflags", "+faststart", "-hls_segment_type", "fmp4", outputFile) }

chiefMarlin commented 1 year ago

When i run ffmpeg -i a.ts -c:v copy -c:a aac -tag:v hvc1 -movflags +faststart -hls_segment_type fmp4 b.mp4 i get an error Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 130 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help [mp4 @ 0x12ef068a0] Tag hvc1 incompatible with output codec id '27' (avc1) [out#0/mp4 @ 0x600000a600c0] Could not write header (incorrect codec parameters ?): Invalid data found when processing input [aost#0:1/aac @ 0x12ef07ef0] Error initializing output stream: [aac @ 0x12ef081c0] Qavg: nan Conversion failed!

wehbs commented 1 year ago

Seems like maybe because -tag:v hvc1 only works on HEVC (h265)

wehbs commented 1 year ago

So maybe this should be another option in the config for h265 users?

chiefMarlin commented 1 year ago

Yup, im gonna see if i can dynamically get this info

chiefMarlin commented 1 year ago

So when stream info is pulled, it gets the codec name, for me it shows up as 'h264' when "printDebug": true, is enabled in config i am assuming for your stream it would show h265 or something similar ? If thats the case then i can use that to determine ffmpeg options

wehbs commented 1 year ago

"codec_name": "hevc", "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",

chiefMarlin commented 1 year ago

Thanks, You can try it here https://github.com/8ff/firescrew/releases/download/onnx_test_release/firescrew.darwin.arm64

wehbs commented 1 year ago

Ok, so it's improved, in that it allows me to press play and plays the audio but still no video in Safari. However, if I open the .mp4 file directly from drive with either quicktime or safari directly it does now play when it wouldn't before. When I download said video through the web gui it downloads a .TS version that also does not play in Safari or quicktime.

chiefMarlin commented 1 year ago

Are you able to provide a sample video file ?

wehbs commented 1 year ago

Yes, here you go:

https://tempcloud.cf/

file name: firescrew_sample number: 420

wehbs commented 1 year ago

sorry that seems broken, will try elsewhere

chiefMarlin commented 1 year ago

You can try https://transfer.sh

wehbs commented 1 year ago

https://send-anywhere.com/

345270

chiefMarlin commented 1 year ago

https://send-anywhere.com/

345270

Im getting The key is invalid or has expired

wehbs commented 1 year ago

Nice will bookmark the one you suggested, and will upload to it now.

wehbs commented 1 year ago

https://transfer.sh/a1N58gRGqP/clip_KvesHSA9qZzCpjY.mp4

wehbs commented 1 year ago

New revelation, it does work on mobile safari.. lol.. Which is really what matters the most in this scenario since it also still works very well in Chrome.

chiefMarlin commented 1 year ago

Thanks for that, i think the issue was the filename was being requested with .ts extension but later served with as mp4 i have fixed it (atleast on my safari 😄 ) https://github.com/8ff/firescrew/releases/download/onnx_test_release/firescrew.darwin.arm64

wehbs commented 1 year ago

BOOM! Solid!

chiefMarlin commented 1 year ago

Let me know if i can close this

wehbs commented 1 year ago

good to close 💪