Reputation: 2925
I am trying to merge three video files (each 16 seconds long) into one file using ffmpeg. Since they are in mpeg format I am simply trying to concatenate them into one file using cat
command. The problem is that when I run the resulting file (video.mpg
) it is reported as being ~16 seconds long (same as the first concatenated video). Interestingly when I play the file in VLC, I can watch the whole 48 sec of video, even though the video progress bar also only reports up to 16 secs.
It almost seems like the file "properties" (e.g. duration, etc) are not updated after the additional two videos are added using the cat
command.
Would appreciate any suggestions on how I might solve this.
The following is the relevant section of the BASH script I have created:
mkfifo intermediate1.mpg
mkfifo intermediate2.mpg
mkfifo intermediate3.mpg
ffmpeg -i "./tmp/final01.mp4" -qscale 1 -y intermediate1.mpg < /dev/null &
ffmpeg -i "./tmp/final02.mp4" -qscale 1 -y intermediate2.mpg < /dev/null &
ffmpeg -i "./tmp/final03.mp4" -qscale 1 -y intermediate3.mpg < /dev/null &
echo "[audioforge] Stitching files "
cat intermediate1.mpg >> ./tmp/video.mpg
cat intermediate2.mpg >> ./tmp/video.mpg
cat intermediate3.mpg >> ./tmp/video.mpg
# Convert back to mp4 format.
ffmpeg -i "./tmp/video.mpg" -qscale 1 -y "./tmp/video.mp4"
Upvotes: 0
Views: 375
Reputation: 20980
Looks like you have not 'wait'ed for all the conversions to complete.
Use command wait
after the 3 ffmpeg lines (those lines, running in background)
I am not sure of the exact syntax, but it is pretty easy to follow.
Plus, do you HAVE TO use fifo only? you could use a simple file in /tmp; unless it is going to take a really huge space.
EDIT: because of inherent blocking I/O nature of fifo, the wait ommand might not be necessary; however, because of this, you will not achieve parallelism in converting 3 files in parallel, which you want. After converting first 4k (or whatever is your fifo size) of output files, the 2 (2nd & 3rd) conversion commands will stop, till the data is read from the fifo.
Upvotes: 2