Command to stream MPEG-1 video - ffmpeg

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)

Related

FFmpeg streaming rtmp muliple streams

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

How to push mp3 to srs with ffmpeg?

I push my MP3 file like this:
ffmpeg.exe -re -stream_loop -1 -i ./ring.mp3 -c copy -f mp3 rtmp://${domain}/live/test
But the PotPlayer couldn't accept it well.
For FFmpeg, the format you should use flv instead of mp3, like this:
ffmpeg.exe -re -stream_loop -1 -i ./ring.mp3 -c copy \
-f flv rtmp://${domain}/live/test
# Or transcode the sample file of SRS
ffmpeg -re -i srs/trunk/doc/source.flv -vn -c:a libmp3lame \
-f flv rtmp://localhost/live/test
Then play by ffplay:
ffplay rtmp://localhost/live/test
Recommend to use AAC instead MP3, because AAC is more widely used, so you could transcode to aac by:
ffmpeg -f flv -i rtmp://localhost/live/livestream -c:v copy -c:a aac \
-f flv -y rtmp://localhost/live/test2
Note that WebRTC use opus as audio codec.

FFmpeg create muted audio file from video without audio

I have a webm file with only the video track. I would like to know if is it possible to create a new file with an only muted audio track of the same duration as the video file. Let's say that we have a webm vp8 and I want to create another file with the same duration with a muted AAC track.
Yes, using pipes, like this.
ffmpeg -an -i in.webm -f lavfi -i anullsrc -c:v copy -c:a aac -shortest -fflags +shortest -max_interleave_delta 200M -f nut - | ffmpeg -f nut -i - -vn -c copy silent.m4a

Convert x265 Video to x264 and copy all audio tracks and subtitles

i am converting x265 video having two audio streams and sutitles too, I am using this command but it create output file without video stream and with one audio stream and one sutitle, so what i am missing here
!ffmpeg -ss 00:03:00 -i "input file x265.mkv" -t 00:00:50 -c:v libx264 -crf 18 -map 0:a -map 0:s -c copy "output file x264.mkv"
You only told it to copy audio and subtitles. Assuming you want all video, audio, and subtitle streams use:
ffmpeg -ss 00:03:00 -i "input file x265.mkv" -t 00:00:50 -map 0 -c copy -c:v libx264 -crf 18 "output file x264.mkv"
-map 0 selects all streams from input file x265.mkv.
-c copy sets stream copy mode for all selected streams.
-c:v libx264 overrides -c copy for all video streams, and encodes all video with libx264.
Result: Stream copy all stream types except video. Encode video to H.264 using encoder libx264.
See FFmpeg Wiki: Map.

A/V out of sync when using ffmpeg from mpeg-ts to dash

I'm using ffmpeg in order to convert MPEG-TS stream to MPEG-DASH.
The mpeg-ts is h264 and aac_latm.
Therefore I don't need to reencode the video.
The command I use:
ffmpeg -i http://10.0.0.211:55555/Ch%2011%20Kan -strict -2 -c:v copy -window_size 10 -extra_window_size 10 -use_template 1 -use_timeline 1 -f dash kan.mpd
I'm copying the video codec by using -c:v copy and the audio codec is default to aac.
That way I get DASH stream BUT the audio/video is out of sync!
How can I fix it?
Notes:
If I reencode both audio and video like:
ffmpeg -i http://10.0.0.211:55555/Ch%2011%20Kan -strict -2 -window_size 10 -extra_window_size 10 -use_template 1 -use_timeline 1 -f dash kan.mpd
Then the audio/video is synced perfectly.
But I do not want to reencode the video for nothing as I mentioned the video is already h264. (directly impact to performance)
If I convert the MPEG-TS stream to mp4 file like:
ffmpeg -i http://10.0.0.211:55555/Ch%2011%20Kan -strict -2 -c:v copy kan.mp4
Then the audio/video is synced perfectly.

Resources