FFmpeg output to MacOSX screen? - macos

How do I route ffmpeg output to the screen on MacOSX?
If I type:
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay output.mp4
The output file contains the input file with the logo overlayed on top of it.
If I type:
ffplay -i input.mp4 -i logo.png -filter_complex overlay
Then it throws the error:
Argument 'logo.png' provided as input filename, but 'input.mp4' was already specified.
...but typing:
ffplay -filters
displays a list of filters including:
T.C overlay VV->V Overlay a video source on top of the input.
Clearly, I'm missing something obvious.
How do I route ffmpeg output to the screen, and where can I find a list of which filters and options work in ffmpeg but not in ffplay?

With lots of help from Mortiz and Carl on the ffmpeg-user mailing list, I have an incantation that works in both ffmpeg and ffplay:
ffplay -i input.mp4 -vf movie=logo.png,[in]overlay
and:
ffmpeg -i input.mp4 -vf movie=logo.png,[in]overlay test.mp4

Related

FFMPEG: using filters for adding transparent watermark

how can i combine these two lines of code for adding transparent watermark (with Dynamic size)
ffmpeg -i 1.gif -i logo.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.5[logo];[0][logo]overlay=(W-w)/2:H-h-5" -c:a copy output.gif
ffmpeg -i 1.gif -i logo.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=(W-w)/2:H-h-5" -c:a copy output.gif
i have tried the following code:
ffmpeg -i 1.gif -i logo.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[1]format=rgba,colorchannelmixer=aa=0.5[logo];[0][logo]overlay=(W-w)/2:H-h-5" -c:a copy output.gif
i got the following Error:
Filter scale2ref has an unconnected output
Outputs of every filter must be connected to something, and your [video] output pad of scale2ref is not, hence the error.
You need to feed [video] instead of [0] to the overlay filter:
You need to make sure all the filter input & output pads are connected. In your case, format and overlay need to use the output of scale2ref instead of reusing the input streams:
ffmpeg -i 1.gif -i logo.png \
-filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo1][video];\
[logo1]format=rgba,colorchannelmixer=aa=0.5[logo];\
[video][logo]overlay=(W-w)/2:H-h-5" \
-c:a copy output.gif
[Edit: fixed other labeling issues]

How do I generate a color screen for the duration of an MP3 in ffmpeg?

I have successfully generated a blue screen to add to an mp3. But, I have always needed to include the length of the clip to match the mp3. When I don't include a timecode it continues to generate footage until I cancel the command.
ffmpeg -f lavfi -i color=blue:s=1920x1080 -i input.mp3 -t 00:02:08 output.mp4
How do I specify that I only want color generated during the length of the mp3 that I am adding?
ffmpeg -i <.jpg> -i <.mp3>
This worked too but I don't want to rely on a jpeg file.
Use -shortest:
ffmpeg -f lavfi -i color=blue:s=1920x1080 -i input.mp3 -shortest output.mp4

Create muted video and black screen video with FFmpeg

I'm trying to use FFmpeg to generate the following from a local mp4 file:
A copy of the original video with no audio
A copy of the original video with audio but without visuals (a black screen instead). This file also needs to be in mp4 format.
After reading through the documentation I am struggling to get the terminal commands right. To remove the audio I have tried this command without any success:
ffmpeg -i file.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy
Could anyone guide me towards how to accomplish this?
Create black video and silent audio
Use the color and anullsrc filters. Example to make 10 second output, 1280x720, 25 frame rate, stereo audio, 44100 sample rate:
ffmpeg -f lavfi -i color=size=1280x720:rate=25:color=black -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 10 output.mp4
Remove audio
Only keep video:
ffmpeg -i input.mp4 -map 0:v -c copy output.mp4
Keep everything except audio:
ffmpeg -i input.mp4 -map 0 -map -0:a -c copy output.mp4
See FFmpeg Wiki: Map for more info on -map.
Make video black but keep the audio
Using the drawbox filter.
ffmpeg -i input.mp4 -vf drawbox=color=black:t=fill -c:a copy output.mp4
Generate silent audio
See How to add a new audio (not mixing) into a video using ffmpeg? and refer to the anullsrc example.
To remove the audio you can use this:
ffmpeg -i file.mp4 -c copy -an file-nosound.mp4
notice the -an option
-an (output)
Disable audio recording.
To keep audio but "replace" the video with a black screen, you could do this:
ffmpeg -i file.mp4 -i image.png -filter_complex overlay out.mp4
image.png is a black wallpaper that is placed on top of the video, but there should be better ways of full removing the frames, you could either extract the audio and later create a new video with the audio as a background

how to output gif with same size as input video

I am following How do I convert a video to GIF using ffmpeg, with reasonable quality?
It gives example:
ffmpeg -i input.flv -i palette.png -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
However I want the gif output to be the same size as video and not 320 as specified here so I removed scale=320:-1 so I have
ffmpeg -i input.flv -i palette.png -filter_complex "fps=10,flags=lanczos[x];[x][1:v]paletteuse" output.gif
When I run that I get:
No such filter: 'flags' Error initializing complex filters.
If I remove:
-filter_complex "fps=10,flags=lanczos[x];[x][1:v]paletteuse"
Then it works but quality of the video is bad. So it seems that I must use a scale for those palette flags to work, how can I get ffmpeg to output gif same size as input video?
Omit the scale filter
By default the output uses the same width and height as the input. The :flags=lanczos was part of the scale filter. So your command will look like:
ffmpeg -i in.flv -i palette.png -filter_complex "fps=10[x];[x][1:v]paletteuse" out.gif
I have figured it out:
ffmpeg -i video.mkv -y -i palette.png -filter_complex "fps=10,scale=iw:ih:flags=lanczos[x];[x][1:v]paletteuse" output_mkv.gif
scale=iw:ih does the trick, same size as input video

Ffmpeg video overlay

I am trying to create a video output from multiple video cameras.
Following the example given here Presenting more than 2 videos using FFmpeg
and other similar examples.
but Im getting the error
Output pad "default" for the filter "src" of type "buffer" not connected to any destination
when i run
ffmpeg -i /dev/video1 -i /dev/video0 -filter_complex "[0:0]pad=iw*2:ih[a];[a][1:0]overlay=w[b];[b][2:0]overlay=w:h" -shortest output.mp4
Im not really sure what this means or how to fix it.
Any help would be greatly appreciated!
Thanks.
When using the "padding" option, you have to specify which is the size of the output image and where you want to put the input image
[0:0]pad=iw*2:ih:0:0
tested under windows 7 with file of same size
ffmpeg -i out.avi -i out.avi -filter_complex "[0:0]pad=iw*2:ih:0:0[a];[a][1:0]overlay=w" -shortest output.mp4
and with WebCam Cap (vfwcap) and a still picture (as i have only o=1 WebCam). BTW you can see how to scale one the source to fit in the target (just in case your source have different resolution)
ffmpeg -y -f vfwcap -r 10 -i 0 -loop 1 -i photo.jpg -filter_complex "[0:0]pad=iw*2:ih:0:0[a];[1:0]scale=640:480[b];[a][b]overlay=w" -shortest output.mp4
under Linux:
ffmpeg -i /dev/video1 -i /dev/video0 -filter_complex "[0:0]pad=iw*2:ih:0:0[[a];a][1:0]overlay=w" -shortest output.mp4
if it doesn't work test a simple record of video 1 and after of video 0 and check their properties (type, resolution, fps).
ffmpeg -i /dev/video1 -shortest output1.mp4
ffmpeg -I output1.mp4
If you still have issue, update your question with ffmpeg console output (as text) for video and video 0 capture and also of the call with the overlay

Resources