kazam icon indicating copy to clipboard operation
kazam copied to clipboard

MP4 screencast does not play in web browser

Open baptx opened this issue 7 years ago • 26 comments

After recording a screencast as H264 (MP4), the file plays correctly in a video player like VLC but when we try to play the screencast in a web browser like Firefox, there is an error message "Video can't be played because the file is corrupt". The workaround is to reencode the video with a tool like ffmpeg / avconc or avidemux (by selecting MP4 AVC x264). The reencoded file also has the advantage to have a smaller size (3 MB instead of 7 MB in my case for the same quality / codec).

Tested on Ubuntu 18.10 (LXQt) with Kazam 1.4.5.

baptx avatar Nov 03 '18 16:11 baptx

I am facing the same problem, would you mind sharing the exact ffmpeg command you used to convert the video? Thanks a lot.

meggart avatar Mar 15 '19 10:03 meggart

@meggart If I remember correctly, you can fix the issue with a simple command like ffmpeg -i input.mp4 output.mp4. That is what I do also when I download a video that is not well supported by some players.

baptx avatar Mar 18 '19 16:03 baptx

I needed to use the following ffmpeg command to get mp4 videos to work on Firefox 66: ffmpeg -i <your input video>.mp4 -pix_fmt yuv420p -vcodec libx264 -acodec avc <output file name>.mp4

gslavin avatar May 10 '19 18:05 gslavin

@gslavin solution works but it's strange that I need to do this for every video. Can we have this issue fix please @kazam?

dudumanbogdan avatar Oct 15 '19 05:10 dudumanbogdan

@gslavin thanks, it looks like ffmpeg -i input.mp4 output.mp4 is not enough to make it play in a web browser like Firefox. Just using ffmpeg -i input.mp4 -pix_fmt yuv420p output.mp4 without -vcodec libx264 -acodec avc worked for me.

baptx avatar Aug 10 '20 18:08 baptx

Facing the same issue. Also getting: image

Mennaruuk avatar Dec 02 '20 05:12 Mennaruuk

I second the change request. I have the same issue. I cannot share a recoreded file in Gdrive (with gdrives own player) because of this issue.

caliph007 avatar Feb 18 '21 17:02 caliph007

Same here. It's also not recognized as a video file when you try to share it vía WhatsApp for example

Davixe7 avatar Feb 25 '21 17:02 Davixe7

yeah same problem,, if i want move videos to mobile, i have crash on kazam

sultanzio avatar Mar 01 '21 04:03 sultanzio

So what is the cause of this issue? Firefox plays videos from other screen recorders (e.g. Peek) correctly, and the codec in the files from Kazam I've received is regular h264. The file opens fine in smplayer and in Chromium. Here's the file info tab from smplayer: image

quezak avatar Mar 01 '21 10:03 quezak

FWIW, It's still an issue on Ubuntu 20.04.2 LTS, Kazam 1.4.5

tomalec avatar Apr 12 '21 12:04 tomalec

Seeing this as well. Kazam 1.4.5, ubuntu 20.04

dopeboy avatar Apr 14 '21 05:04 dopeboy

The issue seems to be that Kazam uses YUV 4:4:4 which is less common than YUV 4:2:0 (https://wiki.videolan.org/YUV/#Planar_formats). On VLC media player, when opening the menu "Tools -> Media information" or using the Ctrl+I shortcut, we can see in the Codec tab "Decoded format: Planar 4:4:4 YUV", which is not displayed on videos working with Firefox. However Kazam videos are working in a web browser like Chromium for me too.

baptx avatar May 03 '21 14:05 baptx

@baptx thanks for the explanation! Are there any disadvantages to using the most common and most supported 4:2:0 format? ie. is there a reason Kazam chose the less popupar one, or is it just a coincidence and it could be changed to improve support for the resulting videos?

quezak avatar May 04 '21 09:05 quezak

@quezak good question, since I don't know I searched "YUV 4:4:4 vs 4:2:0" on a search engine like DuckDuckGo and found this: https://www.reddit.com/r/PS4Pro/comments/8xw3ad/how_important_is_yuv_444_vs_420_re_4k_hdmi/ The best thing would be Firefox to support YUV 4:4:4 like Chromium is doing. Maybe we should create a bug report for Firefox if someone did not already create it. But for this Kazam issue, it would be nice if we can choose between YUV 4:4:4 and 4:2:0 in the settings. And I would suggest that Kazam uses YUV 4:2:0 by default so the screencast will be supported on most software unless we really want YUV 4:4:4.

baptx avatar May 05 '21 10:05 baptx

An alternative solution is to use the webm format. At least in my firefox the webm format works.

support looks good:

https://caniuse.com/webm

Kazam supports the webm format via settings. This way I don't need to convert the file before uploading it.

guettli avatar Sep 08 '21 11:09 guettli

You can try my fix here, it'll change the screencasts to I420(yuv 4:2:0)... https://github.com/niknah/kazam/commit/8995e63cb8cc30e4c623871bedc5050942a36756

niknah avatar Sep 09 '21 10:09 niknah

You can try my fix here, it'll change the screencasts to I420(yuv 4:2:0)... niknah@8995e63

Why do you prefer this format to webm?

guettli avatar Sep 16 '21 15:09 guettli

webm appears rotated sideways when I view it in vlc. Maybe webm support is better nowadays, video editing programs used to have various problems with it.

niknah avatar Sep 17 '21 01:09 niknah

IIUC, its because Kazam uses h264 instead of libx264. From here - https://ourcodeworld.com/articles/read/989/kazam-recorded-mp4-video-in-ubuntu-isn-t-recognized-in-sony-vegas-corrupted-mp4-file-for-windows

DhruvaSambrani avatar Jan 12 '22 19:01 DhruvaSambrani

The ffmpeg command line in the above link includes "-pix_fmt yuv420p" which converts it from yuv444p (not viewable by firefox) to yuv420p (viewable by firefox). If you run that same command line with "-pix_fmt yuv444p" it won't work.

niknah avatar Jan 13 '22 09:01 niknah

So I need to convert each time that I decided to record this? LOL, it's a perfect dream =D

Thank you so much Kazam developer's! (contains irony)

leonardomarcao avatar Apr 19 '24 18:04 leonardomarcao

for weeks i think its whatsapp bug or something that can't play my video. so its kazam's bug then haha. and still not fixed for almost 3 years. ...

sadmiral98 avatar May 06 '24 14:05 sadmiral98