LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-24-2015, 03:44 AM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Rep: Reputation: 61
Cool FFmpeg vs. Libav - And many other questions


Hey LQ,

Trying to get a Ubuntu Server of mine to transcode videos from 1080pHD mp4 to 720p ogg. I hired someone to set up PHP QB/AV (a dead project now) on the server and when I finally got around to testing it out it only seems to encode 1.3mb of video and then stops, no errors to found in the Apache logs, PHP Logs. Zilch.

So I'm rethinking my route and just gonna do plain old cron jobs, bash scripts and ffmpeg from the shell. Now I see that ffmpeg is no longer supported on Ubuntu until 15.04 release in the future, but I need something working now.

So I start reading up on ffmpeg and realize the devs hated each other or something the project has been forked off into libav. So let's keep this thread start short.

1. Do I want to install libav or ffmpeg?
2. How do I install it?
3. Some examples on how to use them.

Your help, massively appreciated. I Google'd and Google'd and found many docs on this, but they all seem to specific case scenarios for ffmpeg and I found nothing on installing and use libav to encode videos in a single command from the shell.

Eep!
 
Old 03-24-2015, 06:19 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,889
Blog Entries: 13

Rep: Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933
  1. I'd recommend ffmpeg
  2. sudo apt-get install ffmpeg
  3. I think examples would depend on exactly what you want to do, I've cropped files, like a video of my dog had a coffee table at the bottom of it because the recorder was sitting on it, so I cropped it to get rid of a certain number of pixels from the bottom of the screen. I figured out the pixel count required to make it fit actually by using VLC and the advanced controls. So I'd also recommend using VLC to view and review. And of course do not specify actions to overwrite the original file, instead put it to another name and verify that you attained what you wished. Another thing one can do is choose the start and stop points so as to grab one scene out of a larger video, for instance the boring part where you hear me calling my dog to come and play and no visible action; I cut that out by specifying a later start time for the output stream. If you view help on either of those two applications, you'll see extensive information on the options and it really becomes a matter of what things you wish to do. I've never done much beyond resize, or limit, or convert from one known form to another one. Doing stuff like advanced filtering, mixing, or covering up stuff like how they cover a witnesses face by scrambling it, never done that.
 
1 members found this post helpful.
Old 03-24-2015, 12:25 PM   #3
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
Quote:
Originally Posted by wh33t View Post
1. Do I want to install libav or ffmpeg?
It's probably just a matter of personal preference. If libav is just a fork like you said, it should be fairly similar.

Quote:
Originally Posted by wh33t View Post
2. How do I install it?
With the package manager. On Ubuntu, it's apt-get. So you would run
Code:
apt-get install ffmpeg
Quote:
Originally Posted by wh33t View Post
3. Some examples on how to use them.
For what you want (encode to 720p ogv):
Code:
ffmpeg -i input.mp4 -s hd720 -acodec libvorbis  output.ogv
A breakdown of what's happening:
-i input.mp4: The name (or path of) the input file. As far as I am aware, ffmpeg automatically determines what the file type is, based on its contents. Fairly simple, right?
-s hd720: The output video size. There are various presets built in, see the man page for a list. Alternatively, you can manually specify a width and a height.
-acodec libvorbis: Specifies the codec to use for the audio. In my experience, for some reason ffmpeg wants to use its built-in FLAC encoder instead of the OGG Vorbis format. If you want to use FLAC, then just get rid of this part (although you have little to gain using FLAC, since the mp4 probably has lossy audio anyway).
output.ogv: The output file. Usually, ffmpeg can determine the output codecs and formats based on the file extension. However, you can manually specify codecs to use (like what I did above with the audio).

Of course, these are just a few of the options available.

Last edited by maples; 03-24-2015 at 12:25 PM. Reason: typo
 
1 members found this post helpful.
Old 03-24-2015, 05:04 PM   #4
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Original Poster
Rep: Reputation: 61
Thanks for the replies guys. Unfortunately nothing is ever as simple as I hope it to be when it comes to Linux.

Code:
wh33t@ubuntu:~$ sudo apt-get install ffmpeg
[sudo] password for wh33t:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package ffmpeg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'ffmpeg' has no installation candidate
wh33t@ubuntu:~$
So now I guess I'm installing it from source and compiling it?
 
Old 03-24-2015, 07:36 PM   #5
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
Quote:
Originally Posted by wh33t View Post
So now I guess I'm installing it from source and compiling it?
No, not yet anyway.

I found this link: https://launchpad.net/~mc3man/+archi...u/trusty-media that has instructions on adding a PPA for ffmpeg. (I have no idea what a PPA is, I'm guessing that it's similar to a repository in Debian).

However, the page notes that you have to completely purge ffmpeg and the PPA if you want to upgrade to the next release of Ubuntu without reinstalling. Otherwise, it sounds like you could get stuck deep in dependency hell or at least have package conflicts.

Hope this helps!
 
Old 03-24-2015, 07:50 PM   #6
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
ffmpeg is actually quite easy to compile on Ubuntu. It's one of the first things I do when installing.

They even provide a copy/paste guide to compiling it with various support.
http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

as for the difference... I was reading in a blog post awhile back how the two have diverged yet are copying each others commits to their own. They're basically identical.
It's a odd situation for open source and a bit like if Apple and Microsoft open sourced everything and starting copying each other - and it's perfectly fine (at wasting time)

Last edited by Sefyir; 03-24-2015 at 09:45 PM.
 
Old 03-24-2015, 09:22 PM   #7
seasons
Member
 
Registered: Dec 2014
Distribution: siduction
Posts: 264

Rep: Reputation: 58
Try libav first. If you're not doing anything complicated, it should be fine.
Code:
sudo apt-get install libav-tools
avconv <parameters>
 
Old 03-25-2015, 05:46 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,889
Blog Entries: 13

Rep: Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933Reputation: 4933
Don't forget to do
Code:
sudo apt-get update
first by the way.
 
Old 03-30-2015, 10:57 PM   #9
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Original Poster
Rep: Reputation: 61
I went with avconv cause it was easiest to install.

Here is where I'm at now:
Code:
wh33t@server:/var/www/html/video-test$ avconv -i raw-video.mp4 -s hd720 -acodec libvorbis -vcodec libtheora -f ogv avconv-video.ogv
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'raw-video.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
  Duration: 00:00:59.55, start: 0.000000, bitrate: 48421 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 48312 kb/s, 60 fps, 60k tbn, 120 tbc
    Stream #0.1(und): Audio: aac, 48000 Hz, stereo, fltp, 99 kb/s
Requested output format 'ogv' is not a suitable output format
I think I'm missing a codec or something?
 
Old 03-30-2015, 11:01 PM   #10
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Original Poster
Rep: Reputation: 61
I fixed it. -f ogv needed to say -f -ogg. Thanks guys! If it doesn't work out I'll post again but marking as solved.
 
Old 03-30-2015, 11:26 PM   #11
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Original Poster
Rep: Reputation: 61
Damn, still not there just yet.

The command does indeed run but the quality of both video and audio is super low. Here is what avconv -i reports.

Code:
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[ogg @ 0x1d05220] 18 bytes of comment header remain
[ogg @ 0x1d05220] truncated comment header, 1 comments not found
Input #0, ogg, from 'avconv-video.ogv':
  Duration: 00:00:59.55, start: 0.000333, bitrate: 568 kb/s
    Stream #0.0: Video: theora, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 5.67 fps, 60 tbn, 60 tbc
    Metadata:
      MAJOR_BRAND     : mp42
      MINOR_VERSION   : 0
      COMPATIBLE_BRANDS: mp41isom
    Stream #0.1: Audio: vorbis, 48000 Hz, stereo, fltp, 112 kb/s
    Metadata:
      MAJOR_BRAND     : mp42
      MINOR_VERSION   : 0
      COMPATIBLE_BRANDS: mp41isom
      ENCODER         : Lavf54.20.4
At least one output file must be specified
Any ideas?
 
Old 03-31-2015, 07:41 AM   #12
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
Try using "-q:v 9"
If that gives an error, then it should be "-qscale 9"
(I'm not at a computer I can test it on, so I'm going off memory)

If I remember correctly, 9 is the hightest quality and 0 is the lowest.

And you should also be able to use "-q:a 9" for the highest quality audio, and "-q:a 0" for lowest quality.
 
Old 03-31-2015, 09:06 AM   #13
seasons
Member
 
Registered: Dec 2014
Distribution: siduction
Posts: 264

Rep: Reputation: 58
Was there a certain video codec you were trying to use? Ogg is a container and it can hold several types of audio/video. avconv is guessing the theora video codec based on your extension, but you could specify vp8 (I think avconv supports it).

As for the audio, converting from one lossy format to another is not going to get you high quality audio. You're starting with relatively low bitrate (~100 kbps) AAC and converting to vorbis - not ideal.
 
Old 03-31-2015, 09:19 AM   #14
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
My 3 cents: nothing wrong with compiling from source. You can build ffmpeg with whatever codecs you want, and it will be optimized for your hardware too! Here's a guide to compiling ffmpeg with codecs of your choice on Ubuntu and friends.
 
Old 03-31-2015, 01:26 PM   #15
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Original Poster
Rep: Reputation: 61
Quote:
Originally Posted by maples View Post
Try using "-q:v 9"
If that gives an error, then it should be "-qscale 9"
(I'm not at a computer I can test it on, so I'm going off memory)

If I remember correctly, 9 is the hightest quality and 0 is the lowest.

And you should also be able to use "-q:a 9" for the highest quality audio, and "-q:a 0" for lowest quality.
Thanks, I managed to get it working. Going from 1080p mp4 to 720p ogg reduces filesize by 50%. That's not enough. What other options could I try here? How is it that movies on the torrent sites somehow cram 90 minutes of 720p video into 1.8gb?! That's the kind of compression I need, but is there any compression that good that will stream to an html5 compliant browser? Me thinks not but I await the answer with high hopes.

Last edited by wh33t; 03-31-2015 at 04:13 PM.
 
  


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
LXer: FFmpeg & Libav Add H.265 Encoder Via x265 LXer Syndicated Linux News 0 02-13-2014 09:51 PM
A FFmpeg/Libav, Mencoder GUI front Open Souce Project MobileMate need your help littlebat Linux - Software 0 09-16-2013 09:44 AM
LXer: The FFmpeg/Libav situation LXer Syndicated Linux News 1 07-02-2012 06:34 PM
[Questions] AVCodec/AVFormat - FFMPEG - Linux vs. Windows 7.e.Q Linux - Software 0 02-09-2006 12:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:34 AM.

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
Open Source Consulting | Domain Registration