Advertisement
Guest User

simple crossfade

a guest
Dec 14th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Windows power shell script (.ps)
  2. #This script is supposed to extract subclips from a variable frame rate input file ("fullgame.mp4"), add 0.5 seconds crossfade between them, and merge in the end. Video and audio is extracted separately, and merged in the end.
  3.  
  4. &'ffmpeg.exe' -ss 00:02:50 -i "fullgame.mp4" -t 00:00:28 -filter_complex "[0:a]afade=t=out:st=27.5:d=0.5[a1]" -map "[a1]" -y "Output\out_temp_00.mp4.wav"
  5. &'ffmpeg.exe'  -i "fullgame.mp4" -ss 00:02:50 -t 00:00:28 -an -vcodec copy -f mpegts -avoid_negative_ts make_zero -y "Output\out_temp_00.mp4.ts"
  6. &'ffmpeg.exe' -ss 00:11:32 -i "fullgame.mp4" -t 00:00:17 -filter_complex "[0:a]afade=t=in:st=0:d=0.5,afade=t=out:st=16.5:d=0.5[a1]" -map "[a1]" -y "Output\out_temp_01.mp4.wav"
  7. &'ffmpeg.exe'  -i "fullgame.mp4" -ss 00:11:32 -t 00:00:17 -an -vcodec copy -f mpegts -avoid_negative_ts make_zero -y "Output\out_temp_01.mp4.ts"
  8. &'ffmpeg.exe' -ss 00:33:32 -i "fullgame.mp4" -t 00:00:58 -filter_complex "[0:a]afade=t=in:st=0:d=0.5,afade=t=out:st=57.5:d=0.5[a1]" -map "[a1]" -y "Output\out_temp_02.mp4.wav"
  9. &'ffmpeg.exe'  -i "fullgame.mp4" -ss 00:33:32 -t 00:00:58 -an -vcodec copy -f mpegts -avoid_negative_ts make_zero -y "Output\out_temp_02.mp4.ts"
  10. &'ffmpeg.exe' -ss 00:35:10 -i "fullgame.mp4" -t 00:01:08 -filter_complex "[0:a]afade=t=in:st=0:d=0.5,afade=t=out:st=67.5:d=0.5[a1]" -map "[a1]" -y "Output\out_temp_03.mp4.wav"
  11. &'ffmpeg.exe'  -i "fullgame.mp4" -ss 00:35:10 -t 00:01:08 -an -vcodec copy -f mpegts -avoid_negative_ts make_zero -y "Output\out_temp_03.mp4.ts"
  12. &'ffmpeg.exe' -ss 00:36:31 -i "fullgame.mp4" -t 00:00:09 -filter_complex "[0:a]afade=t=in:st=0:d=0.5[a1]" -map "[a1]" -y "Output\out_temp_04.mp4.wav"
  13. &'ffmpeg.exe'  -i "fullgame.mp4" -ss 00:36:31 -t 00:00:09 -an -vcodec copy -f mpegts -avoid_negative_ts make_zero -y "Output\out_temp_04.mp4.ts"
  14.  
  15. &'ffmpeg.exe' -i "Output\out_temp_00.mp4.wav"  -i "Output\out_temp_01.mp4.wav"  -i "Output\out_temp_02.mp4.wav"  -i "Output\out_temp_03.mp4.wav"  -i "Output\out_temp_04.mp4.wav"  -y  -filter_complex "[0:a]adelay=0|0[a0];[1:a]adelay=27500|27500[a1];[2:a]adelay=44000|44000[a2];[3:a]adelay=101500|101500[a3];[4:a]adelay=169000|169000[a4];[a0][a1][a2][a3][a4]amix=inputs=5:dropout_transition=178,atrim=duration=178[outa0];[outa0]loudnorm[outa]" -map "[outa]" -ar 48000 -acodec aac -strict -2 "Output\fullgame_Output.mp4.aac"
  16.  
  17.  
  18. &'ffmpeg.exe' -i "Output\out_temp_00.mp4.ts" -i "Output\out_temp_01.mp4.ts" -i "Output\out_temp_02.mp4.ts" -i "Output\out_temp_03.mp4.ts" -i "Output\out_temp_04.mp4.ts" -y -i "Output\fullgame_Output.mp4.aac"  -filter_complex "[0:v]trim=start=0.5,setpts=PTS-STARTPTS[0c];[1:v]trim=start=0.5,setpts=PTS-STARTPTS[1c];[2:v]trim=start=0.5,setpts=PTS-STARTPTS[2c];[3:v]trim=start=0.5,setpts=PTS-STARTPTS[3c];[4:v]trim=start=0.5,setpts=PTS-STARTPTS[4c];[0:v]trim=27.5:28,setpts=PTS-STARTPTS[fo];[1:v]trim=0:0.5[fi];[fi]format=pix_fmts=yuva420p,fade=t=in:st=0:d=0.5:alpha=1[z];[fo]format=pix_fmts=yuva420p,fade=t=out:st=0:d=0.5:alpha=1[x];[z]fifo[w];[x]fifo[q];[q][w]overlay[r];[0c][r][1c]concat=n=3[t00];[t00]split[t1][o1];[t1]trim=0:44[1c1];[o1]trim=44:44.5,setpts=PTS-STARTPTS[fo1];[2:v]trim=0:0.5[fi1];[fi1]format=pix_fmts=yuva420p,fade=t=in:st=0:d=0.5:alpha=1[z1];[fo1]format=pix_fmts=yuva420p,fade=t=out:st=0:d=0.5:alpha=1[x1];[z1]fifo[w1];[x1]fifo[q1];[q1][w1]overlay[r1];[1c1][r1][2c]concat=n=3[t11];[t11]split[t2][o2];[t2]trim=0:101.5[2c1];[o2]trim=101.5:102,setpts=PTS-STARTPTS[fo2];[3:v]trim=0:0.5[fi2];[fi2]format=pix_fmts=yuva420p,fade=t=in:st=0:d=0.5:alpha=1[z2];[fo2]format=pix_fmts=yuva420p,fade=t=out:st=0:d=0.5:alpha=1[x2];[z2]fifo[w2];[x2]fifo[q2];[q2][w2]overlay[r2];[2c1][r2][3c]concat=n=3[t22];[t22]split[t3][o3];[t3]trim=0:169[3c1];[o3]trim=169:169.5,setpts=PTS-STARTPTS[fo3];[4:v]scale=1920x1080,fps=60,trim=0:0.5[fi3];[fi3]format=pix_fmts=yuva420p,fade=t=in:st=0:d=0.5:alpha=1[z3];[fo3]format=pix_fmts=yuva420p,fade=t=out:st=0:d=0.5:alpha=1[x3];[z3]fifo[w3];[x3]fifo[q3];[q3][w3]overlay[r3];[3c1][r3][4c]concat=n=3[outv]" -map "[outv]" -map 5:a -shortest -acodec copy -vcodec libx264 -preset ultrafast -b 15000k -aspect 1920:1080 "Output\fullgame_Output.mp4"
  19.  
  20.  
  21. Remove-Item 'Output\out_temp_00.mp4.wav'
  22. Remove-Item 'Output\out_temp_00.mp4.ts'
  23. Remove-Item 'Output\out_temp_01.mp4.wav'
  24. Remove-Item 'Output\out_temp_01.mp4.ts'
  25. Remove-Item 'Output\out_temp_02.mp4.wav'
  26. Remove-Item 'Output\out_temp_02.mp4.ts'
  27. Remove-Item 'Output\out_temp_03.mp4.wav'
  28. Remove-Item 'Output\out_temp_03.mp4.ts'
  29. Remove-Item 'Output\out_temp_04.mp4.wav'
  30. Remove-Item 'Output\out_temp_04.mp4.ts'
  31. Remove-Item 'Output\fullgame_Output.mp4.aac'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement