Sunday, February 1, 2015

Combining MP4 files with avconv (updated)

Here's a shell script for combining .mp4 files into one (in chronological order).  Comes in handy for consolidating a bunch of short videos into a single file.


#!/bin/bash

count=1
cmd="cat"

for f in `ls -1rt *.mp4`
do
 PIPE="pipe"$count".mpg"
 mkfifo $PIPE
 avconv -i $f -c:v mpeg2video -q:v 5 -y $PIPE < /dev/null &
              cmd=$cmd" pipe"$count".mpg"
 count=`expr $count + 1`
done

$cmd | avconv -i pipe: -r 24 -vcodec libx264 -acodec libvo_aacenc -ab 61000 -ar 16000 -threads 0 -y final.mp4
rm pipe*mpg
Copyright ©1993-2024 Joey E Whelan, All rights reserved.