sonysuqin / WasmVideoPlayer

Play file/stream with wasm & webgl & web audio api, using ffmpeg for multi codec support, especially for h265,support http, websocket, http-flv stream.
GNU General Public License v3.0
1.3k stars 375 forks source link

How to build h264 #40

Closed vasanthudhaya closed 4 years ago

vasanthudhaya commented 4 years ago

Hi @sonysuqin, Thanks for the wonderful repo

Here in this repo you builded the hevc type of video decoder.js. The same i need to build h264 codec support decoder.js. That is very useful for my project.

I tried to build the h264 codec support on edit the file (https://github.com/sonysuqin/WasmVideoPlayer/blob/master/build_decoder.sh) with --enable-demuxer = mov,mp4. But that will be not working for me.

So kindly let know me how to build the h264 decoder.js with latest ffmpeg version.

Thanks in advance...

sonysuqin commented 4 years ago

Hi @vasanthudhaya H264 already supported by '--enable-decoder=h264' in build_decoder.sh, is there any problem playing MP4/H264 file?

vasanthudhaya commented 4 years ago

Yeah @sonysuqin, there was a problem appears while give an input of other videos. ie) Some other mp4 format videos are not working.

Reference link: https://gcs-vimeo.akamaized.net/exp=1578387656~acl=%2A%2F514754074.mp4%2A~hmac=e3fea79d34c0c03c21278d05183f469f3f46175e172e8f4b721e4996de6312fb/vimeo-prod-skyfire-std-us/01/2579/6/162896263/514754074.mp4

The above link video is not played in your demo. I downloaded the video and placed the video in video folder and starts to decode but the decode throws error like the below

[2020-1-7 10:44:32:238][Decoder][IF] Wasm loaded.
common.js:58 [2020-1-7 10:44:32:929][Player][IF] Play video/Bullfinch2797.mp4.
common.js:58 [2020-1-7 10:44:32:952][Downloader][IF] Getting file size video/Bullfinch2797.mp4.
common.js:58 [2020-1-7 10:44:32:976][Player][IF] Got file size rsp:200 size:7649950 byte.
common.js:58 [2020-1-7 10:44:32:976][Player][IF] Initializing decoder.
common.js:58 [2020-1-7 10:44:32:986][Decoder][IF] initDecoder return 0.
common.js:58 [2020-1-7 10:44:32:986][Player][IF] Init decoder response 0.
common.js:58 [2020-1-7 10:44:33:61][Player][IF] Opening decoder.
libffmpeg.js:1 18
libffmpeg.js:1 18
abort @ libffmpeg.js:1
(anonymous) @ wasm-01306ac6-343:1
(anonymous) @ wasm-01306ac6-2802:1
(anonymous) @ wasm-01306ac6-104:1
(anonymous) @ wasm-01306ac6-123:1
(anonymous) @ wasm-01306ac6-243:1
(anonymous) @ wasm-01306ac6-917:1
(anonymous) @ wasm-01306ac6-2185:1
(anonymous) @ wasm-01306ac6-2472:1
(anonymous) @ libffmpeg.js:1
Decoder.openDecoder @ decoder.js:48
Decoder.processReq @ decoder.js:165
self.onmessage @ decoder.js:248
libffmpeg.js:1 Uncaught abort(18). Build with -s ASSERTIONS=1 for more info.
abort @ libffmpeg.js:1
(anonymous) @ wasm-01306ac6-343:1
(anonymous) @ wasm-01306ac6-2802:1
(anonymous) @ wasm-01306ac6-104:1
(anonymous) @ wasm-01306ac6-123:1
(anonymous) @ wasm-01306ac6-243:1
(anonymous) @ wasm-01306ac6-917:1
(anonymous) @ wasm-01306ac6-2185:1
(anonymous) @ wasm-01306ac6-2472:1
(anonymous) @ libffmpeg.js:1
Decoder.openDecoder @ decoder.js:48
Decoder.processReq @ decoder.js:165
self.onmessage @ decoder.js:248
common.js:54 [2020-1-7 10:44:33:998][Player][ER] Reach file end.

So is there any possibilites to re-compile with all types of video support ? example: 3gp, mp4, avi,.. That will be very useful for me..

Thanks in advance....

sonysuqin commented 4 years ago

The url you provided outputs "Access Denied", so I can't be sure, there maybe some format problem with this file, for example, moov box was put at tail. Anyway, my mp4 file on my server is all right, you can compare format of those files with mp4reader or mp4info, and transform it with ffmpeg.

vasanthudhaya commented 4 years ago

@sonysuqin Sorry for the Access Denied issue. Kindly use the below url video.

https://pixabay.com/videos/bullfinch-male-bird-nature-red-2797/

And I am a beginner level programmer of c and c++ program language. So kindly provide the compile steps of external libraries such as libx264.

sonysuqin commented 4 years ago

Hi, @vasanthudhaya I've downloaded that file and found it indeed put moov box at tail, so meta info in moov box can't be loaded before playing, you need to convert it to the right format for this player, with follow cmd:

ffmpeg -i Bullfinch2797.mp4 -acodec copy -vcodec copy -movflags faststart 2797.mp4

vasanthudhaya commented 4 years ago

@sonysuqin Thanks for your reply.

Still, i have got the same error for the below URL even after the above conversion was done.

https://pixabay.com/videos/robin-bird-forest-nature-spring-21723/

So for my project i need all type of video support. Kindly let me know how to compile ff-mpeg with all video support or please give me a solution how to resolve this error.

sonysuqin commented 4 years ago

@vasanthudhaya Hi. I checked the file, the failure reason is that file just got one video track, one single track is not supported by now, this player only support certain format, there's some work to do to support "all type of video", sorry for that, I won't pay too much time on that target currently, you can try it yourself, it's not a difficult task but need time. In practice, we convert all videos to the same format on our platform in case of incompatibility. After all, expect format of this player for now is "mp4, with audio & video track, moov box ahead".

vasanthudhaya commented 4 years ago

@sonysuqin, Thanks for your valuable time for the past few days. Your reference and conversation have be very useful for me.

For my try share a ffmpeg compilation tutorial links.