We help IT Professionals succeed at work.

Unable to play a .mp4 in Chrome. Only sound works.

ITSysTech
ITSysTech asked
on
We are trying to play a .mp4 in the latest version of Chrome. The .mp4 is located on a Windows 2016 IIS server. The audio works fine but the video will not work. It does work in Edge though. Any ideas?
Comment
Watch Question

Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
Not all videos are the same.  A mp4 can be made in different ways.  H.264, h.265, mpeg-4  https://www.nch.com.au/kb/10252.html

https://www.chromium.org/audio-video
H.264 [Google Chrome only]
MPEG-4 [Google Chrome OS only]

I can't say for sure, but it is possible the format is not fully supported.
ITSysTechSenior Systems Administrator

Author

Commented:

I believe your correct. The issues we have is that we would have to convert 2,600 .mp4 videos to work in HTML5.

Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
You can do that all with code using ffmpeg https://www.ffmpeg.org/

Other solutions for bulk would be vlc media player or handbrake https://handbrake.fr/docs/en/1.3.0/cli/cli-options.html
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
For ffmpeg as example, https://trac.ffmpeg.org/wiki/Encode/H.264

COMMAND LINE
ffmpeg -i input.avi -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv

Open in new window


Now imagine this is done instead using variables
ffmpeg -i $INPUT.AVI-c:v libx264 -preset slow -crf 22 -c:a copy $INPUT.MKV

Open in new window


Where the variable is called from a loop you created that traverses all of your folders and files. For a vbscript example, I just published this https://www.experts-exchange.com/articles/33944/Use-VBScript-to-Silently-Remove-Empty-Folders.html to traverse through all folders and delete if empty. You can see how you can modify to also loop through all files in the folder and instead of deleting anything, run ffmpeg.
David FavorFractional CTO
Distinguished Expert 2019
Commented:
1) Start by posting the output of the following command...

ffmpeg -i /path-to-one-of-your-videos.mp4

Open in new window


This will show your current audio + video codec for a video.

2) Then mention all playback methods, if there are any other besides Chrome.

3) Scott's compression example will work well. You might pull some of the following out of the transcode tool I use for TV/Movie footage...

ffmpeg -fflags +genpts -async 1 -i 'file.mp4' -map 0:0 -c:v libx264 -crf:v 18 -preset:v veryfast -tune:v film -level:v 4.1 -profile:v high -b:v 5000K -maxrate:v 5000K -bufsize:v 5000k -vf setdar=dar=0,setsar=sar=0 -x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709:fullrange=off:rc_lookahead=60 -movflags +faststart -map 0:1 -c:a libfdk_aac -profile:a aac_he_v2 -afterburner 1 -signaling explicit_sbr -vbr 5 -ac 2 -ar 44100 > file-trancoded.mp4

1) -vpreset:v veryfast - Runs orders of magnitude faster than slow + also produces much smaller files. For 1000s of files, this might work better than slower presets.

2) -crf:v 18 - Adjust this value to target a specific file size + playback quality. Normally 18 is a bit slower + higher quality than human eyes can see. Best to test a variety of settings, till you get your sweet spot.

3) -tune:v film - Targets the type of input footage you're working with.

4) -movflags +faststart - Useful for fast start serving videos, if videos are played off a server somewhere.

5) -b:v 5000K -maxrate:v 5000K -bufsize:v 5000k - Also effects the buffer size for server playback.

6) -c:v libx264 - Targets h.264 transcoding, same as Scott's example. Be sure you actually have the most recent x264 installed, as a new version is distributed nightly.

7) other video codecs - You may target many codecs (VP9 + HEVC) also, then build fallback HTML to serve your videos. Just depends on all devices you're targeting.

8) -c:a libfdk_aac -profile:a aac_he_v2 -afterburner 1 -signaling explicit_sbr -vbr 5 -ac 2 -ar 44100 - Transcode audio using the FDK AAC codec, which produces massive audio stream compression with high fidelity playback.

9) -async 1 - Instructs ffmpeg to do a pre scan of a few seconds periodically through transcode, then automagically sync up audio + video time bases. I always use this, as some videos will desync audio over entire playback. This option makes transcodes slightly slower, with audio + video in sync almost all the time.

10) -map 0:X - You'll only require using this if you have videos with multiple videos streams + multiple audio streams. The transcoder tool I use, goes through an ffmpeg -i + builds up a best guess of which video + audio stream to transcode, when there are many. You can skip using these if you only have one audio stream + one video stream.
ITSysTechSenior Systems Administrator

Author

Commented:

Excellent. This was what I was looking for to fix this issue. Thanks