FFmpeg streaming rtmp muliple streams - ffmpeg

I have a mpeg file with two video streams stream
#0:0[0x27] yuv420p 352X288
and
#0:1[0x29] yuv420p 640X480
I am trying to read the file and send it out rtmp
ffmpeg -stream_loop -1 -i myvideofile.mpg -f mpegts udp://localhost:123456
To verify the stream is streaming I use ffplay
ffplay udp://localhost:123456
I get the video, but it is only one of the two streams I am expecting. the 640x480
Is there something that I need to do to make both streams get sent?

To remap all streams you have to pass -map 0.
ffmpeg -stream_loop -1 -i myvideofile.mpg -map 0 -f mpegts udp://localhost:123456

Related

FFmpeg efficient capture from rtsp ipcamera

I need to capture an audio/video rtsp stream uncompressed in a file from ipcamera. Audio (pcm_alaw) and video (h264) must be synchronized. It is necessary that the file does not get corrupted if the camera loses the connection for a few moments (mp4).
At the moment I use the command below, but the ts codec does not support pcm_alaw and therefore the audio is not heard:
ffmpeg -stimeout 2000000 -rtsp_transport tcp -i rtsp://admin:1234#192.168.5.22/h264 -c:v copy -c:a copy -f mpegts -y main.ts
I use the mpegts codec because I need to check the duration of the capture in real time with the command:
ffprobe -i /home/pi/NAS/main.mov -show_entries format=duration -v quiet -of csv="p=0"
If i use mkv or avi its output would be:
N/A
The verification of the duration is important because I capture files of about 3 hours and at my choice I perform some data while the capture is in progress. I prefer not to compress the audio because I have often noticed some asynchrony with respect to the video when cutting.
Thank you.
Instead of -c:a copy you can use -c:a aac or -c:a mp3 to convert the audio stream before you save it.
MPEG-TS h264 is only compatible with mp3 or aac (source).

Command to stream MPEG-1 video

I'm trying to stream MPEG-1 video over FFMPEG with
ffmpeg -i "out.ts" -f flv -listen 1 -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app
The out.ts file is a MPEG-1 video encoded with
ffmpeg -i out.avi -f mpegts -codec:v mpeg1video -b:v 1500k -r 30 -bf 0 -codec:a mp2 -b 0 -q 5 -t 1 out.ts
When I try to open the stream with VLC: rtmp://localhost:1935/live/app media is not playing. What's the command to stream MPEG-1 video over FFMPEG?
RTMP does not have support for mpeg1 video or mpeg2 audio. You can see the complete list if supported code in the fly specification under the VIDEODATA header.
https://www.adobe.com/content/dam/acom/en/devnet/flv/video_file_format_spec_v10.pdf
To stream MPEG-1 video using ffmpeg:
ffmpeg -re -y -i out.ts -an -f rtp_mpegts rtp://127.0.0.1:1234
Credit to: https://ffmpeg.org/pipermail/ffmpeg-user/2015-October/028879.html
(Although the source video is 720p, the stream in VLC looks like 360p and no audio is streamed, any idea would be appreciated)

ffmpeg RTP audio multicast stream choppy

I'm trying to stream .wav audio files via RTP multicast. I'm using the following command:
ffmpeg -re -i Melody_file.wav -f rtp rtp://224.0.1.211:5001
It successfully initiates the stream. However, the audio comes out very choppy. Any ideas how I can make the audio stream clean? I do not need any video at all. Below is a screenshot of my output:
Here's some examples expanding upon the useful comments between #Ralf and #Ahmed about setting asetnsamples and aresample, and also those mentioned in the Snom wiki. Basically one can get smoother multicast transmission/playback using these approaches for G711/mulaw audio:
ffmpeg -re -i Melody_file.wav -filter_complex 'aresample=8000,asetnsamples=n=160' -acodec pcm_mulaw -ac 1 -f rtp rtp://224.0.1.211:5001
Or using higher quality G722 audio codec:
ffmpeg -re -i Melody_file.wav -filter_complex 'aresample=16000,asetnsamples=n=160' -acodec g722 -ac 1 -f rtp rtp://224.0.1.211:5001

Combine video segments and stream with ffmpeg

FFmpeg can save a video stream to disc as video segments with the following command (source)
ffmpeg -rtsp_transport tcp -reorder_queue_size 8000 -i rtsp://192.168.10.203:554/11 -r 25 -vcodec copy -acodec copy -map 0 -f segment -segment_time 60 -reset_timestamps 1 -segment_format avi "/vidcam2cont/ffmpeg_capture-%03d.avi"
Is there a way to achieve the reverse of this (using FFmpeg or anything else), where I want to merge the video segments and get a continuous video stream?

Extracting a eia_608 stream from a mpeg2 transport stream with FFMPEG

I'm trying to convert a MPEG2 Transport Stream to a MP4 stream. The video and audio are fine, but I can't seem to figure out how to tell ffmpeg to extract the eia_608 stream from the video and place it in a stream for the mp4 or mov. I've tried a straight copy as shown below.
ffmpeg -f mpegts -i tsfile3.ts -codec:v copy -fflags genpts -bsf:a aac_adtstoasc -codec:a copy -codec:s copy -f mov tsfile3a.mp4
Has anyone done this? If so, could you help with the syntax? Thanks.
Finally figured this out. Just be aware it appears to only work with mpegvideo and not h264. The syntax is as follows:
ffmpeg -i Closedcaption_rollup.ts -f lavfi -i "movie=Closedcaption_rollup.ts[out+subcc]" -map 0:0 -map 0:1 -map 1:1 -c:s mov_text test_out.mp4
This is using the ffmpeg fate test clip.
The caveats are:
Appears to only work with mpegvideo. I can't get it to work with h264
Doesn't output eia_608 type in the file, it converts it to mov_text.

Resources