LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 08-08-2016, 11:02 AM   #1
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 511

Rep: Reputation: 44
avconv: convert m4v to avi, but not Avidemux


If I need to convert an m4v file to avi, I can use Avidemux but it takes a while - about 20-25 mins for a 30 min video on my PC.

I thought I had found a faster method - the shell utility "avconv". However, the files convert faster (takes about 10 mins for a 30 min video), but either the files are 2-3 times as big as the avi's Avidemux produces, or the output is of a lesser quality, depending on the switches I use. It pelts along at around 100-150 frames per second conversion, as opposed to Avidemux's rate of 48-58 fps conversion rate, but with an unsatisfactory result.

I'm sure I'm using the avconv switches wrongly somewhere.

The Avidemux output while converting confirms that the "Quantiser" equals 4; the average bitrate is 800 kb/s. Frames per second conversion rate is around 48 to 58 on average.

By contrast, the avconv script I'm using says:

Code:
for i in *.m4v; do
    avconv -i "$i" -c:v mpeg4 -vtag xvid -c:a libmp3lame -r 30 -b:v 800k "${i%.*}".avi
done
Using this script, the file is an acceptable size, but image frame quality is less. If I use -b:v 1800k or possibly -qscale 4, quality is better but file size shoots up. (I assume qscale is equivalent to Avidemux's quantiser reading).

Also for some reason, while avconv is working away, it states a video bitrate way above the 800k I specify. I am aware that qscale maintains a standard quality regardless of bitrate; but should I be using -b:v to set the bitrate, or qscale to keep the image quality constant?

And what is Avidemux doing that is slower, produces smaller file sizes but still maintains quality?

I did read that Avidemux uses ffmpeg "underneath the hood". But I thought avconv had superseded ffmpeg now. Should I be running a similar script, but using ffmpeg instead of avconv?

Thank you for any help you can give. If I can get avconv producing identical output quality to Avidemux, but 3 times faster, that would be the ideal solution. I could understand avconv producing lower quality output, but faster; but it still only takes 10 mins to produce identical quality output to Avidemux - but with 3 times the file size!

Steve
 
Old 08-08-2016, 03:38 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,963
Blog Entries: 12

Rep: Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435Reputation: 5435
Quote:
Originally Posted by Steve W View Post
I can use Avidemux but it takes a while - about 20-25 mins for a 30 min video on my PC.

I thought I had found a faster method - the shell utility "avconv". However, the files convert faster (takes about 10 mins for a 30 min video), but either the files are 2-3 times as big as the avi's Avidemux produces, or the output is of a lesser quality, depending on the switches I use.
and that is how it is.
quick conversion = either low quality or huge files
slow conversion = possible to find good balance between quality and filesize.
if you find the right settings for avconv, it will take about as long as with avidemux, i guess. but try by all means, maybe you can shave off some seconds or megabytes.
 
1 members found this post helpful.
Old 08-08-2016, 04:00 PM   #3
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,075

Rep: Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725
Avconv "superseded" ffmpeg only according to avconv, and for a while, Debian (although, thankfully, they seem to be backing away from symlinking ffmpeg to avconv as if ffmpeg no longer exists). FFmpeg is still very much alive, still very active, and very relevant.

You probably do want a variable bitrate (VBR). This allows your video converter (ffmpeg or a fork like avconv) to "spend" more bits on complex motion and fewer bits on slow, non-moving (or low motion) shots. `-qscale` is the option for that.

You will also benefit from using the 2-pass option; the first pass allows ffmpeg (or avconv) to calculate bitrates and then the second pass performs the actual encode:

For the first pass, send the output to dev/null:

Code:
$ ffmpeg -i blah.m4v -c:v libxvid -c:a libmp3lame -r 30 -threads 12 -pass 1 -f rawvideo -y /dev/null
This produces no video, but a file called `ffmpeg2pass` is saved in the current directory.

Use this file to help with the second pass:

Code:
$ ffmpeg -i blah.m4v -c:v libxvid -c:a libmp3lame -r 30 -ar 44100 -b:a 128k -qscale 1 -threads 12 -pass 2 -passlogfile ffmpeg2pass foo.avi
Hope that helps. I prefer ffmpeg, so that's what my answers were based on, but all of that ought to translate to avconv.

A lot more about ffmpeg can be read on my site: http://slackermedia.ml/handbook/doku.php?id=ffmpeg

Last edited by notKlaatu; 08-08-2016 at 04:02 PM. Reason: shameless self promotion added (but it's useful info, so applicable)
 
1 members found this post helpful.
Old 08-12-2016, 04:29 AM   #4
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 511

Original Poster
Rep: Reputation: 44
Okay, thanks for the advice. I might stick with Avidemux then, if it's a swings-and-roundabouts situation. I also notice, when I do "avconv -i [filename]" to get info on a file, the ones from Avidemux use Advanced Simple Profile, but avconv output uses just "Simple Profile". Maybe that also has something to do with it.

Thanks again.

Steve
 
Old 08-12-2016, 06:47 AM   #5
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 7,231

Rep: Reputation: Disabled
You are actually converting H.264 to Xvid. I wonder if there is a simpler solution. Why you need to use AVI container? Will simply remuxing existing video and audio into AVI container work for you?
 
1 members found this post helpful.
Old 08-13-2016, 03:50 AM   #6
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 511

Original Poster
Rep: Reputation: 44
Quote:
Why you need to use AVI container? Will simply remuxing existing video and audio into AVI container work for you?
Well, how does that actually work, either in Avidemux or avconv/ffmpeg? Are you saying that in Avidemux I could just change the "Container" dropdown near the bottom of the screen to AVI, leave the other options to just "Copy" and that would work?

I'm trying to make the videos compatible with my DVD player, which has a USB port on the front to play content on a memory stick, but is fussy and does not want to play MP4 or MKV files, only DIVX or XVID files with an AVI extension.

Doing "ffmpeg -i old_video.mp4 -vcodec copy -acodec copy new_video.avi" does not work; it doesn't even preserve audio when I play it back in VLC on my PC!

Neither does using Avidemux as described in my first paragraph above. I cannot see how merely changing the container is going to fool my DVD player into playing a codec it isn't programmed to understand.

Am I doing something wrong? Is it possible your "quick method" you describe could ever work for me?
 
Old 08-13-2016, 03:58 AM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 7,231

Rep: Reputation: Disabled
I was just wondering. H.264 is MPEG-4 Part 10 coder, while Xvid is MPEG-4 Part 2 codec. They both are MPEG-4, although I'm not sure if AVI container can even handle H.264. It seems your hardware player cannot play it, either. Unfortunately, this means you need to re-code.

Edit: https://en.wikipedia.org/wiki/MPEG-4#MPEG-4_Parts

Edit 2: How about retiring this player and replacing it with RPi running OpenElec.

Last edited by Emerson; 08-13-2016 at 04:02 AM.
 
Old 08-13-2016, 09:10 AM   #8
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 3,645
Blog Entries: 2

Rep: Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169
Quote:
I'm trying to make the videos compatible with my DVD player
I don't know what your DVD player is capable of.
DVD standard is mpeg2 video and aac or uncompressed audio. Same as atsc tv signals.

Quote:
I'm not sure if AVI container can even handle H.264.
Yes, you can put 264 and aac or ac3 into an avi. I do it all the time. I would be surprised if a DVD player could play and .avi though.

I don't think that you have said what the audio and video of the original is.
Code:
ffprobe myfile.m4v
https://en.wikipedia.org/wiki/M4V says it is h264 and aac, assuming that it isn't DRM protected.
Code:
ffmpeg -i myfile.m4v -c:a copy -c:v mpeg2video -b:v 2500k output.avi
That will give you (Did a test on a mpeg4 that I had to mpeg2)
Code:
ffprobe output.avi
.......
 Duration: 00:00:51.59, start: 0.000000, bitrate: 2660 kb/s
    Stream #0:0: Video: mpeg2video (Main) (mpg2 / 0x3267706D), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 2538 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
    Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 112 kb/s
DVD standard is also 30 fps, you may have to change that, if it's 24 fps you may need to add frames. (See https://en.wikipedia.org/wiki/Telecine)

I would say that would be your best bet. Make the video conform to DVD standard.
 
Old 08-13-2016, 09:35 AM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 7,231

Rep: Reputation: Disabled
Quote:
DVD standard is mpeg2 video and aac or uncompressed audio. Same as atsc tv signals.
It is MPEG-2 video and AC-3 or (so called) MP2 audio. I've never seen uncompressed audio in DVD's or broadcast.
 
Old 08-13-2016, 04:42 PM   #10
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 3,645
Blog Entries: 2

Rep: Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169
I've seen a DVD from a service that ends with flix that had wave audio. I've seen ac3 on DVD's. If you need ac3 audio then:
Code:
ffmpeg -i myfile.m4v -c:a ac3 -b:a 128k -c:v mpeg2video -b:v 2500k output.avi
To the OP, you don't have to use a fixed bitrates. Those were simple examples.
I tried that example and it workid fine.
Code:
ffprobe output.avi
......
 Metadata:
    encoder         : Lavf57.41.100
  Duration: 00:00:33.23, start: 0.000000, bitrate: 2687 kb/s
    Stream #0:0: Video: mpeg2video (Main) (mpg2 / 0x3267706D), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 2558 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, stereo, fltp, 128 kb/s
I hadn't recorded an atsc TV stream for a while. So I shoved in a tuner and it is indeed ac3, sorry.
Code:
azap -r -c $HOME/.mplayer/channels.conf WABC
cat /dev/dvb/adapter0/dvr0 > tv1.ts
ffprobe tv1.ts
........
Input #0, mpegts, from 'tv1.ts':
  Duration: 00:00:12.74, start: 11638.308489, bitrate: 10374 kb/s
    Stream #0:0[0x31]: Video: mpeg2video (Main), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 16280 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
 
Old 08-24-2016, 02:57 PM   #11
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 511

Original Poster
Rep: Reputation: 44
Thank you to everyone for your advice. Think I'll stick with Avidemux for the best overall result then.

Steve
 
  


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
how do you convert .avi or anything to .ts? iwannalearn Linux - Newbie 6 03-30-2017 11:49 PM
how could I convert 3gp to mp4 with avconv mia_tech Linux - General 1 02-11-2014 07:54 AM
[SOLVED] Using Mencoder or Avidemux to convert to xvid Steve W Linux - Software 2 10-23-2013 06:17 AM
[SOLVED] avconv to convert avi frames to single images tomasdepomas Linux - General 1 10-18-2012 05:32 AM
Gui that convert AVI to AVI DivX, with telling final avi target final size ? frenchn00b Linux - General 5 03-02-2008 05:37 AM

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

All times are GMT -5. The time now is 01:36 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