Modify

Ticket #8017 (closed enhancement: fixed)

You must read the TicketHowTo before creating a new ticket or commenting on an existing ticket.

Opened 2 years ago

Last modified 21 months ago

Fix mythweb flash streaming to behave like a progressive download

Reported by: justin.johnson3@… Owned by: kormoc
Priority: minor Milestone: unknown
Component: Plugin - MythWeb Version: unknown
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Attached patch allows the flash streaming flowplayer to behave like a progressive download. You can seek to any position in the video which has been downloaded. Note that you cannot seek to arbitrary points which have not yet been sent from the server.

This patch requires ffmpeg > r21615

This patch also addresses ticket  #7538

Attachments

mythweb.diff Download (2.3 KB) - added by justin.johnson3@… 2 years ago.
flv_stream.diff Download (1.3 KB) - added by justin.johnson3@… 2 years ago.
new patch with new fix

Change History

Changed 2 years ago by justin.johnson3@…

comment:1 Changed 2 years ago by scottadmi@…

This fix does not seem to work for my setup. An estimated size comes through when transferring the flv (confirmed by trying to download the flv stream directly) - however despite this, clicking any point in the flow player even parts which have already been played simply restarts the playback at 0. Any ideas?

comment:2 follow-up: ↓ 3 Changed 2 years ago by scottadmi@…

As a clarification, I am using the latest ffmpeg which exceeds the revision listed (built from trunk today) but it appears the flv itself does not have a duration set in the header which could be a culprit.

comment:3 in reply to: ↑ 2 Changed 2 years ago by justin.johnson3@…

Replying to scottadmi@…:

As a clarification, I am using the latest ffmpeg which exceeds the revision listed (built from trunk today) but it appears the flv itself does not have a duration set in the header which could be a culprit.

It looks like the patch I submitted to ffmpeg was reverted in revision r21652. It looks like I made some assumptions that were incorrect. I haven't gotten around to investigating another method of doing this. I'll post here when I do.

comment:4 Changed 2 years ago by scottadmi@…

I found a work around which doesn't require changes to ffmpeg. Its very rough code (as perl is not a language I work with much), but it works. The gist of it, is simply writing the duration data directly to the output stream at the appropriate place in the flv export (effectively overwriting the location which has a zero generated by ffmpeg).

This code snippet replaces the end of stream_flv.pl

    # Guess the filesize based on duration and bitrate. This allows for progressive download behavior
    my $lengthSec;
    $dur = `ffmpeg -i $filename 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,//`;
    if ($dur && $dur =~ /\d*:\d*:.*/) {
        @times = split(':',$dur);
        $lengthSec = $times[0]*3600+$times[1]*60+$times[2];
        $size = int($lengthSec*($vbitrate*1000+$abitrate*1000)/8);
        print header(-type => 'video/x-flv','Content-Length' => $size);
    } else {
        print header(-type => 'video/x-flv'); 
    }

    my $buffer;
    if (read DATA, $buffer, 53) {
        print $buffer;
        read DATA, $buffer, 8;
        $durPrint = reverse pack("d",$lengthSec); // change endian
        print $durPrint;
        while (read DATA, $buffer, 262144) {
            print $buffer;
        }
    }
    close DATA;

This could certainly be made cleaner, but it works well for now.

comment:5 Changed 2 years ago by justin.johnson3@…

I can confirm that this works for me as well.

Changed 2 years ago by justin.johnson3@…

new patch with new fix

comment:6 Changed 2 years ago by scottadmi@…

As an additional note, I've discovered that the duration returned by ffmpeg for .nuv (nuppelvideo) files which contain mpeg4 recordings produce extremely exaggerated durations (the HD recordings do not have this problem). Since I do not have the expertise to address this, I added a line two divide the duration given for nuv files by 21. This does not produce an exactly correct duration, but it is usually within a couple minutes (so the duration will be 33 min. instead of 12 hours).

comment:7 Changed 21 months ago by kormoc

  • Status changed from new to closed
  • Resolution set to fixed

(In [24919]) Fixes #8017, allows flowplayer to seek better

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.