Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Perl not playing video with vlc plugin

by awanti (Acolyte)
on Dec 29, 2015 at 10:36 UTC ( [id://1151332]=perlquestion: print w/replies, xml ) Need Help??

awanti has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to play the video file with help of vlc-plugin. Here is my code:-
#!/usr/bin/perl use strict; use warnings; use File::Basename; my $file ='/home/abhishek/Videos/lua.mp4'; my $size = -s "$file"; my $begin=0; my $end=$size; (my $name, my $dir, my $ext) = fileparse($file, qr/\.[^.]*/); open (my $fh, '<', $file)or die "can't open $file: $!"; binmode $fh; print "Content-Type: application/x-vlc-plugin \n"; print "Cache-Control: public, must-revalidate, max-age=0"; print "Pragma: no-cache" ; print "Accept-Ranges: bytes"; print "Content-Length: $end - $begin\n\n"; print "Content-Range: bytes $begin'-'$end'/'$size"; print "Content-Disposition: inline; filename=\"$name$ext\"\n"; print "Content-Transfer-Encoding: binary"; print "Connection: close"; my $cur=$begin; seek($fh,$begin,0); while(!eof($fh) && $cur < $end) { my $buf=1024*16; read $fh, $buf, $end-$cur; $cur+=1024*16; } close $fh;
And here is my access log is writing
127.0.0.1 - - [29/Dec/2015:11:39:31 +0530] "GET /cgi-bin/download.cgi +HTTP/1.1" 200 484 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko +/20100101 Firefox/43.0" 127.0.0.1 - - [29/Dec/2015:11:39:32 +0530] "GET /cgi-bin/download.cgi +HTTP/1.1" 200 447 "-" "(null)"

As I checked what does this mean from apache site,here is what i got

If no content was returned to the client, this value will be "-". To log "0" for no content, use %B instead.

I think the path or file has the issue. No content is returning to the client.It is returning null. I am not able to figure out what is going wrong. Any help what will be grateful.

And please suggest me what should i do to play the video and I am not sure is this the correct way to do?

Thanks in advance

Replies are listed 'Best First'.
Re: Perl not playing video with vlc plugin
by marto (Cardinal) on Dec 29, 2015 at 10:49 UTC

    As previously suggested, can you remove perl from the equation and create a stand alone HTML page which launches the video in the plugin successfully?

      yeah i made that.The code i posted is the standalone page and as i mentioned in access log it is writing it has no content return .

        From here on, I assume that you already have a static version of the video playback working that does not involve Perl or webmin at all.

        Your HTTP headers are very wonky. Please inspect them, again. Like I already told you, you should be using \r\n to delimit your HTTP headers.

        The following lines are problematic:

        print "Content-Length: $end - $begin\n\n";

        This means that for the web browser, all other headers after this get ignored.

        Also, this means that your script outputs something like:

        Content-Length: 50000000-0

        ... which is malformed. You will need to actually calculate the length before printing the length header.

        You could have found these using the techniques I told you before. Maybe you want to retry these techniques.

      yeah i made that.The code i posted is the standalone page and as i mentioned in access log it is writing it has no content written.

        The code you posted is Perl. "Standalone" in this context means just static HTML and Javascript, no Perl involved. This is intended for testing.

Re: Perl not playing video with vlc plugin
by nicomen (Novice) on Dec 29, 2015 at 11:52 UTC
    Aren't you missing a print of some sort? For instance print $buf inside your while-loop?
Re: awanti Perl not playing video with vlc plugin
by Anonymous Monk on Dec 29, 2015 at 18:49 UTC
        static html page has no header..

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1151332]
Approved by GotToBTru
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-20 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found