ffmpeg play RTSP stream while recording - ffmpeg

I successfully record to a file a RTSP stream using ffmpeg with the following command:
ffmpeg -i "rtsp://1.1.1.1:554/user=admin&password=admin&channel=1&stream=1" -acodec copy -vcodec copy -movflags frag_keyframe+empty_moov -y http://www.example.com/rec/1.mp4
now I need to play video while ffmpeg is still writing to file. Even changing file format, is it possible?

Pipe a 2nd output to ffplay
ffmpeg -i "rtsp://1.1.1.1:554/user=admin&password=admin&channel=1&stream=1" -acodec copy -vcodec copy -movflags frag_keyframe+empty_moov -y http://www.example.com/rec/1.mp4 -c copy -f nut - | ffplay

Related

Ffmpeg command results in output contains no video stream error

I'm trying to execute the following command:
ffmpeg -hide_banner -loglevel warning -progress -i E:\TEMP\mtc\input\sample2.mp4 -acodec mp3 -vcodec libx265 -r 60 -vf "scale=2560:1440" -b:v 35000k -f matroska E:\TEMP\mtc\input\output\result.mkv
This results in error:
Output file #0 does not contain any stream
The input file exists and can be accessed by ffmpeg.
I'm working on Windows 10 with latest version of FFmpeg.
Fixed by adding - after -progress
ffmpeg -hide_banner -loglevel warning -progress - -i E:\TEMP\mtc\input\sample2.mp4 -acodec mp3 -vcodec libx265 -r 60 -vf "scale=2560:1440" -b:v 35000k -f matroska "E:\TEMP\mtc\input\output\result.mkv"

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

ffmpeg error when I make TS file

I use ffmpeg to make video from audio/image to mp4.
I want merge/concatenate two mp4 video.
I have this to make mp4 video:
ffmpeg -i "background.png" -i "audio.mp3" -y -r 30 -b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 "result.mp4"
This, it works!
To concatenate two mp4 video, I must pass by ts files.
ffmpeg -i "result.mp4" -codec copy -bsf:v hevc_mp4toannexb intermediate1.ts
But, I have this error:

ffmpeg rtmp and local file output

I have a trouble with ffmpeg
I receive a rtsp stream from a grabbing device (camera) and I stream-out it to rtmp (Youtube Live)
I want to have a copy of the stream in my computer so I write at the same time in a local file
I use this command :
ffmpeg -y -i 'RTSP_SOURCE' -c:v copy -c:a libvo_aacenc -map 0:v -bsf:v dump_extra -fflags +genpts -flags +global_header -movflags +faststart
-map_metadata 0 -metadata title= -f tee -filter_complex aevalsrc=0 '[f=mp4]/tmp/backup.mp4|[f=mpegts]/tmp/backup.ts|[f=flv]rtmp://a.rtmp.youtube.com/live2/STREAM_ID'
The problem is when I have some disconnections, ffmpeg exits and stop to recording
Is there any flag or option for telling to ffmpeg to continue recording in local files even there is not internet ?
Thank you very much for your help =)
You can try:
ffmpeg -f tee "[onfail=ignore] ...
More description is available here.

ffmpeg fails to transcode and give output to stream for -f mp4

I have been using ffmpeg for transcoding for quite some time.
Recently i have got a requirement where the ffmpeg output needs not be to a file but to stdout , which will be later captured and then sent back to callingurl.
I have got some prelimenary success with flv and avi , but got failure at mp4 when using -f flag.
here are my codes and need some serious look at the same
this works well with player :
ffmpeg -loglevel quiet -i cat_dog.mp4 -vbsf h264_mp4toannexb -vcodec copy \
-acodec copy -f mpegts -movflags frag_keyframe+empty_moov -re - 2>&1
this cannot be played by player :
ffmpeg -loglevel quiet -i cat_dog.mp4 -vbsf h264_mp4toannexb -vcodec copy \
-acodec copy -f MP4 -movflags frag_keyframe+empty_moov -re - 2>&1
As noted in the docs, the drawback to using -movflags is that it is "less compatible with other applications."
For flv or avi format, the -movflags option would be extraneous and ignored, but with mp4 it would take effect and potentially break compatibility.

Resources