Find the answer to your Linux question:
Results 1 to 2 of 2
Hi. I had some problems converting mp4's video to mp3 audio files. I searched the web and found three different solutions that all seems to work for other users. I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2013
    Posts
    7

    Hlp understanding terminal commands syntax


    Hi.
    I had some problems converting mp4's video to mp3 audio files. I searched the web and found three different solutions that all seems to work for other users. I did get it working - yet I don't understand why one worked and the two others did not.


    When I tried those solutions I was rather puzzled. I experinced things that was never to been reported by others, ie one of the clever one-liners seemed to destroy the content of the the source mp4's without actually producing any mp3's.

    I am rather new to Linux but I am amazed by the power of the terminal. Seems most things can by done by search and easy tool. Unfortunatly I am new to this way of thinking and solving problems. Earlier I have looked for .exe files or .msi or whatever and dblclicked to add or alter things. So I have major lacks of knowladge of terminal "language".

    Can someone pls explain to me in laymans terms the difference between these three terminal commands?

    #1:
    Code:
    for f in *.mp4; do ffmpeg -i "$f" -vn -b:a libmp3lame -ar 44100 -ac 2 -ab 192k "${f%mp4/mp3}"; done
    #2:
    Code:
    for f in *.mp4; do ffmpeg -i "$f" -acodec libmp3lame  -ab 192 "${f%mp4/mp3}"; done
    #3:
    Code:
    for f in *.mp4; do ffmpeg -i "$f" -ab 320k "${f%.mp4}.mp3"; done
    I do understand some of it after browsing and googling, but I can not see why the outcome is different between them. When navigating to correct folder/directory in terminal the *.mp4 tells ffconvert to convert ALL files within directory to {f%mp4/mp3}, which must be mp4 to mp3. But there are also "$f" -ab 320k.

    In of of the commands there is also an "ac" which is audio channels. But I can not see any place where is says to destroy source files? Or even delete them?

    Why are those 3 commands not working all of them? For me only #3 works. Yet it seems other got the two first ones to work as well.

    I am trying to learn from this so any help would be great. Then maybe next time I run into trouble I have a better chance of examining the commmands and tutorials I find via google. Today I trust those forum post blindly and have no way to see what might work and what might not work.

    And finally are there commands or "tags" used in terminal that are universal? Like across linux/unix platform or are they all program/software specific?

    What is the best way to learn extensive use of terminal for a newbie? As it seems to be one of the slickest ways to operate and maintain computers.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,708
    Have you read the online ffmpeg documentation yet? Try experimenting and not using "canned" procedures. Also note that some videos have multiple audio channels (for different languages), so you may need to take that into account as well. FWIW, simpler is better. I use ffmpeg regularly to transcode videos (usually into mpeg2 DVD format in order to burn on DVDs), but I have also used it to extract the audio on occasion. Also, the options available depend upon the version of ffmpeg you are using - mine is 1.2.3, and here are the audio options for that version:
    Code:
    Audio options:
    -aframes number     set the number of audio frames to record
    -aq quality         set audio quality (codec-specific)
    -ar rate            set audio sampling rate (in Hz)
    -ac channels        set number of audio channels
    -an                 disable audio
    -acodec codec       force audio codec ('copy' to copy stream)
    -vol volume         change audio volume (256=normal)
    -af filter_graph    set audio filters
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •