drslump / flv4php

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

Joined FLV stream #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

Actually this is not an issue related to your code .. but I like to submit 
my issue here and it will be great if you can help.

My issue is that I need to join more than one FLV file in the PHP stream. 
So I tried the following:

if($seekat1 != 0) {
    print("FLV");
    print(pack('C', 1 ));
    print(pack('C', 1 ));
    print(pack('N', 9 ));
    print(pack('N', 9 ));
}

$fh1 = fopen("file1.flv", "rb") or exit("Could not open file1.flv");
fseek($fh1, $seekat1);
while (!feof($fh1)) {
    print (fread($fh1, 16384));
}
fclose($fh1);

$fh2 = fopen("file2.flv", "rb") or exit("Could not open file2.flv");
fseek($fh2, $seekat2);
while (!feof($fh2)) {
    print (fread($fh2, 16384));
}
fclose($fh2);

But didn't work. It streamed the part of the first file "file1.flv" 
successfully then stopped without continuing streaming the part of the 
second file "file2.flv". Am I missing pack() that should be written 
between the 2 streams?

Appreciate your help.

Thanks,
Raed Petro.

Original issue reported on code.google.com by raedpetro@gmail.com on 27 May 2009 at 7:26

GoogleCodeExporter commented 9 years ago
What is the content of file 2 ?if there is also header / metadata in file 2 you 
need
to skip it.n and then it might not work 100 % as sound don't like to get cut up.

need to make sure the first frame you are outputting from file 2 is a keyframe
aswell. fires frame is always a keygrame, but if you seekat you need to make 
usre its
actuarly a keyframe.

I have been working on a feature to do this using flv4php but its never been 
perfected.

Original comment by fan...@gmail.com on 28 May 2009 at 8:17

GoogleCodeExporter commented 9 years ago
Hi Fannoj,

Thanks for your reply.

In my code I skipped the header of the second file. Actually I am trying to 
seek 
file2.flv from the middle via $seekat2.

I am struggling now with:
"making sure the first frame outputting from file 2 is a keyframe".
Do you have any hint(s) about this?

I am still trying .. didn't give up yet.

Thanks,
Raed Petro.

Original comment by raedpetro@gmail.com on 28 May 2009 at 10:33

GoogleCodeExporter commented 9 years ago
the only thing i can say from all the things i have tried is ht must be the 
keyframe ?

are you 100 % sure you are at the keyframe start ?

Original comment by fan...@gmail.com on 28 May 2009 at 12:50

GoogleCodeExporter commented 9 years ago
No .. I am not sure .. I am asking you how to make sure that I am starting the 
second file at a keyframe?

Original comment by raedpetro@gmail.com on 28 May 2009 at 1:01

GoogleCodeExporter commented 9 years ago
ohh i missed that sorry, if you look throw the flv4php framework:

getTag function will return "Tags" from the file.. it will return an object

while($tag = $FLV->getTag()) {
if($tag->type == FLV_TAG_TYPE_VIDEO && $tag->frametype == 1) {
// is video, and is keyframe

$keyframepointer = $FLV->getTagOffset();
}
}

-Morten Hundevad

Original comment by fan...@gmail.com on 28 May 2009 at 1:13

GoogleCodeExporter commented 9 years ago
I see .. I will have a look at this and try using it.

Original comment by raedpetro@gmail.com on 28 May 2009 at 1:19

GoogleCodeExporter commented 9 years ago
Yesss .. finally done :)

You were telling me to start at a keyframe. I recognized that this is what I 
was 
doing. I was getting the "filepositions" array of the keyframes of the FLV 
file, and 
seeking (via $seekat) at one of those keyframes to put the pointer at (to start 
with). That what you told me "IT MUST BE LIKE THIS" and this is absolutely true.

The second thing that MUST be done is that you have to end every joined FLV 
with "the end of a keyframe". This could be done by reading via "fread()" to 
EXACTLY 
a (filepositions - 1) using "ftell()". No byte less, no byte more.

Working excellent, Praise the LORD.

Now time to sleep .. now it is 12:40 AM here.

Thanks a lot Fannoj

Original comment by raedpetro@gmail.com on 28 May 2009 at 9:41