LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-22-2011, 05:58 AM   #1
Adol
Member
 
Registered: Feb 2011
Location: Osaka, Japan
Distribution: Gentoo, Opensuse
Posts: 262

Rep: Reputation: 5
What program can batch convert video


Hello,

I have many video files that I'm trying to convert from *** to .mp4

Currently I'm using Handbrake which does a good job but getting it started is very tedious. In Handbrake I need to confirm and add to queue all of the files. When there are over 200 files at a time it takes way too long. If there is a way to not confirm all of the files please let me know.

What program can I use to just add a folder and have it automatically add all of the files to my queue?

Any suggestions?
 
Old 04-22-2011, 06:39 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Hi,

I'd go with the humble ffmpeg - it's my main work horse for this...

Wellness!

Thor
 
Old 04-22-2011, 08:36 AM   #3
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
Handbreak can be used from the command line.

Code:
$ cd folder
$ for file in *;do handbrakecommand "$file" ;done
https://trac.handbrake.fr/wiki/CLIGuide

Last edited by arizonagroovejet; 04-22-2011 at 12:07 PM. Reason: handbrake not handbreak
 
1 members found this post helpful.
Old 04-22-2011, 09:46 AM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Tnx arizonagroovejet! I adapted this for ffmpeg:

Quote:
for file in *; do ffmpeg -i $file $file.mp4;done
and that works like a train!

Thanks!!!

Thor
 
Old 04-22-2011, 10:06 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
hi, i generated/ modified this from xvidenc:
Code:
[schneidz@hyper ~]$ cat bin/xvidenc-ac3-mkv.ksh
#!/bin/bash
################### START OF COMMANDS ###################

dvd=live-free-or-diehard #`lsdvd $1 | head -n 1 | awk '{print tolower($3)}' | sed s/_/-/g`
#mkdir /home/xbmc/win/stuff/clips/$dvd
titles=`lsdvd $1 | grep ^Title: | cut -b 8-9 | tail -n 1`
i=1
while [ $i -le $titles ]
do

/usr/bin/mencoder "dvd://$i" -dvd-device $1 -o /dev/null -vc mpeg12 -vf pp=al:c,softskip,unsharp=l5x5:.25:c5x5:.25,harddup -aid 128 -channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=192 -a52drc 1 -ovc xvid -xvidencopts pass=1:turbo:me_quality=6:vhq=4:threads=2:max_bframes=2:bvhq=1:nopacked:quant_type=h263:noqpel:nogmc:trellis:nointerlacing:chroma_me:chroma_opt:hq_ac:nolumi_mask:rc_reaction_delay_factor=0:rc_averaging_period=100:closed_gop:autoaspect -passlogfile "$dvd-$i.log"

/usr/bin/mencoder "dvd://$i" -dvd-device $1 -o "$dvd-`zero-pad-2.x $i`".avi -vc mpeg12 -vf pp=al:c,softskip,unsharp=l5x5:.25:c5x5:.25,harddup -aid 128 -channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=192 -a52drc 1 -ovc xvid -xvidencopts pass=2:bitrate=2000:me_quality=6:vhq=4:threads=2:max_bframes=2:bvhq=1:nopacked:quant_type=h263:noqpel:nogmc:trellis:nointerlacing:chroma_me:chroma_opt:hq_ac:nolumi_mask:rc_reaction_delay_factor=0:rc_averaging_period=100:closed_gop:autoaspect -passlogfile "$dvd-$i.log"




sleep 2

/usr/bin/mkvmerge   --title "$dvd-$title-ac3" --track-name 0:"$dvd-$title-ac3" --language 1:en --track-name 1:"AC3 5.1" "$dvd-`zero-pad-2.x $i`.avi"      -o "$dvd-`zero-pad-2.x $i`.mkv"
sleep 2

i=`expr $i + 1`
done
#################### END OF COMMANDS ####################
 
Old 04-23-2011, 02:33 AM   #6
Adol
Member
 
