I'm trying to stream my webcam with FFmpeg to my Red5 server using RTMP. I've done this successfully using FLV format with the following line:
ffmpeg -f video4linux2 -i /dev/video0 -f flv rtmp://localhost/live/livestream
I'm new to FFmpeg and live streaming, and I've tried to stream using H.264/MPEG-4. But my knowledge is a bit limited with the FFmpeg options (which I did find here: http://man.cx/ffmpeg%281%29).
So, my questions would be:
How can I use H.264/MPEG-4 to stream to my Red5 server?
What are the options to stream audio as well?
And one final issue is:
I'm having a delay of about 5 seconds when I play the content with JWPlayer in Mozilla Firefox (on Ubuntu). Can you please help me out to solve this problem? Any suggestions why this might be?
Many thanks
There is no need to use ffmpeg for streaming H.264/MPEG-4 files because red5 has build in support for this. Using ffmpeg will only put an unnecessary load on your CPU usage. Red5 will recognize the file type automatically, you only have to specify the mp4 file in your JWPlayer.
About the delay, as far as I know JWPlayer has a buffer of 3 seconds by default. You can try to lower this (property bufferlength or something like that). And maybe JWPlayer has a "live" property as well to stream with minimal delay, but I am not sure about that. Removing ffmpeg will probably speed up the process also.
Related
In Ant Media Server after recording stream on Windows using API, the VOD plays fine on Windows. But when playing the same VOD on macOS using Quick Time Player v10.5, the video freezes after some seconds and audio continues.
VODs playback with Quick Time Player is fine for recordings made on macOS.
How can I overcome this and is it an expected behaviour!
TL;DR;
Transcode the video with ffmpeg after recording or add at least one adaptive bitrate on the Ant Media Server side.
This is a known issue in quick time player. This problem also exists for MacOS/iOS and Safari. Let me tell the cause of the problem and offer a solution.
Problem:
The resolution may be changed in WebRTC sessions according to the network conditions so that the resolution of the recording is being changed to lower or higher resolution.
Most of the players and browsers can handle that. On the other hand, Safari and Quick Time Player cannot handle resolution changes and the problem you mention appear.
Solution:
Transcoding the stream into a specific resolution with ffmpeg or using adaptive bitrate on the server side resolves this issue. Typical ffmpeg command is sufficient
ffmpeg -i INPUT.mp4 OUTPUT.mp4
A. Oguz antmedia.io
My legacy software breaks after migrating it to Windows 10 since WMV Encoder 9 SDK isn't longer supported.
I've tried other approaches, and I can generate the ASF file I need using FFmpeg.
I only need mux audio and video into ASF container, and this command do it :
ffmpeg -y -i audio.mp3 -i video.asf -vcodec copy -acodec copy output.asf
It works well, and the file can be played using VLC or Windows Media Player.
But it can't be played by DirectShow. I've got a ASF_E_INVALIDHEADER error when I set as the source of WMAsfReader. Any idea how can I generate a valid ASF file for the WMAsfReader?
Thnks!
You might be unable to use legacy SDK, but current Windows APIs to produce ASF files (with DirectShow and Media Foundation) are in good standing in Windows 10:
DirectShow: WM ASF Writer Filter
Media Foundation: ASF Support in Media Foundation, ASF Media Sinks
This content should be acceptable for WMAsfReader. FFmpeg has always generated "almost good" output, so it was acceptable for long time. However checks for format consistency in OS components were getting stricter and stricter over time and once in a while FFmpeg content is not longer considered valid.
ffmpeg has all kinds of options in it to record video off of a webcam, transcode video, send video up to streaming servers. Is there a way to loop over a file and make it look like a webcam?
I found this for Linux:
https://gist.github.com/zburgermeiszter/42b651a11f17578d9787
I've search around a lot to try to find something for Windows, but have not yet found anything.
No, that's not part of FFmpeg so you'll need to create this "virtual video device" yourself. See e.g. How to create virtual webcam in Windows 10?.
I've successfully gotten ffmpeg to stream live video from the built-in webcam on my macbook pro to my rtmp server but I cannot figure out how to get it to also send audio from the built-in microphone.
I've tried both the qtkit device as well as the avfoundation. It appears that neither support an audio stream.
Does ffmpeg support audio capture on a mac?
All of the examples I can find only show audio capture working with the DirectShow device.
Turns out it isn't supported at this time. With the help of some of the ffmpeg-devel folks I was able to get it working with a patch. I've applied the patch to a fork available here:
https://github.com/realrunner/FFmpeg
I am streaming video and audio from my web cam/microphone over UDP. When I view the stream (even on the same machine) there is a delay of about 4 seconds. I have tried setting the UDP Cache setting to 0, or 1 but it doesn't seem to help. I have tried reducing the video and audio bit-rates, using mono sound and reducing the sample-rate all to no avail.
Does anyone have any ideas how I could reduce the delay, to something better suited to for a video conference, i.e < 1 second?
Is there a setting I can apply to the viewer/streamer that can help?
Thanks,
Marc
If you are using rtsp protocol to stream to video/audio, you can adjust the delay at
tools->preferences->all->input/codecs->demuxers->RTP/RTSP->caching value
tools->preferences->all->input/codecs->demuxers->RTP->RTP de-jitter buffer length
Try this.
#!/bin/sh
ETH=eth0
cvlc --miface=$ETH v4l2:///dev/video0 :input-slave=alsa://hw:0,0 :sout=#transcode{vcodec=h264,venc=x264{preset=ultrafast,tune=zerolatency,intra-refresh,lookahead=10,keyint=15},scale=auto,acodec=mpga,ab=128}:rtp{dst=224.10.0.1,port=5004,mux=ts} :sout-keep >/dev/null 2>/dev/null &
vlc1=$!
vlc --miface=$ETH rtp://224.10.0.1 >/dev/null 2>/dev/null &
vlc2=$!
wait $vlc2
kill -9 $vlc1
I've 2 seconds delay with 720p webcam, it produce about 2.5Mbit/s trafic and load for one core ~30%.
In my study of VLC streaming with webcam, I got 2-3 seconds delay for UDP multicast stream transcoded with WMV/ASF container + WMV2 codec from Dell's Creative Integrated Webcam with cif video size.
If using MP4/MOV container + H.264 codec, I got twice the delay of the former with the same settings in bitrate, fps and scale.
I disabled audio in both streaming settings since I wasn't interested in it.
I did the study with two VLC versions:
VLC 1.1.11 (latest Windows stable release)
VLC 2.1.0 (latest nightly build version)
With the first version, I could transcode and stream from the webcam, but it could not playback the stream properly (it just gave a blackened video stream)
With the second version, it worked well for transcoding, streaming and playback.
This study was done on:
Intel Core 2 Duo T7250
4GB DDR2-667 SDRAM
SATA 7200 RPM HDD
GeForce 8400M GS 128MB GDDR3 (+ 128MB shared memory = 256MB video memory)
Windows XP Pro SP3