Open hahazexia opened 7 years ago
.mpg files are not supported. JSMpeg only plays MPEG-TS containers. See the readme.
You can use ffmpeg
to repackage your MPEG-1 encoded video into an MPEG-TS container without transcoding:
ffmpeg -i in.mpg -f mpegts -v:c copy out.ts
ok,fine,i see that,thanks and i have a another question : How can i know when the video is ended? i don't have any method or event to check out
i had same err message WebGL: INVALID_OPERATION: texImage2D: type UNSIGNED_BYTE but ArrayBufferView not Uint8Arra JSMpeg: Possible garbage data. Skipping.
I try to use jsmpeg demo sample to display rtsp stream through websocket , broswer side can receive video stream but always show erroor "JSMpeg: Possible garbage data. Skipping." when it run decoder
this is my ffmpeg command " ffmpeg -i rtsp://192.168.168.22 -f mpeg2video -b 800k -r 30 http://localhost:8081/1234/640/480/"
If i save stream on server side and play ts file with jsmpeg then decoder is no problem to play
Is anything i did wrong ?
@daiseita: same issue. Use the mpegts format for streaming, not mpeg2video.
@hahazexia: there's currently no straight forward way to do this. The player pauses at the end (if not looping), so you could check for that. I'll probably implement a bunch of callbacks for things like this.
@daiseita use the 'mpegts'; not the 'mpeg2video '
@phoboslab By the way , the introduce on the index page, there is some thing wrong missing a comma after the 'video.ts'
@phoboslab Thank for your answer , i change my command to "ffmpeg -i rtsp://192.168.168.22 -f mpegts -b 800k -r 30 http://localhost:8081/1234/640/480/"
error "JSMpeg: Possible garbage data. Skipping." is not show but browser canvas is display a picture not toatally be decode and after 1 or 2 minute browser became frozen not work anymore ,do not show any javascript error msg
jsmpeg use mpeg1video and mp2 . ffmpeg -i rtsp://192.168.168.22 -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2 -r 30 http:// localhost:8081/1234/640/480 / ”
@hahazexia @phoboslab @wait121000 thank you all guys ,I'd appreciate your help after fix command, my program can work now.
Hi @phoboslab. I really appreciate the JSMpeg library.
I have been working for a month with FFMPEG and JSMpeg to stream an IP Camera, and I already have it working translating from RTSP to HTTP (as the WebSocket example).
I used Wireshark to monitor each part of the system (Camera to Server, and Server to Browser) and I realized that I have many retransmissions. This is bad for the solution that I am trying to do because the IP cameras are using 4G internet and it is not unlimited. So I am trying to use UDP instead of HTTP. My HTTP command is:
ffmpeg -i rtsp://<user>:<pass>@<camera_ip>:554 -f mpegts -codec:v mpeg1video -r 20 -codec:a mp2 -ar 44100 http://<server_ip>:8081/<stream_secret>
Everytime that I use the HTTP it works fantastic. But when there start to be many TCP retransmissions the video starts to have several delays.
So, I added an UDP server in the web-socket-relay.js
var dgram = require('dgram');
var udp_server = dgram.createSocket('udp4');
udp_server.on('listening', function () {
var address = udp_server.address();
console.log('UDP Server listening');
});
udp_server.on('message', function (message, remote) {
socketServer.broadcast(message);
});
udp_server.bind(8083);
Now the command is:
ffmpeg -i rtsp://<user>:<pass>@<camera_ip>:554 -f mpegts -codec:v mpeg1video -r 20 -codec:a mp2 -ar 44100 udp://<server_ip>:<udp_port>
When I try the UDP solution with my internet, the UDP solution works. But when I try the 4G internet, the video freeze. In the console I got "JSMpeg: Possible garbage data. Skipping", and later Chrome crashes.
Do you have any idea what could be happening?
@jvanegas Well, in theory, JSMpeg should be somewhat resilient to missing data - it should just synchronize to the next MPEG-TS packet. I have never really tried that, though. Out-of-order data could be more problematic. JSMpeg doesn't verify the correct packet order, nor does it skip over older packets that arrive after newer ones.
Can you record the raw, incoming UDP stream on the server, so that we have a test case? I can't promise you to look into it any time soon, though.
@phoboslab Thanks for your response.
I created a text file with the hex data that arrived at the server. I also saved a .ts file if you believe it is useful.
Let me know if something else is needed.
Thanks. 1493388741337.txt
hey guys i need your help. i want to use mpg so to work this out. im gonna use this script right? mpeg1.js? @phoboslab
or do i need other scripts just to work out the mpg file i need to play?
<script src="js/jsmpeg.min.js"></script>
this is my code <div class="jsmpeg" data-url="http://localhost:8080/mind-blown.mpg" data-loop="true" data-autoplay="true"></div>
I am not sure what i am doing. please guide me @phoboslab
@pixelstar2017 If you want to use JSMpeg and you are not going to change anything in their code, you only need the jsmpeg.min.js file. You do not need to add all the files.
@jvanegas great. thanks. it worked right now.
help!
ffmpeg -i rtsp://192.168.1.10:554/user=admin\&password=\&channel=1\&stream=0.sdp?real_stream -f mpegts -codec:v mpeg1video http://localhost:10021
all seems right !! but just no video!!!
@wait121000 thanks .The perfect solution to a problem that has plagued me for a long time.
WebGL: INVALID_OPERATION: texImage2D: type UNSIGNED_BYTE but ArrayBufferView not Uint8Array
JSMpeg: Possible garbage data. Skipping.
what is this mean???!!!
i use the .mpg video.