LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What program can batch convert video (https://www.linuxquestions.org/questions/linux-newbie-8/what-program-can-batch-convert-video-876476/)

Adol 04-22-2011 04:58 AM

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?

ButterflyMelissa 04-22-2011 05:39 AM

Hi,

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

Wellness!

Thor

arizonagroovejet 04-22-2011 07:36 AM

Handbreak can be used from the command line.

Code:

$ cd folder
$ for file in *;do handbrakecommand "$file" ;done

https://trac.handbrake.fr/wiki/CLIGuide

ButterflyMelissa 04-22-2011 08:46 AM

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

schneidz 04-22-2011 09:06 AM

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 ####################


Adol 04-23-2011 01:33 AM

Quote:

Originally Posted by Thor_2.0 (Post 4332619)
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.

schneidz 04-23-2011 09:35 PM

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

jschiwal 04-23-2011 10:13 PM

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.

Adol 04-24-2011 08:33 AM

Thank you

I'll try both ways later this week.

Hope I can get it to work soon.


All times are GMT -5. The time now is 12:29 PM.