Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I normally use avidemux to convert mp4s to Xvid AVI for my Philips Streamium SLM5500. Normally I select MPEG-4 ASP (Xvid) at Two Pass with an average bitrate f 1500kb/s for video and AC3 (lav) audio and it converts correctly.

However, I'm trying to using avconv so I can automate the process with a script, but when I do this the video stutters and stops playing part way through. I have a suspicion its something to do with a faulty audio conversion.

The commands I'm using are as follows:

avconv -y -i video.mp4 -pass 1 -vtag xvid -c:a ac3 -b:a 128k -b:v 1500k -f avi /dev/null
avconv -y -i video.mp4 -pass 2 -vtag xvid -c:a ac3 -b:a 128k -b:v 1500k -f avi video.avi

There is a bewildering array of arguments for avconv. Is there something I'm doing wrong? Is there a way I can script avidemux from a headless server?

Please see command line output:

$ avconv -y -i video.mp4 -pass 1 -vtag xvid -an -b:v 1500k -f avi /dev/null
avconv version 0.8.5-6:0.8.5-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Jan 24 2013 14:49:20 with gcc 4.7.2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-02-04 13:53:38
  Duration: 00:44:09.16, start: 0.000000, bitrate: 669 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 720x404 [PAR 1:1 DAR 180:101], 538 kb/s, 25 fps, 25 tbr, 100 tbn, 50 tbc
    Metadata:
      creation_time   : 2013-02-04 13:53:38
    Stream #0.1(und): Audio: ac3, 44100 Hz, stereo, s16, 127 kb/s
    Metadata:
      creation_time   : 2013-02-04 13:53:42
[buffer @ 0x7f4c40] w:720 h:404 pixfmt:yuv420p
Output #0, avi, to '/dev/null':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-02-04 13:53:38
    ISFT            : Lavf53.21.1
    Stream #0.0(und): Video: mpeg4, yuv420p, 720x404 [PAR 1:1 DAR 180:101], q=2-31, pass 1, 1500 kb/s, 25 tbn, 25 tbc
    Metadata:
      creation_time   : 2013-02-04 13:53:38
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
Press ctrl-c to stop encoding
frame=66227 fps=328 q=2.0 Lsize=       0kB time=2649.16 bitrate=   0.0kbits/s    
video:401602kB audio:0kB global headers:0kB muxing overhead -100.000000%
$ avconv -y -i video.mp4 -pass 2 -vtag xvid -c:a ac3 -b:a 128k -b:v 1500k -f avi video.avi
avconv version 0.8.5-6:0.8.5-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Jan 24 2013 14:49:20 with gcc 4.7.2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-02-04 13:53:38
  Duration: 00:44:09.16, start: 0.000000, bitrate: 669 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 720x404 [PAR 1:1 DAR 180:101], 538 kb/s, 25 fps, 25 tbr, 100 tbn, 50 tbc
    Metadata:
      creation_time   : 2013-02-04 13:53:38
    Stream #0.1(und): Audio: ac3, 44100 Hz, stereo, s16, 127 kb/s
    Metadata:
      creation_time   : 2013-02-04 13:53:42
[buffer @ 0x12b4f00] w:720 h:404 pixfmt:yuv420p
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[mpeg4 @ 0x12b3ec0] [lavc rc] Using all of requested bitrate is not necessary for this video with these parameters.
Output #0, avi, to 'video.avi':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-02-04 13:53:38
    ISFT            : Lavf53.21.1
    Stream #0.0(und): Video: mpeg4, yuv420p, 720x404 [PAR 1:1 DAR 180:101], q=2-31, pass 2, 1500 kb/s, 25 tbn, 25 tbc
    Metadata:
      creation_time   : 2013-02-04 13:53:38
    Stream #0.1(und): Audio: ac3, 44100 Hz, stereo, flt, 128 kb/s
    Metadata:
      creation_time   : 2013-02-04 13:53:42
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
  Stream #0:1 -> #0:1 (ac3 -> ac3)
Press ctrl-c to stop encoding
Input stream #0:1 frame changed from rate:44100 fmt:s16 ch:2 to rate:44100 fmt:flt ch:2
frame=66227 fps=284 q=2.2 Lsize=  458486kB time=2649.13 bitrate=1417.8kbits/s    
video:413716kB audio:41393kB global headers:0kB muxing overhead 0.741969%
share|improve this question
add comment

1 Answer 1

with several pass, you should deactivate audio on pass 1, with the -an option, so :

avconv -y -i video.mp4 -pass 1 -vtag libxvid -an -b:v 1500k -f avi /dev/null
share|improve this answer
    
Why do I need to deactivate audio on the first pass? –  Ricardo Gladwell Feb 28 '13 at 0:00
    
That seemed to make no difference to the output. –  Ricardo Gladwell Feb 28 '13 at 0:18
    
they recommand in the man page to deactivate audio (-an) and set output to null (dev/null), but you are not forced to. please try it this way : avconv -y -i vid.mp4 -pass 1 -vtag xvid -b:v 1500k -c:a ac3 -b:a 128k vid1.avi and avconv -y -i vid.mp4 -pass 2 -vtag xvid -b:v 1500k -c:a ac3 -b:a 128k vid2.avi report your log if this doesnt work. according to your source (format and resolution), difference in vid1 and vid2 can be quite little. –  riimzzai Feb 28 '13 at 12:11
    
I'm not sure I see how those commands are different. I've attached a log above. –  Ricardo Gladwell Mar 1 '13 at 15:32
    
2nd command (with -pass 2) uses the log file created with the 1st command (with -pass 1) to generate vid2. if you try without the /dev/null you can compare the vid1 and vid2 and see how they are different in quality and size of file. but for sure you will never use the the -pass1 option without -pass2. personally i don't use much this option... difference is too insignificant with a standard conversion. but it depends on your source format. at least your log seems to show that your audio prbl is solved :) –  riimzzai Mar 3 '13 at 15:48
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.