Announcement

Collapse
No announcement yet.

avconv: convert .avi to different codec

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    avconv: convert .avi to different codec

    Hello again...

    I have some .avi files with a codec that is unsupported by RaspBMC, so I'd like to re-encode them.

    The unsupported codec is "MS MPEG-4 Video v3 (DIV3)" and I'd like to use "libx264".

    I've had a go at converting one of the files but I've been having some problems. Here's the output:

    Code:
    feathers-mcgraw@62-West-Wallaby-Street:/data/Videos/South Park/South Park - Season 01 - (1997 - 1998)$ avconv -i INPUT.avi -vcodec libx264 OUTPUT.avi
    avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
      built on Mar 30 2013 22:20:06 with gcc 4.7.2
    Input #0, avi, from 'INPUT':
      Duration: 00:24:08.78, start: 0.000000, bitrate: 868 kb/s
        Stream #0.0: Video: msmpeg4, yuv420p, 464x352, 23.98 tbr, 23.98 tbn, 23.98 tbc
        Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s
    [buffer @ 0x20fea00] w:464 h:352 pixfmt:yuv420p                                               
    Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'                 
    [libx264 @ 0x2113120] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT     
    [libx264 @ 0x2113120] profile Main, level 2.1                                                 
    [ac3 @ 0x21138e0] invalid bit rate
    Output #0, avi, to 'S01E01.avi':
        Stream #0.0: Video: libx264, yuv420p, 464x352, q=-1--1, 90k tbn, 23.98 tbc
        Stream #0.1: Audio: ac3, 48000 Hz, stereo, flt, 200 kb/s
    Stream mapping:
      Stream #0:0 -> #0:0 (msmpeg4 -> libx264)
      Stream #0:1 -> #0:1 (mp3 -> ac3)
    Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
    I'm out of my depth here, any help would be fantastic.

    Thanks,

    Feathers
    samhobbs.co.uk

    #2
    Searching with the 'avconv conversion mp3 -> ac3 Error while opening encoder '

    A hit: avconv giving error on audio stream - http://superuser.com/questions/42697...n-audio-stream


    Testing at here - the ac3 codec seems to need more information - with the
    Code:
    avconv -i Test.wmv -c:a ac3 Test.avi
    There is an error:
    Stream #0:0 -> #0:1 (wmav2 -> ac3)
    Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
    With the bit rate:
    Code:
    avconv -i Test.wmv -c:a ac3 -b:a 448000 Test.avi
    no problems

    More: http://libav.org/avconv.html#toc-Codec-AVOptions

    ---------EDIT---------

    Should be '-b:a 48000'

    Last edited by Rog132; Oct 05, 2013, 10:44 AM.
    A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
    Searching FAQ's: Google Search 'FAQ from Kubuntuforums'

    Comment


      #3
      Thanks for that! How do I choose a bit rate?

      I guess setting it above a certain value will be a waste, as the original encoder will have lost some info?

      Feathers
      samhobbs.co.uk

      Comment


        #4
        Bitrate

        You pick the bitrate so that it satisfies your needs. With the video you don't see artifacts and with the audio it sounds good.

        Higher bitrates are usually easier on the low end systems.

        If you are squeezing files to the limited space then there are calculators to estimate the space consumption.

        As example the Avidemux calculator:

        A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
        Searching FAQ's: Google Search 'FAQ from Kubuntuforums'

        Comment


          #5
          Ok thanks!

          I've written a little BASH script to convert the files because there are so many of them. I'll post it here just in case it's useful to someone:

          Code:
          #!/bin/bash
          
          if [ $# -ne 2 ]; then
          echo "Usage: $0 source target"
          exit
          fi
          
          SOURCE_DIR=$1
          TARGET_DIR=$2
          IFS=''
          
          for file in $SOURCE_DIR/*.AVI $SOURCE_DIR/*.avi
          do
          echo "infile: $file"
          out_file=$TARGET_DIR/"${file##*/}"
          out_file="${out_file%.*}".avi
          echo "outfile: $out_file"
          avconv -i "$file" -vcodec libx264 -c:a ac3 -b:a 48000 "$out_file"
          done
          The script works for me, but if can see a better way to write it I'd be interested in learning how and why!

          Feathers
          Last edited by Feathers McGraw; Oct 05, 2013, 11:29 AM. Reason: fixed error - thanks GreyGeek
          samhobbs.co.uk

          Comment


            #6
            Originally posted by Feathers McGraw View Post
            Ok thanks!

            I've written a little BASH script to convert the files because there are so many of them. I'll post it here just in case it's useful to someone:

            Code:
            .....
            avconv -i "$file" -vcodec libx264 -c:a ac3 -b:a 448000 "$out_file"
            ...
            The script works for me, but if can see a better way to write it I'd be interested in learning how and why!

            Feathers
            You say it works for you, but shouldn't "-b:a 448000" be "-b:a 44800" Nearly half a million bit rate seems high. Is Avconf defaulting to another bit rate?

            BTW, thanks for that script. It is a classic example of how software is written and improved upon in the open or GPL environment. In other environments a person is tempted to take the input from others, add it to their code (if not outright steal the code), compile and/or obfuscate it, then copyright it and sell it. After that, no one benefits except the thief.
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Ha!

              How on earth did you spot that? Keen eye you have there, thanks a lot!

              I'll change the script and edit the original post. Maybe it'll encode faster now!

              Feathers
              samhobbs.co.uk

              Comment


                #8
                Can you find the "n"
                mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                mmmmmmmmmmmmmmmmmmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                mmmmmmmmmmmmm
                "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                – John F. Kennedy, February 26, 1962.

                Comment


                  #9
                  Originally posted by GreyGeek View Post
                  Can you find the "n"
                  mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                  mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                  mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                  mmmmmmmmmmmmmmmmmmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                  mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                  mmmmmmmmmmmmm
                  The length of the strings is a bit of a give away.

                  Comment


                    #10
                    Originally posted by kubicle View Post
                    The length of the strings is a bit of a give away.
                    Even knowing that, I can't see it - it's making my eyes go funny!
                    samhobbs.co.uk

                    Comment


                      #11
                      Originally posted by greygeek View Post
                      can you find the "n"
                      mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                      mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                      mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                      mmmmmmmmmmmmmmmmmmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
                      mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                      mmmmmmmmmmmmm
                      ;d
                      vinny
                      i7 4core HT 8MB L3 2.9GHz
                      16GB RAM
                      Nvidia GTX 860M 4GB RAM 1152 cuda cores

                      Comment


                        #12
                        Congrats, you win!!
                        samhobbs.co.uk

                        Comment


                          #13
                          How about now?
                          mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                          mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                          mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmm
                          mmmmmmmmmmmmmmmmmmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                          mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mmmm
                          mmmmmmmmmmmmm
                          Kubical, the length of the line sure shortens the search!
                          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                          – John F. Kennedy, February 26, 1962.

                          Comment

                          Working...
                          X