Hi,

I'm writing an application that cuts MPEG2 with the help of libav.
Cutting lossles at I and P frames works fine. 
But I've got a problem with frame exact cutting and minimal recoding.
Tried it this way:
- create a recoded file (f1) with the contents preceding the first I
frame
- create a recoded file (f2) with the contents after the last I frame
- copy f1 to the output file
- copy the complete GOPs of the original file
- copy f2
- proceed with the next cut ...

The recoding is done I frames only, the copying resorts pts and dts,
like I did it for lossles cutting.

Video players show different mistakes with the resulting file: 
WMP and Nero Player often let the video jump some frames (about 30
frames before the I frames only portion at the mark out). 
MPlayer shows one or more green frames, every time the different gop
sizes meet.


Bitmaps written by a test program from the decoded frames look fine.
Recoding the resulting file with ffmpeg creates a video, that works fine
on all players.
So the frame contents can't be the mistake.


So my questions are:
- is it 'legal' at all to mix gop size = 12 and I frames only? 
And if not:
- how do I do minimal recoding?
- do I have to set a flag to show the players, that the gop size has
changed? 
- or did I do a mistake in resorting the pts and dts:

/*
first letter is the frame type,
pts & dts are devided by frame duration
and the data size was a helpful ID while writing and reading.

the preceeding I frames should be < 12, I know. Mistake! but that's not
the problem.
*/

<copy of the recoded file f1>
I pts = 3, dts = 0, size = 52859
I pts = 4, dts = 1, size = 70729
...
I pts = 13, dts = 10, size = 87247
I pts = 14, dts = 11, size = 86306

<copy of the unrecoded gops>
I pts = 15, dts = 12, size = 55316
P pts = 18, dts = 13, size = 12668
B pts = 16, dts = 14, size = 4026
B pts = 17, dts = 15, size = 4034
P pts = 21, dts = 16, size = 9356
B pts = 19, dts = 17, size = 4026
B pts = 20, dts = 18, size = 4034
P pts = 24, dts = 19, size = 8620
B pts = 22, dts = 20, size = 2746
B pts = 23, dts = 21, size = 2922
I pts = 27, dts = 22, size = 60092
B pts = 25, dts = 23, size = 4586
B pts = 26, dts = 24, size = 4026
...
I pts = 99, dts = 94, size = 73524
B pts = 97, dts = 95, size = 5138
B pts = 98, dts = 96, size = 5498

<copy of the recoded file f2>
I pts = 100, dts = 97, size = 55702
I pts = 101, dts = 98, size = 65879

<next cut:>
I pts = 102, dts = 99, size = 29428
I pts = 103, dts = 100, size = 40001
...


Thanks in advance,

Thomas

ps.: the cut test video (152 frames, 3890 kB) is at
http://www.ismism.de/xc/cut_test.mpg
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to