Registered: Feb 2011
Location: Osaka, Japan
Distribution: Gentoo, Opensuse
Posts: 262

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by Thor_2.0 View Post
Tnx arizonagroovejet! I adapted this for ffmpeg:



and that works like a train!

Thanks!!!

Thor
Hello,

I'm trying this:

PHP Code:
petreuss@linux-nfvv:/bigdrive/working/New video formatffmpeg -/bigdrive/working/New\ videoformat/Mash/ /bigdrive/working/New\ videoformat/MashHighProfile/*.mp4 
and getting this error:
PHP Code:
FFmpeg version SVN-r201104161305Copyright (c2000-2011 the FFmpeg developers
  built on Apr 16 2011 11
:36:21 with gcc 4.5.0 20100604 [gcc-4_5-branch revision 160292]
  
configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-postproc --enable-gpl --enable-x11grab --extra-cflags='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/include/gsm' --enable-debug --disable-stripping --enable-libgsm --enable-libschroedinger --enable-libdirac --enable-avfilter --enable-libvpx --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libdc1394 --enable-pthreads --enable-librtmp
  libavutil    50. 40. 1 
50. 40. 1
  libavcodec   52.119
52.1191
  libavformat  52.108
52.1080
  libavdevice  52.  4. 0 
52.  4. 0
  libavfilter   1. 79. 0 
/  1. 79. 0
  libswscale    0. 13. 0 
/  0. 13. 0
  libpostproc  51.  2. 0 
51.  2. 0
/bigdrive/working/New video format/Mash/: Operation not permitted 
Is my input wrong? I want to convert all of the files from the Mash directory to the MashHighProfile directory. I'll worry about the correct setting for the device later. First I want to be able to get it started.
 
Old 04-23-2011, 10:35 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
i wouldnt use filenames with spaces...
else escape the spaces or put quotes around the filename.

not quite sure what you want for the input or putput filenames...

try this as a quick test:
Code:
ffmpeg -i input.avi -b 64k output.avi
 
Old 04-23-2011, 11:13 PM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Putting all the videos in the argument line won't convert them individually.
You would do that to append videos (ie cat'ing files together) or have more than one video stream.
There are a large number of presets for libx264 in the /usr/share/ffmpeg/ directory. You want to include
options to control the size, aspect & quality of your output. The generic options will give you a very
low bitrate small sized video as a result.

Experiment with the options until you get the result you want for your device. Then you can create a script that uses those options in ~/bin/
and if you have several videos to convert, you can call the script in a loop.

Bonus example:
Code:
Here is the ~/bin/vid2sansap2 script I use to transcode videos for my Sansa P2 player:
#!/bin/bash
videoin="$1"
videoout="${videoin%.*}.svi"
if [ -f "$videoin" ]; then
    mencoder -vf scale=480:272 -ofps 29.97 -ffourcc XVID \
             -oac mp3lame -lameopts cbr:br=128 \
             -ovc xvid \
             -xvidencopts max_bframes=0:quant_type=mpeg:bitrate=1024 \
             -af resample=44100 \
             "$videoin" \
             -o "$videoout" 
fi
It uses mencoder instead of ffmpeg. For 4x3 aspect ratio video I use "-vf scale=360:270" instead.
It's easy to include the script in a loop to transcode multiple videos.

Last edited by jschiwal; 04-23-2011 at 11:15 PM. Reason: fixed typo
 
Old 04-24-2011, 09:33 AM   #9
Adol
Member
 
Registered: Feb 2011
Location: Osaka, Japan
Distribution: Gentoo, Opensuse
Posts: 262

Original Poster
Rep: Reputation: 5
Thank you

I'll try both ways later this week.

Hope I can get it to work soon.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a batch of 7z files to zip don_wombat_73 Linux - Newbie 5 07-04-2016 10:35 AM
Batch convert video in entire folder using ffmpeg Steven Hyde Linux - General 4 05-03-2008 06:28 PM
Need help doing batch-convert with Gimp paulsm4 Linux - Software 0 01-09-2006 02:11 AM
Batch convert video files KimVette Linux - General 1 08-02-2005 10:13 PM


All times are GMT -5. The time now is 09:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration