i want to join two ffmpeg command to gather - merge

This command is for add video in to video :
ffmpeg -i 1.mp4 -i over.mp4 -filter_complex
"[0:v]setpts=PTS-STARTPTS,scale=224x400[top];[1:v]setpts=PTS-STARTPTS,scale=100x44[bottom];[top][bottom]overlay=x=115:y=346:eof_action=pass;[0]volume=0.7[a1];[1]volume=0.3[a2];[a1][a2]amix=inputs=2[a]"
-acodec aac -vcodec libx264 -map 0:v -map "[a]" out.mp4
This command is for add water mark and username text in to video :
ffmpeg -i 1.mp4 -i watermark.png -filter_complex
"overlay=main_w-overlay_w-5:main_h-overlay_h-15,drawtext=fontfile=/path/to/font.ttf:text=‘#Unknown':
fontcolor=white: fontsize=10: box=1: boxcolor=black#0.0: boxborderw=5:
x=160: y=380" -codec:a copy output.mp4
If i want to execute this two command together then what i have to do OR how can i join this two command in one ?

Add the watermark and drawtext after the overlay.
ffmpeg -i 1.mp4 -i over.mp4 -i watermark.png -filter_complex "[0:v]setpts=PTS-STARTPTS,scale=224x400[top];[1:v]setpts=PTS-STARTPTS,scale=100x44[bottom];[top][bottom]overlay=x=115:y=346:eof_action=pass[vid];[vid][2]overlay=main_w-overlay_w-5:main_h-overlay_h-15,drawtext=fontfile=/path/to/font.ttf:text=‘#Unknown': fontcolor=white: fontsize=10: box=1: boxcolor=black#0.0: boxborderw=5: x=160: y=380;[0]volume=0.7[a1];[1]volume=0.3[a2];[a1][a2]amix=inputs=2" -acodec aac -vcodec libx264 out.mp4

Related

Flutter_ffmpeg: HOW to merge/mix/overlay multiple stickers with video?

I try to mix multiple URL of sticker with video .
command= "-y -i ${video.path} -i ${sticker.url} -filter_complex \"[1:v]scale=100:100[ovrl];[0:v][ovrl]overlay=${sticker.offset!.dx}:${sticker.offset!.dy}\" -frames:v 900 -codec:a copy -codec:v libx264 -max_muxing_queue_size 2048 -preset ultrafast $outputFilePath",

Flutter FFmpeg error option not found when using filter

I am very new to flutter and trying to use FFmpeg.
I want to use this filter
ffmpeg '-i input.mp4 -filter_complex "[0:v]crop=200:200:60:30,avgblur=10[fg];[0:v][fg]overlay=60:30[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy -movflags +faststart derpdogblur.mp4'
but it's not working when I am passing it as an argument.
My fluter code is this.
return _ffmpeg.renderHelper(args: [
'-i $src -filter_complex "[0:v]crop=200:200:60:30,avgblur=10[fg];[0:v][fg]overlay=60:30[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy -movflags +faststart $output'
], onStats: onStats, onError: onError, onAbort: onAbort);
But this filter is not working I am getting the option not found error.

Text streaming with RTMP?

I'm trying to get the output of a bash file to an RTMP stream.
I've successfully done it with FFMPEG using a filter, but the stream stops at Random intervals.
I assume that it's FFMPEG reading NULL data from the file.
I already write another file "output.txt", delete " input.txt" (which FFMPEG is reading) and rename "output.txt" to "input.txt".
Is there any way to do it more atomic in bash so it will work? Or is there a more elegant way to turn a changing text (max one time per second) to an FFMPEG stream?
Here is my current script:
ffmpeg -s 1920x1080 -f rawvideo -pix_fmt rgb24 -r 10 -i /dev/zero -f lavfi -i anullsrc -vcodec h264 -pix_fmt yuv420p -r 10 -b:v 2500k -qscale:v 3 -b:a 712000 -bufsize 512k -vf "drawtext=fontcolor=0xFFFFFF:fontsize=15:fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf:textfile=input.txt:x=0:y=0:reload=1" -f flv "rtmp://example.com/key"

Encoding 25mp video

I have a 25MP uncompressed video file of 100 frames.
I tried to encode it with ffmpeg and h264 encoder into a .mp4 file, but the encoding got stuck around the 10th frame.
This is the script:
avconv -y -i input.avi -c:v libx264 -preset medium -b:v 5000K -pass 1 -c:a libfdk_aac -b:a 5000K -f mp4 /dev/null && \
avconv -i input.avi -c:v libx264 -preset medium -b:v 5000K -pass 2 -c:a libfdk_aac -b:a 5000K output.mp4
I am running it on a jetson TK1 with nvidia gpu, is there any way to use an accelarating encoding in order to make the encoding possible?
Please, if you can, give me a sampler script of something that might work.
Right now, I dont care how much time the encoding take, as long as it will work.
Thank you in advance! :)

Cut parts of subtitle file using FFMPEG

I want to edit an input mp4 file with audio video subtitle streams, i can successfully cut video and audio streams by:
1- Convert each part to a new mp4 file
2- Convert mp4 files to mpg files
ffmpeg -i out00.mp4 -qscale:v 0 intermediate1.mpg
ffmpeg -i out01.mp4 -qscale:v 0 intermediate2.mpg
3- Merge mpg files
ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg
4- Convert the mpg file back to mp4
ffmpeg -i intermediate_all.mpg -f mp4 output.mp4
and i can extract the subtitle stream to srt file, but i can't cut parts of the subtitle file, do you have an idea how to do this?
Ok it works after long searching trip, here what i did:
1- Download latest FFMPEG from here (this was causing alot of problems for me).
2- Add the subtitle to the input files:
ffmpeg -i "input.mkv" -i subtitles.srt -c copy -c:s srt -metadata:s:s:1 language=eng -map 0 -map 1 -map_metadata 0 output.mkv
3- Cut the parts you need as you did normally ffmpeg will cut subtitle stream also
ffmpeg -i input.mkv -ss 00:00:00 -t 00:01:35 -c copy -map 0:0 -map 0:1 -map 0:2 -qscale:0:V 0 -y out0.mkv
4- Join the cut files using concat demux:
ffmpeg -f concat -i mylist.txt -c copy output.mkv
where mylist.txt contains:
file out0.mkv
file out1.mkv
And enjoy :).
I think you have to edit the srt manually (text and timecode the text needs to appear at) and remux it to your final video with a command like:
ffmpeg -i EditedSource.mp4 -i EditedSub.srt -c copy -map 0:a -map 0:v -map 1:s output.mp4
And instead of creating these intermediate files, have you tried:
ffmpeg -i out00.mp4 -i out01.mp4 -filter_complex '[0][1]concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]' output.mp4