New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Need to write a script - no idea where to start - PHP HELP NEEDED
Ok guys, so I am in need of a script to write. It'll need to do the following:
- Access a folder that I have selected
- Rename the file within that folder
- Move the file into a separate folder
- Run an FFMPEG conversion command
- Remove original file
Any ideas on where I could/should start with this?
Liam
Comments
I could help, but unfortunately stuck at #4, lol. I know all the commands 1 -3 and 5. But 4 I have no idea how to run a FFMPEG conversion command...
I am sure someone here will help you! Be Patient :O
Bash
I like Java. Do everything in Java!
Only thing is, the script needs to be dynamic. Needs to be able to rename a file within that folder regardless of what the original file name is.
Basically it's for going through my collection of TV series.
Needs to access the folder where the video files are kept, rename the files individually to make them more recognisable, move them elsewhere, convert from avi to flv (stream through browser on home network for family), then remove original file.
Just lost atm .
CouchPotato, Sickbeard, and Plex. Done and done.
CouchPotato (movies) and Sickbeard (tv) for renaming and keeping track of your collection. Plex for a media center that can stream to any device.
It won't remove the original file, but it will on the fly perform an ffmpeg stream so you can watch the video on mobile and more if the original file format is not capable of playing on said device.
@liamwithers Windows?
Do it in Java, multithread that shit.
Rename the file within that folder
Move the file into a separate folder
Run an FFMPEG conversion command
Remove original file
Maybe by defining the parameters....
What's the basis for the new file name for renaming files?
What's the new folder going to be named?
And providing a sample of what you have, e.g. a sample directory listing.
Maybe he needs to run it in a 128mb VPS.
@Soylent With Java? Not a chance, 4GB should be enough right?
Seriously, bash
What you are writing on command line can be used exactly same in bash
You can do all the stuffs you listed on command line, can't you?
Now with a bit of tweak with bash codes such as loop, output and error handling, you can make robust script for whatever you want on Linux.
Ok, so I could use Bash.. but basically it's my torrented collection from online. So some of the names of files are a little confusing, or when I've downloaded individual episodes, the layout for the name has been different. I want to change them all to be me more consistent.
The script doesn't need to access a SPECIFIC folder.. it needs to access a folder which I haven't defined a name for. It then needs to be able to make the conversion on any .avi files, whilst renaming them, without me defining the original name. Obviously it would be a lot easier if I was giving it direct instructions: Go to this folder, fetch this file, rename it to this, convert it, move it.
Obviously it's slightly different to that though, seeing as I'm dealing with multiple files, and would rather have the script do it for me than do it manually through all of them.
I understand you guys say I can do this in bash, but I've never used bash before.. anybody able to give me a pointer or two as to how to do this? Would rather have some first-hand knowledge than being pointed towards a tutorial site, because that's not what I need in this case.
Cheers
@liamwithers - do it one file by hand, post the commands here - we can take generalising the commands into a bash script from there...
@liamwithers Use sickbeard to organise all the files, then maybe run the converter script to do whatever you want. Or maybe sickbeard lets you run scripts on files? I don't use it myself.
hm.. in VIsual Basic it would be nice
Could PHP script that :L, seems pretty simple to do; just need to figure out your conversion script; there will be something, and just make it wait until finished, using arguments from the script found online.
Seems pretty easy !
Why would you bring PHP into something that can be done entirely in a shell script?
@Gary - Gives expandability to make a interface for you to view the converted file; have a gallery of files converted etc. Depends what you're fluent in. I'd prefer PHP to Bash.
Ok, think I'm gonna be doing this in PHP.
For doing the FFMPEG command, is it simply:
shell_exec("FFMPEG COMMAND");
?Also, can you use PHP variables within shell_exec?
Basically I'll be wanting to do the following:
ffmpeg -i $FILENAME $FILENAME.flv
$FILENAME being a PHP variable
Ok, so I'm stuck for ideas.
Currently I've got a script that takes all of the video filenames from within a folder, and places them line-by-line in a text file like so:
I'm able to select each individual line as so (example to select fourth line):
$content = file('test.txt');
echo $content[3];
Now what I need to be able to do is perform an FFMPEG command on each one of these until I have reached the final line of the text file.
Any ideas on:
Thanks guys, appreciate your patience
It would be ffmpeg... *nix are case-sensitive.
@Damian yeah that's fine.. I know the command I'd need to use, just need to know how to do this for each video file which is defined in the text file. ffmpeg command I'd be using is:
Just need to know how this is all gonna work from each line of the text file
http://us.php.net/manual/en/control-structures.foreach.php is what you're looking for.
Use something like...
Do until EOF(1) {
for each $line as $filename {
~~~~
}
}