LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   command line video converting? (https://www.linuxquestions.org/questions/linux-software-2/command-line-video-converting-681773/)

mrgreaper 11-07-2008 08:50 AM

command line video converting?
 
ok heres the situation
i use sabnzbd+ to get my tv episodes (legaly no different to recording them on a vcr) i then move them to my windows pc and use Omniquiti Lathe 1.8 ( a VERY old converting program) to convert the files into a smaller more archos friendly format. Now sabnzbd has the power to do postprocessing in the form of a script so heres what im after but have zero idea how to even start,
a simple command line conversion program that can take the command from the post processing script which provides various varible names in the form of $4echo
the format i need the converted files to is;
video
avi container
frame width 424 (height and width not set in stone just needs to be widescreen and around these numbers maybe set height and keep aspect ratio? )
frame height 234
datarate 48kbps
total bitrate 128kbps
25 frames per second
codec xvid
audio
codec mpga (mp3 would work i think, ac3 etc doesnt)
channels 2 (1 would be fine)
sample rate 44100mhz
bitrate 80kbps

im thinking along the lines off

NAMEOFPROGRAM $4echo videosettings/audiosettings $4echo-converted

so it would convert it and rename the resaulting file (but as i say i have no idea)

any and all help greatfully recieved

for reference the archos im using is the "av700 tv"

David the H. 11-07-2008 09:04 AM

There are a multitude of cli converters on Linux. Indeed, there are many more command line options than gui ones, and the gui's are usually mostly front-ends for the cli programs.

For your purposes, I'd say ffmpeg is probably all you need. It's simple to use and the fastest encoder available. mplayer/mencoder is another option. I also like transcode, which is a cli frontend for various individual encoders, including ffmpeg and mencoder. Read the man pages thoroughly and check out some Google searches or whatnot to get an idea of the command syntax for each program.

mrgreaper 11-07-2008 10:57 AM

Quote:

Originally Posted by David the H. (Post 3334494)
There are a multitude of cli converters on Linux. Indeed, there are many more command line options than gui ones, and the gui's are usually mostly front-ends for the cli programs.

For your purposes, I'd say ffmpeg is probably all you need. It's simple to use and the fastest encoder available. mplayer/mencoder is another option. I also like transcode, which is a cli frontend for various individual encoders, including ffmpeg and mencoder. Read the man pages thoroughly and check out some Google searches or whatnot to get an idea of the command syntax for each program.


first thank you for the prompt reply.

i googled ffmpeg and that seems to be the key going through the documentation (after a swift drink to stop my eyes going crosseyed)i think this line will work
ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec xvid -b 48kbps -acodec mpga -ac 2 -ab bitrate 80 output.avi

though i will cahnge input.avi to $4echo and output.avi to Conv-$4echo (so i get test.avi as input conv-test.avi as output)

i just have to install mpga codec xvid codec and ffmpeg to give it a test but dont have time tonight, to save hassle latter can you tell me if that above line will convert the media to the format ineed or if i have done any of the syntax wrong?

thankyou in advance

almatic 11-07-2008 11:22 AM

Quote:

Originally Posted by mrgreaper (Post 3334578)
ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec xvid -b 48kbps -acodec mpga -ac 2 -ab bitrate 80 output.avi

mpga is not an option in libavcodec, so you'll be stuck with mp3. The correct syntax would be:

ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec libxvid -b 48k -acodec libmp3lame -ac 2 -ab 80k output.avi

btw. are you sure you wanna use a bitrate of 48kbit/s ? This will result in very bad quality with the chosen video size ...

mrgreaper 11-07-2008 12:05 PM

Quote:

Originally Posted by almatic (Post 3334593)
mpga is not an option in libavcodec, so you'll be stuck with mp3. The correct syntax would be:

ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec libxvid -b 48k -acodec libmp3lame -ac 2 -ab 80k output.avi

btw. are you sure you wanna use a bitrate of 48kbit/s ? This will result in very bad quality with the chosen video size ...

i get unknown codec libxvid

so i did a google and found many outdated solutions none of which worked or where suggestions to use other programs arghhhhhhh

this being the most promising
http://stream0.org/2008/01/install-f...ntu-gutsy.html

a few of the commands i had to change (three of the enables went goodbye and i had to change one sudo command ) all of the changes where using the onscreen text to help, for example the sudo command i changed said one of the files packages was navailable but had been replaced with such and such so i changed the replaced one with the such and such one and hay presto :)

but i still get the error unknown codec libxvid, why oh why does linux have to be so user unfriendly !!!!! im out of time for tonight but any hints on how to get xvid codec installed much apreciated (i did check synaptic package installer but that didnt help) all software repositries are shown as ticked in software sources (about five of my google hits said i needed the restricted repository enabled ...but it is)

im stuck im lost i must of missed something simple please help


****edit***
i decided to do the sudo checkinstall to see if i had messed it up
aparently sudo checkinstall doesnt check it, it installs it
so its now installed but i have a new error instead of unknown codec i get
bash: /usr/bin/ffmpeg: No such file or directory
im off to bash the computer till it finds it .......

found it in the local folder so set up a symbolic link...whatever that is (google told me to do it)
sudo ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg
and now get a new error
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

i hate linux i really hate it i do i do i do (sorry but atleast you can see im trying to fix it im not just rellying on you guys to fix it for me ...though im now out of ideas)

almatic 11-07-2008 01:22 PM

It would be useful if you told more about your system (e.g. distribution you are using). I'm guessing it's ubuntu from what you said.
If so, how did you check that the 'restricted repository' is enabled ?

you probably just have to replace 'libxvid' with 'xvid' and 'libmp3lame' with 'mp3' to make the command work. So reinstall ffmpeg and its dependencies and make sure you install the version from the medibuntu repository (that's the 'restricted' one) and then try again like that.

ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec xvid -b 48k -acodec mp3 -ac 2 -ab 80k output.avi

If it doesn't work, post the output of 'ffmpeg -formats | grep -e xvid -e mp3'

Shadow_7 11-07-2008 02:31 PM

ffmpeg / mencoder / transcode

The three main ones to convert video.

VLC / Kaffeine

For capturing from DVB and other things.

There's a few sources that are not included in some distros. Licensing / legal deterrents and whatnot. Lame is source only iirc. libxvid libx264 libdvdcss and others to some degree as well. Obtainable from videolan.org by clicking on the developers link and the corresponding library.

Is there some reason you're wanting xvid output? There are other options without having to install extra libs. mpeg2, mpeg4, mjpeg, x264, quicktime, ........

I use -f avi -vcodec msmpeg4v2 output.mp4 if I want decent quality and relatively low disk usage.

Or -vcodec mpeg2video output.mpeg if it's destined for dvd.

Or this ugly mess for the camcorder I'll be getting.

ffmpeg -i $INFILE -sameq -an -deinterlace -f yuv4mpegpipe - 2> /dev/null \
| yuvfps -s 60000:1001 -r 60000:1001 \
| yuvscaler -n n -M RATIO_1920_960_1080_540 2> /dev/null \
| ffmpeg -f yuv4mpegpipe -sameq -i - \
-croptop 270 -cropright 480 -cropbottom 270 -cropleft 480 \
-vcodec mpeg2video -r 60000/1001 $VIDFILE

mrgreaper 11-08-2008 01:03 AM

Quote:

Originally Posted by almatic (Post 3334714)
It would be useful if you told more about your system (e.g. distribution you are using). I'm guessing it's ubuntu from what you said.
If so, how did you check that the 'restricted repository' is enabled ?

you probably just have to replace 'libxvid' with 'xvid' and 'libmp3lame' with 'mp3' to make the command work. So reinstall ffmpeg and its dependencies and make sure you install the version from the medibuntu repository (that's the 'restricted' one) and then try again like that.

ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec xvid -b 48k -acodec mp3 -ac 2 -ab 80k output.avi

If it doesn't work, post the output of 'ffmpeg -formats | grep -e xvid -e mp3'

i googled medibuntu
and found the repositry
added it with the insstructions online
ticked them all in software sources
sudo apt-get install ffmpeg --fix-missing (last bit was a suggestion from the terminal)
did the command
unknown codec xvid (and libxvid)

heres the output

Code:

mrgreaper@horeseman:~$ ffmpeg -formats | grep -e xvid -e mp3
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg --enable-libgsm --enable-dc1394 --disable-debug --enable-libmp3lame --enable-libfaadbin --enable-libfaad --enable-libfaac --enable-xvid --enable-x264 --enable-liba52 --enable-amr_nb --enable-amr_wb --enable-shared --prefix=/usr
  libavutil version: 1d.49.3.0
  libavcodec version: 1d.51.38.0
  libavformat version: 1d.51.10.0
  built on Jul 29 2008 18:21:25, gcc: 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
 DE mp3            MPEG audio layer 3
 D A    mp3
 D A    mp3adu
 D A    mp3on4

im using ubuntu 8.04

again your help is majoly appreciated

mrgreaper 11-08-2008 08:37 AM

ok i have tried the following today,
instaled w32codecs from both apt-get and synaptic package manager
installed "non-free" codecs from synaptic package manager
sudo apt-get remove ffmpeg
installed it from here http://packages.medibuntu.org/hardy/ffmpeg.html
the command line you showed me shows same build date as last time which is 2008 the package installed but on the site if you look at the name it says 2007 in it (so did it just reinstall the old one?)
sudo apt-get remove again (wierd how so many commands start sudo, is it a spelling mistake like should be sodo?)
installed ffmpeg from synaptic package manager (it said that it was the "risky" one with mp3 etc enabled )

at each stage i tried the ffmpeg command to encode with xvid and libxvid both unknown every time

i dont get it i just dont get it, why is this so hard?

all i want is an xvid codec a terminal based conversion tool i can tell to convert from a script and a simple easier life

is ubuntu unfriendlyier then other destros? (i got the impression it was suposed to be the most user friendly ...now i want to throw it through a window (not mine of course that would be silly, its cold outside))

mrgreaper 11-08-2008 10:32 AM

ok new post as its a new idea
ffmpeg is clearly not for users of my low skill

so im trying mencoder

Code:

mrgreaper@horeseman:~$ mencoder -ovc help
MEncoder 2:1.0~rc2-0ubuntu13 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 Processor 3000+ (Family: 15, Model: 31, Stepping: 0)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Available codecs:
  copy    - frame copy, without re-encoding. Doesn't work with filters.
  frameno  - special audio-only file for 3-pass encoding, see DOCS.
  raw      - uncompressed video. Use fourcc option to set format explicitly.
  nuv      - nuppel video
  lavc    - libavcodec codecs - best quality!
  vfw      - VfW DLLs, read DOCS/HTML/en/encoding-guide.html.
  qtvideo  - QuickTime DLLs, currently only SVQ1/3 are supported.
  libdv    - DV encoding with libdv v0.9.5
  xvid    - XviD encoding
  x264    - H.264 encoding

Code:

mrgreaper@horeseman:~$ mencoder -oac help
MEncoder 2:1.0~rc2-0ubuntu13 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 Processor 3000+ (Family: 15, Model: 31, Stepping: 0)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Available codecs:
  copy    - frame copy, without re-encoding (useful for AC3)
  pcm      - uncompressed PCM audio
  mp3lame  - cbr/abr/vbr MP3 using libmp3lame
  lavc    - FFmpeg audio encoder (MP2, AC3, ...)
  twolame  - Twolame MP2 audio encoder
  faac    - FAAC AAC audio encoder

ok so far so good we have mp3 and xvid !!!!!

i go to the memcoder help novel(volumes 1 through 2million) and to be honest im finding it unhelpful

mencoder -h pr --help or just plain help do nothing

all i can understand is "mencoder test.avi -ovc xvid (VIDEO OPTIONS) -oac mp3lame (AUDIO OPTIONS) -o output.avi" seems to be the rough format the encoding to xvid page http://www.mplayerhq.hu/DOCS/HTML/en...feat-xvid.html is of no help whatso ever

so my question, my on my knees and begging for help is this

how do i turn
ffmpeg -i input.avi -s 424x234 -aspect 16:9 -vcodec xvid -b 48k -acodec mp3 -ac 2 -ab 80k output.avi

into a mencoder command ?

almatic 11-08-2008 02:17 PM

mencoder input.avi -ovc xvid -oac mp3lame -xvidencopts bitrate=48:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o output.avi

I wouldn't give up on ffmpeg so fast because it's really useful.
From the output you have posted it seems as if you have the correctly
compiled version, but the dependencies (libavcodec, libavformat ...)
are wrong, because they have no support for mp3 and xvid encoding.
Maybe you have wrecked your installation with your checkinstall action.



I'd try to uninstall everything (and make sure everything with name
libav* is gone under /usr/lib and /usr/local/lib), then install again
(and make sure that all packages come from medibuntu repository).

mrgreaper 11-08-2008 05:25 PM

Quote:

Originally Posted by almatic (Post 3335545)
mencoder input.avi -ovc xvid -oac mp3lame -xvidencopts bitrate=48:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o output.avi

I wouldn't give up on ffmpeg so fast because it's really useful.
From the output you have posted it seems as if you have the correctly
compiled version, but the dependencies (libavcodec, libavformat ...)
are wrong, because they have no support for mp3 and xvid encoding.
Maybe you have wrecked your installation with your checkinstall action.



I'd try to uninstall everything (and make sure everything with name
libav* is gone under /usr/lib and /usr/local/lib), then install again
(and make sure that all packages come from medibuntu repository).

