ffmpeg -hide_banner -i 1.mp4 -i 2.mp4 -filter_complex_script "[0:a]atrim=0:0[a0];[0:v]split[v000][v010];[1:a]atrim=0:[a1];[1:v]split[v100][v110];[v000]trim=0:0[v001];[v010]trim=0:[v011t];[v011t]setpts=PTS-STARTPTS[v011];[v100]trim=0:0[v101];[v110]trim=0:[v111t];[v111t]setpts=PTS-STARTPTS[v111];[v011][v101]xfade=duration=1:transition=smoothleft[vt0];[v001][vt0][v111]concat=n=3[outv];[a0][a1]concat=n=2:v=0:a=1[outa]" -map [outv] -map [outa] -look_ahead 0 -ac 2 -c:v libx264 -c:a aac -profile:v high -preset:v veryfast -keyint_min 72 -g 72 -sc_threshold 0 -b:v 3000k -minrate 3000k -maxrate 6000k -bufsize 6000k -b:a 128k -avoid_negative_ts make_zero -fflags +genpts -y ffmpeg-xfade-concat.mp4
You should be getting an error:
Failed to set value for option 'filter_complex_script'
-filter_complex_script accepts a text file. The text file contains the filtergraph. But your filtergraph is in the command itself.
Either move the filtergraph into a text file and use -filter_complex_script filters.txt, or change -filter_complex_script to -filter_complex.
Related
I would like to add black stroke to text in ffmpeg. Is it possible?
ffmpeg -y -i video.mp4 -vf drawtext="fontfile=arialuni.ttf:textfile=z1.txt : x=0/2:y=h-t*13:fontcolor=white:fontsize=35:shadowcolor=black:shadowx=10:shadowy=10" -shortest -vcodec libx264 -pix_fmt yuv420p -r 25 -g 160 -b:v 4000k -profile:v main -level 3.1 -acodec libmp3lame -b:a 128k -ar 44100 -preset superfast output1.mp4
Yes - set the borderw option in your drawtext filter to set the width of the stroke you want.
bordercolor can be used to set the colour, but defaults to black so you don't need to set it for your use case.
For example, the command in the OP could become:
ffmpeg -y -i video.mp4 -vf drawtext="fontfile=arialuni.ttf:textfile=z1.txt : x=0/2:y=h-t*13:fontcolor=white:fontsize=35:shadowcolor=black:shadowx=10:shadowy=10:bordercolor=black:borderw=3" -shortest -vcodec libx264 -pix_fmt yuv420p -r 25 -g 160 -b:v 4000k -profile:v main -level 3.1 -acodec libmp3lame -b:a 128k -ar 44100 -preset superfast output1.mp4
See https://ffmpeg.org/ffmpeg-filters.html#drawtext-1 for documentation.
My command
ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -video_size 1920x1080 -i :99.0+0,0 -f alsa -i pulse -channels 2 -c:a aac -b:a 160k -ar 44100 -threads 8 -c:v libx264 -x264-params nal-hrd=cbr -profile:v baseline -framerate 30 -level:v 4.2 -vf format=yuv420p -b:v 1000k -maxrate 1500k -minrate 1000k -bufsize 8000k -g 60 -preset ultrafast -tune zerolatency -f tee -flags +global_header -map 0:v -map 1:a "[f=flv:onfail=ignore]rtmp://stream1|[f=flv:onfail=ignore]rtmp://stream2"
Error in console:
[NULL # 0x55aaf9a54bc0] Unable to find a suitable output format for '"[f=flv:onfail=ignore]rtmp://strea1
[tee # 0x55aaf96f3200] Slave muxer #0 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -video_size 1920x1080 -i :99.0+0,0 -f alsa -i pulse -channels 2 -c:a aac -b:a 160k -ar 44100 -threads 8 -c:v libx264 -x264-params nal-hrd=cbr -profile:v baseline -framerate 30 -level:v 4.2 -vf format=yuv420p -b:v 1000k -maxrate 2500k -minrate 800k -bufsize 8000k -g 60 -preset ultrafast -tune zerolatency -map 0:v -map 1:a -f tee -flags +global_header [f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmp://stream1|[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmp://stream2
problem was with quotes
I'm trying to create a live stream with three quality profiles with different resolutions (SD, HD and FullHD). The live stream has subtitles, and I have to burn them for compatibility reasons.
I know how to do it with one profile, but with many no idea.
ffmpeg -nostdin -loglevel error -hwaccel cuvid -deint 2 -drop_second_field 1 -surfaces 15 -c:v h264_cuvid -resize 1280x720 -y -i udp://xxx.xxx.xxx.xxx:xxxxx?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1 -filter_complex [i:0x2c6]hwdownload,format=nv12[base];[i:0x993]setpts=(2.5)/TB+PTS[subs];[subs]scale=1280:720[subtitle];[base][subtitle]overlay[v];[v]hwupload_cuda[v] -map [v] -c:v hevc_nvenc -preset llhq -rc vbr_hq -cq 23 -qp 23 -tier high -profile:v main10 -level 4.0 -b:v 2000k -maxrate 2400k -bufsize 1000k -map i:0x2bd -c:a libfdk_aac -ac 2 -b:a 64k -map i:0x2be -c:a libfdk_aac -ac 2 -b:a 64k -metadata:s:a:0 language=eng -metadata:s:a:1 language=spa -f mpegts -mpegts_flags resend_headers+pat_pmt_at_frames -mpegts_copyts 1 -pcr_period 40 udp://yyy.yyy.yyy.yyy:yyyy?ttl=31\?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1
Apparenlty, Iffmpeg doen't allow to use -vf filter with filter_complex.
I'm using ffmpeg 3.4, cuda 8.
Use
ffmpeg -nostdin -loglevel error -hwaccel cuvid -deint 2 -drop_second_field 1 -surfaces 15
-c:v h264_cuvid -y -i udp://xxx.xxx.xxx.xxx:xxxxx?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1
-filter_complex "[i:0x2c6]hwdownload,format=nv12,split=3[fhd][hd][sd];
[i:0x993]setpts=(2.5)/TB+PTS,split=3[subfhd][subhd][subsd];
[fhd]scale=1920:1080[fhd];
[hd]scale=1280:720[hd];
[sd]scale=960:540[sd];
[subfhd]scale=1920:1080[subfhd];
[subhd]scale=1280:720[subhd];
[subsd]scale=960:540[subsd];
[fhd][subfhd]overlay,hwupload_cuda[v-fhd];
[hd][subhd]overlay,hwupload_cuda[v-hd];
[sd][subsd]overlay,hwupload_cuda[v-sd]"
-map [v-fhd] -map [v-hd] -map [v-sd] -c:v hevc_nvenc -preset llhq -rc vbr_hq -cq 23 -qp 23 -tier high
-profile:v main10 -level 4.0 -b:v 2000k -maxrate 2400k -bufsize 1000k
-map i:0x2bd -map i:0x2be -c:a libfdk_aac -ac 2 -b:a 64k
-metadata:s:a:0 language=eng -metadata:s:a:1 language=spa
-f mpegts -mpegts_flags resend_headers+pat_pmt_at_frames -mpegts_copyts 1
-pcr_period 40 udp://yyy.yyy.yyy.yyy:yyyy?ttl=31\?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1
You'll have to adjust the video bitrates and buffer sizes as required, but this is the basic command template.
ffmpeg -i "udp://localhost:2117" -vf "movie= logo3.png [logo];[in]
[logo]overlay= 30:70 [out]" -c:a aac -ac 1 -strict -2 -c:v libx264 -maxrate
1500k -bufsize 1500k -g 40 -r 23 -preset veryfast -threads 1 -f flv
rtmp://localhost/live/OTA2
I'am using this command above for my streaming transcoding , I want apply yadif filter in side -vf " " but i am getting error , so maybe i don't know the syntax
so someone help me how to apply yadif filter to the current command
Better to use a filter_complex in this case.
ffmpeg -i "udp://localhost:2117"
-filter_complex "[0]yadif[main];movie=logo3.png[logo];[main][logo]overlay=30:70"
-c:v libx264 -maxrate 1500k -bufsize 1500k -g 40 -r 23 -preset veryfast -threads 1
-c:a aac -ac 1 -strict -2
-f flv rtmp://localhost/live/OTA2
I am trying to use a watermark and apply Yadif using complex filter, but I cannot figure out how to apply Yadif with the following syntax
ffmpeg -i "source:" -i C:\logo.png -c:v libx264 -preset veryfast -s 1920x1080 -b:v 4000k -minrate 4000k -maxrate 4000k -bufsize 11835k -crf 18 -acodec mp3 -ab 128k -filter_complex [0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] -map [out] -f mpegts "dest"
Can anyone point me in the right direction?
Thanks
As indicated at the support forum, use
ffmpeg -i "source:" -i C:\logo.png \
-filter_complex "[0:v]yadif,scale=hd1080,setsar=1[b]; \
[b][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10" \
-c:v libx264 -preset veryfast -b:v 4000k -minrate 4000k -maxrate 4000k -bufsize 11835k \
-c:a mp3 -b:a 128k -f mpegts "dest"