Artur Bodera
2009-12-28 11:48:53 UTC
Hey there!
A simple use case:
1) a sample mp4 file of 23.98 tbr, 264 + aac, 1:51.27 in length
2) the file (lotr trailer) encoded with: ./ffmpeg -i
./lordoftherings_h640_ml.mov -vcodec libx264 -g 50 ./lord.mp4
3) we want to split it in 3 parts: 30s, 10s and the rest of the stream
Chunks we want to have:
1) ~30s (00:00:00 - 00:00:30)
2) ~10s (00:00:30 - 00:00:40)
3) ~71s (00:00:40 - 00:01:51)
File info:
Duration: 00:01:51.27, start: 0.000000, bitrate: 256 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 640x272, 192 kb/s, 47.90 fps,
23.98 tbr, 24k tbn, 47.95 tbc
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 58 kb/s
The only tools right now are -vframes, -ss and -t.
Frame-accurate seeking is missing/broken (?). Below is my approach.
a) chunk 1 is 30s, so with 23.98 fps that gives 719.5 frames.
b) Because it's gop 50 we round down to 700 frames = 29.1909925 seconds from
start
c) Chunk 1 extraction: "-vframes 699"
d) Chunk 2 starts from frames 700 and ends in 10s = 239.8 frames ~ 250
frames (gop 50)
e) Chunk 2 extraction: "-ss 29.1909925 -vframes 250"
f) Chunk 3 starts at 40s = 959.2th frames (23.98 fps). Rounding down to 50
gives us 950th frame
g) 950th frame is at aproximately 39.61635 sec.
g) Chunk 3 extraction: "-ss 39.61635"
Of course I wouldn't be bothering the community if it worked properly :-)
The chunks are off by many seconds, lengths are off.
Please assist - what am I doing wrong? Is there any more elegant way to do
that?
Also: a simpler case that I thought would "just work" - split the stream in
two:
./ffmpeg -y -ss -t 30 -i ./lord.mp4 -vcodec copy -acodec copy
lord-chunk1.mp4
./ffmpeg -y -ss 00:00:30 -i ./lord.mp4 -vcodec copy -acodec copy
lord-chunk2.mp4
It doesn't work! This will also end badly with two arbitrary length chunks
with seek times that make little sense.
How is it done properly?
Thanks!
Arthur.
ps: FFmpeg version SVN-r20880
A simple use case:
1) a sample mp4 file of 23.98 tbr, 264 + aac, 1:51.27 in length
2) the file (lotr trailer) encoded with: ./ffmpeg -i
./lordoftherings_h640_ml.mov -vcodec libx264 -g 50 ./lord.mp4
3) we want to split it in 3 parts: 30s, 10s and the rest of the stream
Chunks we want to have:
1) ~30s (00:00:00 - 00:00:30)
2) ~10s (00:00:30 - 00:00:40)
3) ~71s (00:00:40 - 00:01:51)
File info:
Duration: 00:01:51.27, start: 0.000000, bitrate: 256 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 640x272, 192 kb/s, 47.90 fps,
23.98 tbr, 24k tbn, 47.95 tbc
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 58 kb/s
The only tools right now are -vframes, -ss and -t.
Frame-accurate seeking is missing/broken (?). Below is my approach.
a) chunk 1 is 30s, so with 23.98 fps that gives 719.5 frames.
b) Because it's gop 50 we round down to 700 frames = 29.1909925 seconds from
start
c) Chunk 1 extraction: "-vframes 699"
d) Chunk 2 starts from frames 700 and ends in 10s = 239.8 frames ~ 250
frames (gop 50)
e) Chunk 2 extraction: "-ss 29.1909925 -vframes 250"
f) Chunk 3 starts at 40s = 959.2th frames (23.98 fps). Rounding down to 50
gives us 950th frame
g) 950th frame is at aproximately 39.61635 sec.
g) Chunk 3 extraction: "-ss 39.61635"
Of course I wouldn't be bothering the community if it worked properly :-)
The chunks are off by many seconds, lengths are off.
Please assist - what am I doing wrong? Is there any more elegant way to do
that?
Also: a simpler case that I thought would "just work" - split the stream in
two:
./ffmpeg -y -ss -t 30 -i ./lord.mp4 -vcodec copy -acodec copy
lord-chunk1.mp4
./ffmpeg -y -ss 00:00:30 -i ./lord.mp4 -vcodec copy -acodec copy
lord-chunk2.mp4
It doesn't work! This will also end badly with two arbitrary length chunks
with seek times that make little sense.
How is it done properly?
Thanks!
Arthur.
ps: FFmpeg version SVN-r20880
--
__
/.)\ +48 695 600 936
\(./ abodera at gmail.com
__
/.)\ +48 695 600 936
\(./ abodera at gmail.com