amikey / winff

Automatically exported from code.google.com/p/winff
0 stars 0 forks source link

Wishlist: add simple concatenation of clips #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Just an idea:
Under Linux, something like 

cat movie1.avi movie2.avi > movie_cat.avi

and then running ffmpeg just concatenates the two movies. I guess using
copy in Windows can do the same thing.

Wouldn't it be nice to have the simple option to concatenate different
clips together? No need to become a heavy editor, but this is probably very
simple. I for one would use it to add my clips of holidays together to get
one overview (before deciding to really edit into something nice).

What do you guys think?

Original issue reported on code.google.com by poipodec...@hotmail.com on 9 Jan 2009 at 3:26

GoogleCodeExporter commented 9 years ago
Speaking under correction, but I assume that a typical .avi consists of:

<header><movie>

doing a concatenate should give you
<header><movie><header><movie>

I'm sure there is an ffmpeg way to do it.

Its been a long time, but I know you have to use the /b (binary) flag in dos.
In dos (and I assume windows) copy /b movie1.avi + movie2.avi movie_cat.avi
should do the same thing, but I might be slightly wrong.

Original comment by istoff@gmail.com on 9 Jan 2009 at 6:28

GoogleCodeExporter commented 9 years ago
From http://howto-pages.org/ffmpeg/

[Quote] You can also use ffmpeg to concatenate multiple videos into one long 
video.
Start by transcoding all the individual videos into MPEG format, all with 
exactly the
same bit rates, codecs, image resolutions, frame rates etc. Mistakes can be 
avoided
by using one of ffmpeg's predefined targets such as ntsc-dvd or pal-dvd. Once 
that's
done, simply string the resulting .mpg files together using "cat" and redirect 
the
output to another .mpg file. Now, the timestamps inside the resulting, big .mpg 
file
are all going to be messed up, so you'll have to process the big .mpg file with
ffmpeg again. This will have the effect of putting the timestamps right. 
[/quote]

Maybe only works for mpeg? But on websites it seems like a general approach.
Apparently ffmpeg is that smart.

Original comment by poipodec...@hotmail.com on 9 Jan 2009 at 7:25

GoogleCodeExporter commented 9 years ago
the cat'ing only works on mpeg files, but you convert all the files to mpg then 
cat
and then you convert again to the format you like. It's a long involved 
process. It
would be cool though.

(the size of all the videos converted to mpg)x2 + the size of the final encode.

Original comment by bgg...@gmail.com on 9 Jan 2009 at 9:58

GoogleCodeExporter commented 9 years ago
Played with this. FFmpeg bitrates, even when specified all the same are not 
converted
to exactly the same every time. It is very inconsistent.  Getting more than 4 
files
would almost guarantee failure. So i am going to wait. 

Original comment by bgg...@gmail.com on 21 Feb 2009 at 5:01

GoogleCodeExporter commented 9 years ago
From the ffmpeg FAQ:

 3.18 How can I join video files?

A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow to join video files by
merely concatenating them.

Hence you may concatenate your multimedia files by first transcoding them to 
these
privileged formats, then using the humble cat command (or the equally humble 
copy
under Windows), and finally transcoding back to your format of choice.

ffmpeg -i input1.avi -sameq intermediate1.mpg
ffmpeg -i input2.avi -sameq intermediate2.mpg
cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg
ffmpeg -i intermediate_all.mpg -sameq output.avi

Notice that you should either use -sameq or set a reasonably high bitrate for 
your
intermediate and output files, if you want to preserve video quality.

Also notice that you may avoid the huge intermediate files by taking advantage 
of
named pipes, should your platform support it:

mkfifo intermediate1.mpg
mkfifo intermediate2.mpg
ffmpeg -i input1.avi -sameq -y intermediate1.mpg < /dev/null &
ffmpeg -i input2.avi -sameq -y intermediate2.mpg < /dev/null &
cat intermediate1.mpg intermediate2.mpg |\
ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 -acodec libmp3lame output.avi

Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also 
allow
concatenation, and the transcoding step is almost lossless.

For example, let's say we want to join two FLV files into an output.flv file:

mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a 
<
/dev/null &
ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a 
<
/dev/null &
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
ffmpeg -i input2.flv -an -f yuv4mpegpipe - > temp2.v < /dev/null &
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]

Original comment by poipodec...@hotmail.com on 26 Apr 2009 at 9:48

GoogleCodeExporter commented 9 years ago
I would like to concatenate to simple H.264 files together (low bit rate and 
baseline
profile) with identical parameters and audio into one H.264 file without trans 
coding
and from the base libs and not from the command line.  I need them staticly 
linked in
my application.  I know that's a lot to ask, but it would be the bomb no my end.

- Sam

Original comment by dsm...@gmail.com on 8 Dec 2009 at 7:44