thankyou im at work but vnced into my serverpc and tried the command it seemed to work (a littlee slow but it certainly seems to work) as for ffmpeg, hmmm if i ever see that programme again it will be too soon lol

again thankyou

jschiwal 11-08-2008 05:40 PM

I think that part of the problem is that you have names for containers, names for codecs and names for formats that can get mixed up.
I don't think that mpga is the name of a codec. It is one of the names for an mpeg container that only contains an audio stream.
A demuxing program may take an mpeg video file that contains a video and an audio stream and split it into two files. So you end up
with your original program.mpg, and the two output files, program.mpga and program.mpgv.

Take a look at the notice at the end of "ffmpeg -formats":
Quote:

Note, the names of encoders and decoders do not always match, so there are
several cases where the above table shows encoder only or decoder only entries
even though both encoding and decoding are supported. For example, the h263
decoder corresponds to the h263 and h263p encoders, for file formats it is even
worse.
My best guess is that another tool referred to an "mp2" mpeg audio stream as "mpga". For a vanilla mpeg video file, use the "mp2" audio codec. (mpeg-1 layer II audio)
If your container supports mp3, then you may want to use that instead.

andrew.46 11-09-2008 06:56 PM

Hi,

You may be starting off on the wrong foot by installing ffmpeg and MPlayer from the Ubuntu repositories. Can I suggest:

http://ubuntuforums.org/showthread.php?t=786095
http://ubuntuforums.org/showthread.php?t=558538

These guides deal with ffmpeg and MPlayer compiled from svn. Both gentlemen who wrote these guides are quite active and will respond to queries promptly.

Andrew


All times are GMT -5. The time now is 10:05 PM.