0

I am removing multiple segment from a video using ffmepg I am referring to this link -How can I remove multiple segments from a video using FFmpeg?

I am executing below command:

String []complexCommand={"ffmpeg","-i","/sdcard/A.mp4","-filter_complex","[0:v]trim=duration=30[a];[0:v]trim=start=40:end=50,setpts=PTS-STARTPTS[b];[a][b]concat[c];[0:v]trim=start=80,setpts=PTS-STARTPTS[d];[c][d]concat[out1]","-map", "[out1]","-acodec","libmp3lame","-vcodec","mpeg4","-b:v","1024k","/sdcard/temp1.mp4"};    

Executing this command creates a working Video but no audio can be heard. How do I enable audio. Or is there another way to remove multiple segments in ffmpeg.

Sanket990
  • 281
  • 1
  • 2
  • 4

1 Answers1

0

I've updated that answer. If you want to have audio too, You have to do the same for audio streams. So the command should be:

ffmpeg -i utv.ts -filter_complex \
"[0:v]trim=duration=30[av];[0:a]atrim=duration=30[aa];\
 [0:v]trim=start=40:end=50,setpts=PTS-STARTPTS[bv];\
 [0:a]atrim=start=40:end=50,asetpts=PTS-STARTPTS[ba];\
 [av][bv]concat[cv];[aa][ba]concat=v=0:a=1[ca];\
 [0:v]trim=start=80,setpts=PTS-STARTPTS[dv];\
 [0:a]atrim=start=80,asetpts=PTS-STARTPTS[da];\
 [cv][dv]concat[outv];[ca][da]concat=v=0:a=1[outa]" -map [outv] -map [outa] out.ts
ptQa
  • 2,129