473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server Side Video Transcoding!

2 New Member
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 2093
KevinADC
4,059 Recognized Expert Specialist
check the filename with a reexp:

Expand|Select|Wrap|Line Numbers
  1. if ($filename =~ /\.flv/) {
  2.    skip it somehow
  3. }
Nov 24 '07 #2
alou131
2 New Member
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
2050
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 time it is actually viewed its been converted to UTF-8. Maybe by whatever the author used to upload the document to the server, maybe a a proxy, maybe by the user agent (if it saves it to disk), maybe by the httpd in some content negotiation. ...
4
3032
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"> This used to work just fine, but recently I migrated all of my web pages to a new server. Now I find that when I view the web pages they
4
1275
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 client side), but there doesn't seem to be any way to send it to the server after that. For files that are just text, I am able to write their contents to a hidden field, but I can't do that with an image. Thanks, Jim
5
1281
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
2055
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 whole day is then displayed in cels of a table. The user has then to click in a cel representing a hour of the day and an object (book ..), and finally click on the submit button to insert that reservation in the database. My problem is: there...
3
1773
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 src="http://galleries2.ftvcash.com/First-Time-Video/Babes/content/1/01.jpg" > </BODY></HTML>
11
4891
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. Here's a broad overview of what I need to do: cross-platform, client- side GUI apps that interact with a server backed by a database. I'd also like the possibility of having a web interface for small portions of the app. It will be a fairly...
0
799
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 about doing this. Anyone know of any good articles/sites with information on client-side callbacks in .NET AJAX? I can find plenty of articles on other implementations of AJAX but none for the asp.net AJAX. Cheers for any help.
5
2164
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10469
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.