Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: FFMPEG batch video convert?

  1. #1
    Join Date
    Sep 2006
    Beans
    128

    FFMPEG batch video convert?

    Hi guys I got a folder full of different avi files and I want to convert them to mpegs or if possible flv. I want to convert them exactly as they are I dont want to alter the video quality or anything, I saw the commands to do conversions one by one but I want to convert like 50. How can I do this?

    Thanks

    I also have Mplayer I read you can do conversions with mplayer too?

  2. #2
    Join Date
    Jul 2007
    Location
    Melbourne, Australia
    Beans
    3,475
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: FFMPEG batch video convert?

    You could try winff - not sure whether it will convert more than one file at a time. It is basically a gui for ffmpeg.
    Windows is the best virus detector on the market!
    Ubuntu attracts Human Beings - Windows attracts viruses and worms

  3. #3
    Join Date
    Sep 2006
    Beans
    3,713

    Re: FFMPEG batch video convert?

    Quote Originally Posted by babujbf View Post
    Hi guys I got a folder full of different avi files and I want to convert them to mpegs or if possible flv. I want to convert them exactly as they are I dont want to alter the video quality or anything, I saw the commands to do conversions one by one but I want to convert like 50. How can I do this?

    Thanks

    I also have Mplayer I read you can do conversions with mplayer too?
    The find command is the perfect tool for this:
    Linux Basics: A gentle introduction to 'find' [ubuntuforums.org]

    Example to convert all *.avi to *.mp4 in the ~/encode folder:
    Code:
    find ~/encode -name '*.avi' -type f -exec ffmpeg -i '{}' -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -vpre hq -crf 24 -threads 0 '{}'.mp4 \;

  4. #4
    Join Date
    Jun 2005
    Location
    Belgium
    Beans
    1,522
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: FFMPEG batch video convert?

    This was useful for me. Thanks. The output gives files names with double extention .MTS.mpg (I am batch converting MTS to mpg with mencoder).
    Any suggestion how to keep .MTS (in your example .avi) out of the output file name ?
    AMD64X2 3800+ 3GB Ram: 11.10
    ACER one T1810 : 11.10 64 bit

  5. #5
    Join Date
    Sep 2006
    Beans
    128

    Re: FFMPEG batch video convert?

    That command didn't work for me... where do I have to run it? DO I have to cd to the file containing the avis? Cause it says file not found.

    By the way how would I convert avis without decreasing quality of video or audio and convert them to mpeg?

    Thanks for the replies.

  6. #6
    Join Date
    Dec 2006
    Beans
    7,312

    Re: FFMPEG batch video convert?

    Hi cotcot,

    Quote Originally Posted by cotcot View Post
    Any suggestion how to keep .MTS (in your example .avi) out of the output file name ?
    I wrestled with the find syntax + sed for some time and failed fairly miserably . However if it is a single folder with avi files that you are dealing with the following variation of Fakeoutdoorsman's syntax using a for loop will work:

    Code:
    for i in *.avi
    do 
    	ffmpeg -i $i \
    	-acodec libfaac -ac 2 -ab 128k \
    	-vcodec libx264 -vpre hq -crf 24 -threads 0 \
    	$(echo $i | sed 's/\.avi$//').mp4 
    done
    This effectively creates a file called outfile.mp4 rather than outfile.avi.mp4 and can be used in a script or as a simple copy and paste job. Somebody more skilled that me should be able to weave this into a proper find search .

    Andrew

    Edit: I guess I should mention that this fails if there are spaces in the filenames...
    Last edited by andrew.46; August 12th, 2009 at 01:57 AM.
    You think that's air you're breathing now?

  7. #7
    Join Date
    Sep 2006
    Beans
    3,713

    Re: FFMPEG batch video convert?

    Quote Originally Posted by babujbf View Post
    That command didn't work for me... where do I have to run it? DO I have to cd to the file containing the avis? Cause it says file not found.
    My find example looked for files in the encode directory which is in my home directory (the ~/ is the same as typing /home/fakeoutdoorsman/). Alternatively you could navigate to your target directory and then run:
    Code:
    find . -name '*.avi' -type f -exec ffmpeg -i '{}' -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -vpre hq -crf 24 -threads 0 '{}'.mp4 \;
    By the way how would I convert avis without decreasing quality of video or audio and convert them to mpeg?
    You can't convert to a lossy format such as mpeg without loss of quality. If you explain what you are trying perhaps a better format can be used.

  8. #8
    Join Date
    Jun 2007
    Beans
    16,092

    Re: FFMPEG batch video convert?

    Solely in terms of the 'double' ext. (with or without spaces in name), and using a 'for' then something like this gives same filename w/ 1 ext.

    ((with the for and wildcard *, you must be at the dir. prompt where files are.
    Alternate save paths, if desired, go directly in front of "${f%.avi}.mp4"

    Code:
    for f in *.avi; do ffmpeg -i "$f" -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -vpre hq -crf 24 -threads 0 "${f%.avi}.mp4"; done

  9. #9
    Join Date
    Dec 2006
    Beans
    7,312

    Re: FFMPEG batch video convert?

    Hi mc4man,

    Quote Originally Posted by mc4man View Post
    Solely in terms of the 'double' ext. (with or without spaces in name), and using a 'for' then something like this gives same filename w/ 1 ext.[...]

    Code:
    for f in *.avi; do ffmpeg -i "$f" -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -vpre hq -crf 24 -threads 0 "${f%.avi}.mp4"; done
    Very nice! I officially withdraw my gratuitous use of sed .

    Andrew
    You think that's air you're breathing now?

  10. #10
    Join Date
    Jun 2005
    Location
    Belgium
    Beans
    1,522
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: FFMPEG batch video convert?

    Any idea why this command is a no go ? (I am in the folder with these two .MTS files).
    Code:
    for f in *.MTS; do mencoder “$f” -oac copy -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=1920:1080,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:keyint=15:aspect=16/9:threads=4 -vf lavcdeint -ofps 25 -fps 50 -o "${f%.MTS}.mpg"; done
    MEncoder SVN-r29123-4.3.3 (C) 2000-2009 MPlayer Team
    File not found: '“00119.MTS”'
    Failed to open “00119.MTS”.
    Cannot open file/device.
    
    Exiting...
    MEncoder SVN-r29123-4.3.3 (C) 2000-2009 MPlayer Team
    File not found: '“00126.MTS”'
    Failed to open “00126.MTS”.
    Cannot open file/device.
    The following command works fine however with the double extension :
    Code:
    find ~/encode -name '*.MTS' -type f -exec mencoder '{}' -oac copy -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=1920:1080,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:keyint=15:aspect=16/9:threads=4 -vf lavcdeint -ofps 25 -fps 50 -o '{}'.mpg \;
    AMD64X2 3800+ 3GB Ram: 11.10
    ACER one T1810 : 11.10 64 bit

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •