How to produce Live video and audio streaming (not VoD) with ffmpeg? - audio

I want to produce a Live audio/video stream from local file.
I tried the following:
ffmpeg -re -thread_queue_size 4 -i source_video_file.ts -strict -2
-vcodec copy -an -f rtp rtp://localhost:10000 -acodec copy -vn -sdp_file saved_sdp_file -f rtp rtp://localhost:20000
and then:
ffplay saved_sdp_file
It seems to work fine, but it looks like a Video on Demand, cause I can replay this file with ffplay whenever I want.
But I need ffplay to show video/audio only during ffmpeg streaming instance is running (the first command above).
How do I achieve this?
Thanks!

This code works for live video streaming :
proc liveStreaming {} {
#ffmpeg command to capture live streaming in background
exec ffplay -f dshow -i video="Integrated Webcam" >& $logFile &
}
liveStreaming
Make use of fmmpeg using following code, this also works :
proc liveStreaming {} {
#ffmpeg command to capture live streaming
exec ffmpeg -f dshow -i video="Integrated Webcam" -f sdl2 -
}
liveStreaming
You can also make use of "sdl" if sdl2 doesn't work.

Related

ffmpeg split | merge video voice not sync

there are what i done:
download a full mp4 file.
due to it's watermark(0s-10s), i split the full video into 2 parts from 10second. the first part with watermark.
use ffmpeg delogo the first part.
merge the two video into a full again.
wget -O download.mp4
ffmpeg -i download.mp4 -vcodec copy -acodec copy -t 00:00:10 tmp1.mp4
ffmpeg -i download.mp4 -vcodec copy -acodec copy -ss 00:00:10 tmp2.mp4
ffmpeg -i tmp1.mp4 -vf "delogo=x=432:y=44:w=1060:h=108" -c:a copy tmp3.mp4
echo file tmp3.mp4 > mergelist.txt && echo file tmp2.mp4 >> mergelist.txt
ffmpeg -f concat -i mergelist.txt -c copy output.mp4
problem i faced:
in the last merged video, only one tmp part is fine, the other's video and voice not sync and play time more faster than before.
why i divide it, delogo(although only the first 10 seconds shows) full video more than 1h, re-encode takes much time, 10s part fine to me.
Have you tried this?
ffmpeg -i download.mp4 -vf "delogo=enable='lte(t,10)':x=432:y=44:w=1060:h=108" -c:a copy output.mp4
I'm assuming delogo filter is timeline editing enabled.

How merge audio in video with outside audio using ffmpeg?

I have 2 files:
video_orginal.ts,
sound_outside.wav
video_orginal have own sound track. I wants to turn down the volume of the sound from video_orginal and next merge sound_outside.wav with sound in video_orginal to finally get a video with mixed audio. Now I execute 4 working commands:
ffmpeg -i video_orginal.ts -map 0:a -c copy sound_from_video.wav -map 0:v -c copy video_clean.ts --exteract audio and video
ffmpeg -i sound_from_video.wav -filter:a "volume=0.3" sound_from_video_quiet.wav --quiet sound
ffmpeg -i sound_from_video_quiet.wav -i sound_outside.wav -filter_complex amix=inputs=2:duration=longest sound_mixed.wav --merge sounds
ffmpeg -i video_clean.ts -i sound_mixed.wav -c copy video_final.mkv --final merge video and sound
It is possible to execute only one command which will do all these steps with as little encoding as possible?

FFMPEG Audio streaming over RTP

I have a encoded Audio File(.aac file). I want to stream this file over RTP using FFMPEG without any transcoding. I am using following command :
ffmpeg -i input_file.aac -re -vn -acodec copy -strict experimental -f rtp rtp://225.0.0.1:1234
But above command gives below error:
AAC with no global headers is currently not supported
Can anyone point out any corrections ?
Thanks for the help.
The warning means it wants global headers to be set on your audio stream, like this:
ffmpeg -re -i input_file.aac -c:a copy -flags:a +global_headers -f rtp rtp://225.0.0.1:1234

ffmpeg - Have troubling syncing up audio and video together

I have a webcam and a separate mic. I want to record what is happening.
It almost works, however the audio seems to play quickly and parts missing while playing over the video.
This is the command I am currently using to get it partially working
ffmpeg -thread_queue_size 1024 -f alsa -ac 1 -i plughw:1,0 -f video4linux2 -thread_queue_size 1024 -re -s 1280x720 -i /dev/video0 -r 25 -f avi -q:a 2 -acodec libmp3lame -ab 96k out.mp4
I have tried other arguments, but unsure if it has to do with the formats I am using or incorrect parameter settings.
Also, the next part would be how to stream it. Everytime I try going through rtp it complains about multiple streams. I tried doing html as well, but didn't like the format. html html://localhost:50000/live_feed or rts rts://localhost:5000
edit:
I am running this on a rpi 3.

How to record audio stream using ffmpeg?

I have a problem using ffmpeg:
when i trying to record video+audio from my webcam in result i got only video stream, wthout audio at all.
I have tried different codecs and nothing..
Maybe, someone can give me advice?
ffmpeg -f dshow -i video="Logitech HD Webcam C270" -r 25 -s 800x600 -acodec libmp3lame -vcodec mpeg4 -b 3000k -f avi D:\1.avi
Btw: virtualdub grabs both well.
Thanks.
Assuming that you have installed the driver and codecs, use something like:
ffmpeg -f dshow -i video="Logitech HD Webcam C270" [path]out.mp4
A short explanation is given in capture a webcam input. For using DirectShow you have this examples.

Resources