Question

I have videos:

video1 - 923 seconds

video2 - 1457 seconds

video3 - 860 seconds

I need to cut these videos and fix its duration - 600 seconds. But the difficulty is that I need to cut them under the scheme

video

Where :

  1. blue segments is always 120 seconds (fixed);

  2. red segments I should to cut;

  3. green segments I shouldn't cut.

After that I need to join blue and green segments in new 600 seconds video, example

video

As the video1, video2, video3 have a different duration, then the red and green segments must have different duration, they must be in equal proportion to the duration of the video.

I need pure ffmpeg (avconv) command or bash script. I have no ideas how to make it.

Was it helpful?

Solution

probably the simples way to do this is to create an edit decision list (EDL), that you can then use to write your final video. i don't know of ffmpeg/avconv, but mplayer/mencoder will handle those quite will, see the docs.

to create the EDL, use a function like:

make_edl() {
 DUR=$1
 PRE=$2
 SLICES=$3
 POST=$4
 ## get the duration of the cut-up pieces
 SNIPPET=$(((DUR-PRE-POST)/SLICES))
 START=$PRE
 STOP=$((DUR-POST))

 curr=$START

 while [ $curr -lt $STOP ]; do
   currstop=$((cur+SNIPPET))
   if [ $currstop -gt $STOP ]; then
     currstop=$STOP
   fi
   echo "${curr} $((curr+SNIPPET)) 0"
   curr=$((curr+2*SNIPPET))
 done
}

# ...

## the following create an EDL for a 923sec movie,
## where we have 120sec of intro, than 31 alternating slices
## and 120sec of outro
make_edl 923 120 31 120 > myedl.txt

## apply the EDL
mencoder -edl myedl.txt input923.mov -o output923.mov

due to the limitations of bash arithmetic (integer only), this not be very precies

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top