i found a couple of threads on stackoverflow that allow me to create a dummy mov file for picture:
ffmpeg -f lavfi -i color=c=black:s=640x480 -c:v prores_ks -profile:v 3 -tune stillimage -pix_fmt yuv422p10 -t 10 output_proreshq.mov
the above creates a 10 second, picture-only file.
this:
ffmpeg -f lavfi -i anullsrc=channel_layout=5.1:sample_rate=48000 -t 10 output.wav
creates a 6 channel wav file.
i haven't been able to figure out how to combine these two commands to create a file with blank picture and six channels of blank audio. can someone show me how to get this done? thanks!
Combined command is:
ffmpeg -f lavfi -i color=c=black:s=640x480 -f lavfi -i anullsrc=channel_layout=5.1:sample_rate=48000 -c:v prores_ks -profile:v 3 -pix_fmt yuv422p10 -c:a pcm_s16le -t 10 output_proreshq.mov
-tune stillimage is for libx264 only and is being ignored in your command so I removed it.
As for your duration queries, all of the simplified examples below will have a 10 second duration:
ffmpeg -f lavfi -i color -f lavfi -i anullsrc -t 10 output.mov
ffmpeg -f lavfi -i color=d=10 -f lavfi -i anullsrc -shortest output.mov
ffmpeg -f lavfi -i color -t 10 -f lavfi -i anullsrc -shortest output.mov
ffmpeg -t 10 -f lavfi -i color -t 10 -f lavfi -i anullsrc output.mov
ffmpeg -f lavfi -i color,trim=duration=10 -f lavfi -i anullsrc,atrim=duration=10 output.mov
ffmpeg -f lavfi -i color,trim=duration=10 -f lavfi -i anullsrc -shortest output.mov
Use whatever method you prefer.
Related
I need to combine this 2 ffmpeg commands:
"-i videoFile.mp4 -c:a copy -c:v libx264 -vf pad=$length:height=$length:x=-1:y=-1:color=#195766 resultFile"
and
"-i videoFile.mp4 -i waterMark.png -filter_complex 'overlay=10:main_h-overlay_h-10' resultFile.mp4"
Is it possible? How result command will look like?
I hope I have got it right...
The combined command is:
ffmpeg -y -i videoFile.mp4 -i waterMark.png -c:a copy -c:v libx264 -filter_complex "[0:v]pad=384:height=216:x=-1:y=-1:color=#195766[t];[t][1:v]overlay=10:main_h-overlay_h-10[v]" -map "[v]" -map 0:a resultFile.mp4
For mobile FFmpeg on android (according to OP's comment):
"-y -i ${videoFile.absolutePath} -i $waterMarkPath -c:a copy -c:v libx264 -filter_complex pad=$length:height=$length:x=-1:y=-1:color=#195766[t];[t][1:v]overlay=10:main_h-overlay_h-10[v] -map [v] -map 0:a ${resultFile.absolutePath}"
I used the following post as reference: Create video with 5 images with fadeIn/out effect in ffmpeg.
Testing:
Creating a sample video file (with audio):
ffmpeg -y -r 25 -f lavfi -i testsrc=size=192x108:rate=30 -f lavfi -i sine=frequency=400 -f lavfi -i sine=frequency=1000 -filter_complex amerge -vcodec libx265 -crf 17 -pix_fmt yuv420p -acodec aac -ar 22050 -t 30 videoFile.mp4
Creating a sample PNG image file:
ffmpeg -y -f lavfi -i mandelbrot=rate=1:size=192x108 -t 1 waterMark.png
Executing the combined command:
ffmpeg -y -i videoFile.mp4 -i waterMark.png -c:a copy -c:v libx264 -filter_complex "[0:v]pad=$length:$length=216:x=-1:y=-1:color=#195766[t];[t][1:v]overlay=10:main_h-overlay_h-10[v]" -map "[v]" -map 0:a resultFile.mp4
Result (first frame of the output of the test):
Currently I am using three different commands to create three mp4s only to delete the two "temporary" videos using this code.
#ECHO OFF
ffmpeg -f lavfi -i color=size=1280x720:duration=5:rate=25:color=Black -vf "drawtext=fontfile='GothamRnd-Book.otf':line_spacing=15:fontsize=15:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text=Stack Exchange" "out1.mp4"
ffmpeg -i "out1.mp4" -i logo.png -filter_complex "overlay=x=10:y=10" "out2.mp4"
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i "out2.mp4" -c:v copy -c:a aac -shortest "out3.mp4"
del "out1.mp4"
del "out2.mp4"
pause
The nearest I have come is moving the anullsrc=channel_layout into the -filter_complex but that results in a long encode that I dont really understand what it is going because if I ctrl-c to cancel the batch still creates out3.mp4 correctly.
ffmpeg -f lavfi -i color=size=1280x720:duration=5:rate=25:color=Black -vf "drawtext=fontfile='GothamRnd-Book.otf':line_spacing=15:fontsize=15:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text=Stack Exchange" "out1.mp4"
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i "out1.mp4" -i logo.png -filter_complex "overlay=x=10:y=10" "out3.mp4"
It seems like this could be streamlined to not create the temporary files.
But maybe this is the only way to do this. Thank you for any assistance and sorry if the answer is obvious.
Rory
Use
ffmpeg -f lavfi -i color=s=1280x720:d=5:r=25:color=black -i logo.png -f lavfi -i anullsrc=cl=stereo:d=5:r=48000 -filter_complex "[0]drawtext=fontfile='GothamRnd-Book.otf':line_spacing=15:fontsize=15:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text=Stack Exchange[vid];[vid][1]overlay=x=10:y=10" -c:v libx264 -c:a aac "out3.mp4"
NOTE: The below ffmpeg command lines are just a pseudo lines, not 100% final.
From single source I need to stream 2 different udp:// stream.
And I need to overlay 2 different png images on each.
Base sample line:
ffmpeg -r 25 -f dshow -i "video=VideoCaptureDevice:audio=AudioCaptureDevice" -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1234?pkt_size=1316" -codec:v libx264 s:v 720x480 -codec:a libfaac -f mpegts "udp://224.1.1.1:1235?pkt_size=1316"
Now I need to overlay 2 separate images in each output.
I tried below lines and failed.
Overlay sample line what I tried:
ffmpeg -r 25 -f dshow -i "video=VideoCaptureDevice:audio=AudioCaptureDevice" -i "C:\Image1.png" -filter_complex "overlay=100:100" -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1234?pkt_size=1316" -i "C:\Image2.png" -filter_complex "overlay=500:100" -codec:v libx264 s:v 720x480 -codec:a libfaac -f mpegts "udp://224.1.1.1:1235?pkt_size=1316"
Use
ffmpeg -r 25 -f dshow -i "video=VideoCaptureDevice:audio=AudioCaptureDevice" -i "C:\Image1.png" -i "C:\Image2.png" -filter_complex "split[a][b];[a][1]overlay=100:100[v1];[b][2]overlay=500:100,scale=720:480[v2]" -map "[v1]" -map 0:a -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1234?pkt_size=1316" -map "[v2]" -map 0:a -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1235?pkt_size=1316"
I have 2 commands as listed below.
Add intro image to a video
ffmpeg -y -loop 1 -framerate 10 -t 3 -i intro.png -i video.mp4 -filter_complex "[0:0] [1:0] concat=n=2:v=1:a=0" -c:v libx264 -crf 23 videoWithIntro.mp4
Add watermark to video
ffmpeg -y -i video.mp4 -i watermark_color.png -filter_complex "overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2" videoWithWatermark.mp4
I was wondering is it possible to combine these into the 1 command?
Use
ffmpeg -y -loop 1 -framerate 10 -t 3 -i intro.png -i video.mp4 -i watermark_color.png -filter_complex "[0][1]concat=n=2:v=1:a=0[v];[v][2]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2" videoWithWatermark.mp4
I assume your videos don't have audio, else use
ffmpeg -y -loop 1 -framerate 10 -t 3 -i intro.png -i video.mp4 -i watermark_color.png -f lavfi -t 3 -i anullsrc -filter_complex "[0][1]concat=n=2:v=1:a=0[v];[v][2]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2;[3][1]concat=n=2:v=0:a=1" videoWithWatermark.mp4
The final command to get this working correctly is as follows
ffmpeg -y -loop 1 -framerate 25 -t 3 -i 1920x1080_intro.png -i DSC_0002.MOV -i watermark_color.png -report -an -filter_complex "[1][2]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2,setsar=1[v];[0]setsar=1[pre];[pre][v]concat=n=2:v=1:a=0" ../testing/videoWithIntroAndWatermark.mp4
I am using this command line to add a five second image on end of video:
ffmpeg -i "f:\output\input.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4
It works great, but sometimes I want to cut the video and then add the five seconds. So, make a 120 second video 110 seconds, then add the 5 second ending.
Possibly in one command line? I've tried to break it into two, by starting with cutting the video, but then I get an "Unable to parse option value "-1" pixel format" error if I try to re-encode the video I cut with ffmpeg using this:
ffmpeg -i f:\output\input.mov -vcodec copy -acodec copy -ss 00:00:00.000 -t 00:01:50.000 f:\output\output.mov
That output video will then give an error if I try to run the first command line against it.
All feedback appreciated on shortening a video, and then adding ending.
Cheers!
Ryan
Use
ffmpeg -t 110 -i "f:\output\input.mov"
-loop 1 -t 5 -i "f:\output\taff.jpg"
-f lavfi -t 5 -i anullsrc
-filter_complex "[0:v][0:a][1:v][2:a]concat=n=2:v=1:a=1[v][a]"
-c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4
With scale2ref, it should be
ffmpeg -t 110 -i "f:\output\input.mov"
-loop 1 -t 5 -i "f:\output\taff.jpg"
-f lavfi -t 5 -i anullsrc
-filter_complex "[1][0]scale2ref[2nd][ref];[ref][0:a][2nd][2:a]concat=n=2:v=1:a=1[v][a]"
-c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4
If the image has a different aspect ratio, use
ffmpeg -t 110 -i "f:\output\input.mov"
-loop 1 -t 5 -i "f:\output\taff.jpg"
-f lavfi -t 5 -i anullsrc
-filter_complex "[0]split[base][full];[base]trim=0:5,drawbox=t=fill[base];[1][base]scale2ref='if(lt(mdar,dar),oh*mdar/sar,iw)':'if(lt(mdar,dar),ih,ow*sar/mdar)'[2nd][base];[base][2nd]overlay='(W-w)/2':'(H-h)/2'[padded];[full][0:a][padded][2:a]concat=n=2:v=1:a=1[v][a]"
-c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4
This last command requires ffmpeg version >= 3.4