I'm trying to do a Web TV for my Radio but i'm stucked into this problem.
I'm trying to put a video loop (mp4) and trying to add into that loop the audio source of my radio who stream in m3u8 via Shoutcast.
Is possible to do this? I try to search everything on internet without any particular result.
Use -stream_loop:
ffmpeg -re -stream_loop -1 -i input.mp4 -i rtmp:// -map 0:v -map 1:a output
-re will play input.mp4 at realtime for streaming instead of as fast as possible.
Make sure you use FFmpeg 4.0 or newer or it will not work.
Related
I have configured RTMP to work with Nginx on ubuntu server following the guide from https://www.youtube.com/watch?v=Js1OlvRNsdI
I have tested the setup and everything is working perfectly to the end but then I have a folder containing movies and I want them to be streamed or played independently via a web player, for example, JWPlayer and I have failed to get that implementation online. Is there anyone with an idea of how to go about it?
Do you get a folder contains a set of movies, and you want to stream them as a stream, or each file as a stream?
Whatever you could do this by FFmpeg:
for file in $(ls movies/*.mp4); do
ffmpeg -re -i $file -c copy -f flv rtmp://server/app/stream
done
If want to stream each file as a stream, try to start multiple ffmpeg to do this.
I am looking for a way to capture my desktop. I came across something called direct Show but I cannot seem to get the syntax right on ffmpeg.
What can I do to capture the audio and video ?
I tried the syntax given in direct show site but not sure about it.
I just got mine to work and below i've given two examples of how you can do it and play it.
First one is
ffmpeg -f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec h264_nvenc -f mpegts udp://10.1.0.0:1234
This will stream it in the same network in the udp link
play it by typing ffplay udp://#10.1.0.0:1234.
You can change the udp link to what you want. Try different variation so it work. or even type this into VLC, which will also make it work.
2ND is
ffmpeg -f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec h264_nvenc output.mp4
You will get a mp4 file with the recording. Just press ctrl + c to stop the recording. Or if you know how long to record for add -t *seconds*. Replace seconds with actual number of seconds you want to record for. just add the -t before the output file name.
So, I've read all the articles here and unfortunately I can't seem to find the answers I'm looking for. I've gotten close, but the certain magic strings allude me.
I'm running hls live streaming (nginx) on ubuntu 17.10 server. In short, I can get the server running one video at a time fine with ffmpeg (with subtitles) using the following:
ffmpeg -re -i "1.mkv" -vcodec libx264 -vprofile baseline -g 30 -b:v 1000k -s 852x480 -acodec aac -strict -2 -b:a 192k -ac 2 -vf subtitles=1.srt -f flv rtmp://localhost:1935/show/stream
Though, I cannot find a solution to run a playlist using this method. It seems impossible, and when I try vlc via sout (internally, or externally) I reveive either buffer problems, or the aac experimental codec error:
[aac # 0xb162e900] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.
Example string that spits that error:
vlc "1.mkv" --sout '#transcode{soverlay,vb=1000,vcodec=h264,width=853,height=480,acodec=mp4a,ab=128,channels=2,samplerate=44100}:std{access=rtmp,mux=ffmpeg{mux=flv},dst=rtmp://localhost:1935/show/stream}'
Every other audio codec doesn't work with flv. I'm at a loss, I've tried almost every combination I could think of and digout just to get to this point. The best functioning out of them has been ffmpeg: it doesn't buffer video at all, plays smoothly, but just can't play a playlist. Whereas vlc can play a playlist but buffers, and has no sound (internally). I've tried aenc=ffmpeg{strict=-2}, batch pipes, etc, etc. I need help. Nothing works. Is there any solution? All I want is to run a playlist of 25 videos, all different variations, on a loop to the m3u8 for embedding.
A friend of mine mentioned he used bash scripts to have a seamless playlist like viewing feature. Hopefully that points you in the direction you need. I can try digging them up if you want to work together on this, coz I too am interested in finding out more about it.
I'm trying to create a fairly simple streaming server/site. Here's the current flow:
OBS streams to an RTMP URL
Nginx accepts the RTMP stream and uses exec-push to have FFmpeg pick up the stream and transcode it
FFmpeg transcodes the stream and outputs it to a JSMpeg application, which displays the stream on a webpage.
When I have my exec_push statement as follows, everything seems to work perfectly, except the browser says Possible garbage data. Skipping. on every frame it receives:
exec_push /usr/bin/ffmpeg -re -i rtmp://127.0.0.1:1935/$app/$name -f mpeg1video http://localhost:8080/supersecret;
This behavior is understandable, because JSMpeg must receive MPEG-TS data, not MPEG1 data. It sees the MPEG1 frames and thinks they're garbage.
So through some online research, I found this:
exec_push /usr/bin/ffmpeg -re -i rtmp://127.0.0.1:1935/$app/$name -c:v copy -c:a copy -f mpegts http://localhost:8080/supersecret;
Supposedly, this is supposed to transcode my RTMP stream into an MPEG-TS format, which should be compatible with JSMpeg.
However, with the second version of the command, my FFmpeg -> JSMpeg stream keeps connecting and disconnecting, connecting and disconnecting, and so on. This behavior is observed in terminal:
Stream Connected: ::1:40208
close
Stream Connected: ::1:40212
close
Stream Connected: ::1:40216
close
Stream Connected: ::1:40220
close
Stream Connected: ::1:40224
close
...
What would cause this? I am pretty certain the issue is in my exec_push command. OBS is perfectly content, which tells me that the stream is making it to the server, and if I do a push, I can do a test push to Ustream just fine, which tells me that Nginx is at least processing the stream with some reasonable degree of success.
Disclaimer: I have no idea what I'm talking about. Everything I know about FFmpeg and JSMpeg/Node is from snippets of code that I found online.
Answer credit goes to #Mulvya.
In the second exec_push command, the -c:v copy -c:a copy should not be there. By using that, there isn't any transcoding going on-- it's just a stream passthrough.
Removing the -c:v copy -c:a copy from the command and restarting Nginx yields a successful stream.
I'm currently doing a stream that is supposed to display correctly within Flowplayer.
First I send it to another PC via RTP. Here, I also checked with VLC that the codec etc. arrive correctly, which they do.
Now I want to expose this stream to Flowplayer as a file, so it can be displayed, via something I used in VLC:
http://localhost:8080/test.mp4
for example.
The full line I got is: ffmpeg -i input -f mp4 http://localhost:8080/test.mp4
However, no matter how I try to do this, I only get an input/output error. Is this only possible with something like ffserver or another?
What I think is this doesn't work because ffmpeg can't act as a server; on VLC it works since it can. (Though VLC ruins the codecs I set and it can't be read afterwards for some reason)
A (sort of) workaround I can use is saving the RTP stream to a file, and then letting flowplayer load it. This, however, only works once the file is not accessed anymore; I get a codec error otherwise.
To have FFmpeg act as an HTTP server, you need to pass the -listen 1 option. Additionally, -f mp4 will result in a non-fragmented MP4, which is not suitable for streaming. You can get a fragmented MP4 with -movflags frag_keyframe+empty_moov. A full working command line is:
ffmpeg -i input -listen 1 -f mp4 -movflags frag_keyframe+empty_moov http://localhost:8080
Other options you may find helpful are -re to limit the streaming speed to the input framerate, -stream_loop -1 to loop the input, and -c copy to avoid reencoding.
you need this command line
ffmpeg -f v4l2 -s 320x240 -r 25 -i /dev/video0 -f alsa -ac 1 -i hw:0 http://localhost:8090/feed1.ffm
make sure that your feed name ends with ".ffm" and if it's not the case, then add "-f ffm" before your feed URL, to manually specify the output format (because ffmpeg won't be able to figure it out automatically any more), like this "-f ffm http://localhost:8090/blah.bleh".