You are not logged in.

#1 2009-05-14 21:59:44

venky80
Member
Registered: 2007-05-13
Posts: 1,002

encoding all videos in a forder

Is there a script which i can use to encode all videos inside a folder to a better format than mjpeg?
I have lot of videos from my camera and they are huge, please let me know if any such application/script exists.
thanks


Acer Aspire V5-573P Antergos KDE

Offline

#2 2009-05-14 22:07:52

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: encoding all videos in a forder

you could in theory do this with one find command:

find /some/folder -name '*.some_extension' -exec some_encoding_command {} \;

but it gets tricky with extensions and such, i.e.

find ./ -name '*.avi' -exec ffmpeg -i {} {}.mp4 \;

would convert all avi's into mp4's (IIR[the options]C) but it'll leave a bunch of *.avi.mp4 files, which might be undesired.  i'm sure procyon can come through with a more complex find line to take care of that but you could also just script it out:

#!/bin/bash

for video in $(find ./ -name '*.avi'); do
   new="$(echo $video | sed 's/\.avi/\.mp4/g')"
   ffmpeg -i $video $new
done

i _think_ that would work (some care might need to be taken if you've got spaces in filenames)... either way, i hope that gets you going in the right direction

Last edited by brisbin33 (2009-05-14 22:09:26)

Offline

#3 2009-05-15 04:31:51

venky80
Member
Registered: 2007-05-13
Posts: 1,002

Re: encoding all videos in a forder

thanks brisbin but what bout nested folders, will this work for folders inside folders?


Acer Aspire V5-573P Antergos KDE

Offline

#4 2009-05-15 17:34:13

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: encoding all videos in a forder

find will go into any subfolders yes, and return ALL files matching the -name criteria that are below the directory passed.

Offline

Board footer

Powered by FluxBB