Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Stream mp4 video via ffmpeg and rtmp using red5

Writer Sophia Terry

I need to stream mp4 video file via FFMPEG and stream the output to RED5 using RTMP protocol. I am using the following command to do this. It's encoding perfectly, but it does not play when I embed with jwplayer.

ffmpeg -i -acodec copy -vcodec copy -f flv rtmp://xxxxxxx/live/stream1

it's given the following result:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ' Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42isomavc1 creation_time : 2013-10-14 11:57:33 encoder : HandBrake 0.9.9 2013052900 Duration: 00:04:50.99, start: 0.000000, bitrate: 912 kb/s Stream #0.0(und): Video: h264 (Constrained Baseline), yuv420p, 1920x360 [PAR 847:1920 DAR 847:360], 795 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc Metadata: creation_time : 2013-10-14 11:57:33 Stream #0.1(und): Audio: aac, 11025 Hz, stereo, s16, 116 kb/s Metadata: creation_time : 2013-10-14 11:57:33
Output #0, flv, to 'rtmp://xxxxxxxxx/live/stream1': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42isomavc1 creation_time : 2013-10-14 11:57:33 encoder : Lavf53.21.1 Stream #0.0(und): Video: libx264, yuv420p, 1920x360 [PAR 847:1920 DAR 847:360], q=2-31, 795 kb/s, 1k tbn, 25 tbc Metadata: creation_time : 2013-10-14 11:57:33 Stream #0.1(und): Audio: libvo_aacenc, 11025 Hz, stereo, 116 kb/s Metadata: creation_time : 2013-10-14 11:57:33
Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1
Press ctrl-c to stop encoding
frame= 7266 fps=563 q=-1.0 Lsize= 32544kB time=290.64 bitrate= 917.3kbits/s
video:28220kB audio:4130kB global headers:0kB muxing overhead 0.601155%

After this i embed the RTMP url to my jwplayer

<script type='text/javascript'> jwplayer('mediaspace').setup({ 'flashplayer': ' 'stretching': 'exactfit', 'type': 'rtmp', 'file':'stream1', 'autostart': 'true', 'controlbar': 'bottom', 'streamer':'rtmp://xxxxxxxx/live/', 'width': '889', 'height': '410', }); </script>

After done this my player show the following error

Error loading stream
Could not connect to the server

how can i solve this and stream like live stream....???

1 Answer

Try this command. This is the command i usually use to stream a video file as a live stream

ffmpeg -re -i localFile.mp4 -c copy -f flv rtmp://server/live/streamName

The -re option tells FFmpeg to read the input file in realtime and not in the standard as-fast-as-possible manner. With -c copy (alias -acodec copy -vcodec copy ) I’m telling FFmpeg to copy the essences of the input file without transcoding, then to package them in an FLV container (-f flv) and send the final bitstream to an rtmp destination (rtmp://server/live/streamName).

The JWplayer source is as follows

<html>
<head><title>TEST PLAYER</title>
</head>
<body>
<script type="text/javascript" src="jwplayer.js"></script>
<div>Loading the player...</div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "rtmp://[ip-address]/live/streamname", });
</script>
</body>
</html>

Make sure the jwplayer.js and player.swf are in the correct locations.

13

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy