ffmpeg add video thumbnail only [duplicate] - ffmpeg

I am trying to find the proper ffmpeg command to add a .png or .jpg image to a .mp4 video as a thumbnail. The command will eventually automatically be executed by a C# program.
This is what I have so far:
# This does not work. It only removes the default thumbnail.
ffmpeg -i video.mp4 -i image.png -acodec copy -vcodec copy -map 0 -map 1:0 OUTPUT.mp4
Is what I want possible with ffmpeg? If so, please guide me in the right direction.

Using ffmpeg 4.0, released Apr 20 2018 or newer,
ffmpeg -i video.mp4 -i image.png -map 1 -map 0 -c copy -disposition:0 attached_pic out.mp4

As in version 4.2.2...See Section 5.4 in FFmpeg documentation
To add an embedded cover/thumbnail:
ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
Not all muxers support embedded thumbnails, and those who do, only support a few formats, like JPEG or PNG.

Related

FFMPEG attach thumbnail to first frame of the video

I want to attach/append an image (something like youtube) to first frame of the video, i tried this command :
ffmpeg -i video.mp4 -i image.png -map 1 -map 0 -c copy -disposition:0 attached_pic out.mp4
But it doesnt working, the first frame is not my custom image
my ffmpeg version:
ffmpeg version n4.4-80-gbf87bdd3f6-20210830 Copyright (c) 2000-2021 the FFmpeg developers
You will have to concatenate a frame to the beginning.
Re-encode audio in video.mp4. The audio is HE-AACv2, but you don't have a HE-AACv2 encoder. So it has to be changed to the more common AAC-LC to allow concatenation with the video generated from the image.
ffmpeg -i video.mp4 -c:v copy -c:a aac main.mp4
Make a video from image.png with silent filler audio. It has to have the same attributes as main.mp4.
ffmpeg -loop 1 -framerate 30 -i image.png -f lavfi -i anullsrc=r=48000 -frames:v 2 -c:v libx264 -vf format=yuv420p -video_track_timescale 30k -c:a aac image.mp4
-frames:v 2 is used instead of -frames:v 1 as required for the audio.
Make input.txt containing:
file 'image.mp4'
file 'main.mp4'
Concatenate:
ffmpeg -f concat -i input.txt -c copy output.mp4

replace a word in subtitle with ffmpeg

I want to use ffmpeg to replace all occurrences of a word in all subtitles of a video file with ffmpeg. All non-subtitles channels should be copied (not reencoded) and all formatting from the original subtitles should stay if possible.
example:
ffmpeg -i input.mkv -SUBTITLEFILER='old_word/new_word' output.mkv
I am using ubuntu 19.04 and bash (in case additional steps or dependencies would be required for this)
ffmpeg has no find/replace functionality for subtitles, but you can do this losslessly in 3 commands:
Extract the subtitles:
ffmpeg -i input.mkv -map 0:s:0 -c copy sub0.ass -map 0:s:1 -c copy sub1.ass -map 0:s:2 -c copy sub2.ass
I'm assuming your subtitles are SubStation Alpha (ASS/SSA) subtitles. Use the appropriate output name if they differ: such as .srt for SubRip (refer to ffmpeg -muxers).
Replace with sed:
sed -i 's/cat/dog/g' *.ass
Remux:
ffmpeg -i input.mkv -i sub0.ass -i sub1.ass -i sub2.ass -map 0 -map -0:s -map 1 -map 2 -map 3 -c copy -metadata:s:s:0 language=fas -metadata:s:s:1 language=eng -metadata:s:s:2 language=fin output.mkv
If you want to make a certain subtitle the default see the -disposition option as shown in ffmpeg set subtitles track as default.

How do I add a custom thumbnail to a .mp4 file using ffmpeg?

I am trying to find the proper ffmpeg command to add a .png or .jpg image to a .mp4 video as a thumbnail. The command will eventually automatically be executed by a C# program.
This is what I have so far:
# This does not work. It only removes the default thumbnail.
ffmpeg -i video.mp4 -i image.png -acodec copy -vcodec copy -map 0 -map 1:0 OUTPUT.mp4
Is what I want possible with ffmpeg? If so, please guide me in the right direction.
Using ffmpeg 4.0, released Apr 20 2018 or newer,
ffmpeg -i video.mp4 -i image.png -map 1 -map 0 -c copy -disposition:0 attached_pic out.mp4
As in version 4.2.2...See Section 5.4 in FFmpeg documentation
To add an embedded cover/thumbnail:
ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
Not all muxers support embedded thumbnails, and those who do, only support a few formats, like JPEG or PNG.

chromakey: ffmpeg green color video removal

I am using ffmpeg on Mac to remove green background of video and add other background as image it is converting properly the video but auido is missing. I am using below command.
Am I doing anything wrong here?
ffmpeg -i bg.jpg -i input.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mp4
I solved it my own.
ffmpeg -i bg.jpg -i input.mp4 -filter_complex "[1:v]chromakey=0x3BBD1E:0.1:0.2[ckout];[0:v][ckout]overlay[o]" -map [o] -map 1:a output.mp4
we need to add flags for audio.
Once a map switch is added, only mapped streams are included. Add -map 1:a? -c:a copy

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