2

On my website I'm using phpmotion to convert videos into FLV files. What I want to do is that after the successful conversion of any new FLV file add short FLV file at the beginning.

So, I need FFMPEG command in PHP which will join the file 1.flv (intro file) with 2.flv (successful converted file) and as a result create final.flv

I tried with:

ffmpeg -i 1.flv -i 2.flv -vcodec copy -acodec copy final.flv

But without result.

Thanks for any suggestion.

Sergio
  • 1,207
  • 7
  • 28
  • 42

2 Answers2

1

Here is the code, you have to seperate audio and video to raw files at first, join them then again convert back to flv

mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
ffmpeg -i 1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
ffmpeg -i 2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
ffmpeg -i 1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
{ ffmpeg -i 2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &
cat temp1.a temp2.a > all.a &
cat temp1.v temp2.v > all.v &
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
       -f yuv4mpegpipe -i all.v \
       -sameq -y output.flv
rm temp[12].[av] all.[av]
Jasim Muhammed
  • 1,376
  • 1
  • 20
  • 28
  • This one is working for me and, as I can see, is taken from [FFmpeg FAQ](http://ffmpeg.org/faq.html#How-can-I-join-video-files_003f) – weekens Apr 22 '12 at 13:57
0

I guess you can use mencoder to merge two files.

mencoder -oac copy -ovc copy -o c:\video.flv c:\a.flv c:\b.flv
Developer
  • 25,073
  • 20
  • 81
  • 128