[FFmpeg-user] Appending Video Stream to Existing or New File

littlebat dashing.meng at gmail.com
Tue Sep 10 04:24:54 CEST 2013

On Mon, 9 Sep 2013 17:18:15 +0300
Aydoğan Ersöz <aydogan.ersoz at teknotel.com.tr> wrote:

> Dear ffmpeg users,
> i can record 320x240 5-fps h264-encoded grayscale stream from internal
> webcam of my laptop to avi file. Beside this function, i can manage to
> extract a grayscale jpeg file every 5 seconds.
> I do want to record from webcam to file cumulatively to the file. If
> file (output avi) exists, script should append stream to end of file.
> If file does not exist, script should create file and then write.
> My code (script) overwrites the existing file, not appends to the end
> of file.
> How can i achieve this functionality?
> Here is my design: "*ffmpeg -f video4linux2 -i /dev/video0 -c:v
> libx264 -r 5 -s 320x240 -vf
> format=gray /home/aydu/Desktop/demo/cam0.avi -r 1/5 -vf format=gray
> -f image2 -updatefirst 1 /home/aydu/Desktop/demo/image.jpeg*"

Don't know how to append it. There is another idea:
1, Record your video to a temporary file;
2, Join the old file and your new temporary file using the way: How to
concatenate (join, merge) media files
3, When the new recording start, duplicate the steps above.

More information about the ffmpeg-user mailing list