Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in Safari #7

Open
jhodges10 opened this issue Jul 27, 2019 · 5 comments
Open

Doesn't work in Safari #7

jhodges10 opened this issue Jul 27, 2019 · 5 comments

Comments

@jhodges10
Copy link

Not sure if it's just me or not, but while the plugin works in Chrome - it does not work in Safari.

For example, https://beta.jeffhq.com/verizon-go90/ this page does not show looping vids in Safari.

jhodges10/jeffhq-v2@777559d

This commit shows my attempt to make sure it wasn't trying to load .webm but even that didn't fix it.

@Mike-Dax
Copy link
Owner

Mike-Dax commented Jul 28, 2019

html5 video tags will dynamically load the 'correct' one, for example Safari won't load a webm.

However it seems like your mp4 isn't able to be played in Safari.

https://beta.jeffhq.com/static/go90_drew_v09-4138661fabdb68efee190dcd047fb90a-8722d.mp4

Loading the video directly doesn't work.

I've made some changes to the defaults which make the mp4 a bit more compatible. Specifically specifying a yuv420p pixel format and using a main, low-cpu use profile.

Perhaps that will work? I'm having some of my builds work in Safari and some not, I'm not sure what's going on there. I've run out of time this weekend to work on this - but if you could figure out the ffmpeg settings that produce an mp4 that Safari likes, I'll make that the default.

I've made a query based version of this plugin (since I now need videos outside my 'articles')

https://github.com/Mike-Dax/gatsby-transformer-ffmpeg

So you should be able do a query like this in the ___graphql url and 'iterate quickly' to find some combination of settings that work for you if the new defaults don't work.

{
  allVideoFfmpeg {
    edges {
      node {
        mp4: transcode(maxWidth: 900, maxHeight: 480, fileExtension: "mp4", codec: "libx264", options:[["-profile:v", "main"], ["-pix_fmt", "yuv420p"]]) {
          width
          src
          presentationMaxWidth
          presentationMaxHeight
          originalName
          height
          aspectRatio
        }
      }
    }
  }
}

          {
            resolve: `gatsby-remark-videos`,
            options: {
              pipelines: [
                {
                  name: 'vp9',
                  transcode: chain =>
                    chain
                      .videoCodec('libvpx-vp9')
                      .noAudio()
                      .outputOptions(['-crf 20', '-b:v 0']),
                  maxHeight: 480,
                  maxWidth: 900,
                  fileExtension: 'webm',
                },
                {
                  name: 'h264',
                  transcode: chain =>
                    chain
                      .videoCodec('libx264')
                      .noAudio()
                      .addOption('-profile:v', 'main')
                      .addOption('-pix_fmt', 'yuv420p')
                      .outputOptions(['-movflags faststart'])
                      .videoBitrate('1000k'),
                  maxHeight: 480,
                  maxWidth: 900,
                  fileExtension: 'mp4',
                },
              ],
            },
          },

@jhodges10
Copy link
Author

The updated encoding settings seem to be working for me!

Thanks @Mike-Dax

@jhodges10
Copy link
Author

Well I take that back... It worked yesterday in Safari while running in development mode, and now it's not!

Why can't everything just run on Chromium :(

@Mike-Dax
Copy link
Owner

Mike-Dax commented Oct 7, 2019

So this worked on my friend's iPhone X during iOS 12, and upon upgrading to iOS 13 it doesn't work anymore.

@cwgw
Copy link

cwgw commented Oct 24, 2019

Hi. I think this might have to do with gatsby-plugin-offline and how workbox handles range requests. There's an issue for it at gatsbyjs/gatsby too.

The gist (I think) is that caching range requests is complicated and Safari is particularly strict about it.

If that is your problem, then you can fix it by removing gatsby-plugin-offline. It's a bummer of course since you lose offline and PWA support, but I haven't seen a better solution yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants