473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Server Side Video Transcoding!

Hello all!

I have this server side video transcoding script that works on all video files uploaded and transcodes them to the .flv format. The problem is when a video file that is already in the.flv format is uploaded, the script tries to transcode it also and an error occurs. Is there a way to have the script not try to transcode .flv files? I would appreciate any help given.

Expand|Select|Wrap|Line Numbers
  1.  
  2. use IO::Socket::UNIX;
  3. use IO::File;
  4.  
  5. my $vbrate = 64;
  6.  
  7. my $mplayer = "mplayer";
  8. my $mencoder = "mencoder";
  9.  
  10. sub get_length {
  11.   my ($file) = @_;
  12.  
  13.   my $pipe = IO::File->new("$mplayer -vo null -ao null -identify -ss 100:00:00 $file 2>&1|");
  14.   while (<$pipe>) {
  15.     if (/^ID_LENGTH=([\d\.]+)/) {
  16.       return $1;
  17.     } elsif (/^V:\s*(\d+\.\d+)/) {
  18.       return $1;
  19.     }
  20.   }
  21.   undef;
  22. }
  23.  
  24.  
  25. my $listen_path = "/tmp/transcode_socket";
  26. unlink($listen_path);
  27.  
  28. my $listen = IO::Socket->new(Type => SOCK_STREAM,
  29.                  Local => $listen_path,
  30.                  Listen => 1,
  31.                  Domain => AF_UNIX
  32.                 );
  33.  
  34.  
  35. my $sock;
  36. while (($sock = $listen->accept)) {
  37.   my $buf = $sock->getline;
  38.   my ($ifile, $ofile) = split(/\s+/, $buf);
  39.  
  40.   my $pid = fork();
  41.   if ($pid == 0) {
  42.     my $len = get_length($ifile);
  43.     my $ss = 0;
  44.     if ($len) {
  45.       $ss = $len / 2;
  46.     }
  47. #    system("mplayer -ss $ss -vo jpeg -frames 1 $ifile >/dev/null 2>&1");
  48.     exec "mencoder -vf scale=320:240 -ofps 15 -o $ofile -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -oac lavc -lavcopts acodec=mp3:abitrate=32 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=${vbrate}:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=0:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2 -lavcopts vpass=1 $ifile";
  49.   }
  50. }
  51.  
  52. exit (0);
  53.  
  54.  
Nov 24 '07 #1
2 2075
KevinADC
4,059 Expert 2GB
check the filename with a reexp:

Expand|Select|Wrap|Line Numbers
  1. if ($filename =~ /\.flv/) {
  2.    skip it somehow
  3. }
Nov 24 '07 #2
check the filename with a reexp:

Expand|Select|Wrap|Line Numbers
  1. if ($filename =~ /\.flv/) {
  2.    skip it somehow
  3. }

I really do not know how to go about doing that. It may be just some simple addition additional code to add or edit but am not at all in any sense of the word a programmer.
Nov 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: David Dorward | last post by:
I'm sure that I read somewhere that an HTML document might be transcoded to a different characterset at some stage in its journey, so while it might start out as (for example) ISO-8859-15, by the...
4
by: HeroOfSpielburg | last post by:
Hello, I am trying to using the Shift_JIS character set in my web pages, and have specified it as such in the <head>. <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> ...
4
by: Jim Hammond | last post by:
Is there any way to transparently get an image file from the client machine to the server? I already have a way to transparently generate the file and query for the file name (all done on the...
5
by: Dr. Pastor | last post by:
Dear All: (I am a 100% beginner in Python.) What environment,library,product should I import or study to manipulate cameras, video, fire-wire, avi files? Thanks you for any guidance.
10
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The...
3
by: browser | last post by:
when i open this simple page using server (http://localhost... or remote one) <HTML><BODY> <iframe src="http://galleries2.ftvcash.com/First-Time-Video/Babes/content/1/01.jpg" ></iframe> <img...
11
by: Jeff | last post by:
Hello everyone. I've searched through the archives here, and it seems that questions similar to this one have come up in the past, but I was hoping that I could pick your Pythonic brains a bit. ...
0
Bob Ross
by: Bob Ross | last post by:
I have just watched the video - "Make Client-Side Network Callbacks with ASP.NET AJAX?" (http://www.asp.net/learn/ajax-videos/video-79.aspx ). Which is very helpful but I would like to know more...
5
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.