VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. Member
    Join Date
    Jan 2007
    Location
    United States
    Search PM
    I've read that I can use "ffmpeg -acodec copy" on a video file to extract the audio in its original unaltered format. But if I am trying to use ffmpeg in a batch file to extract audio from a bunch of different video files (MP4, FLV, MOV), then how do I know what extension (AAC, MP3, etc) to specify for the audio file? If I don't specify an extension, then ffmpeg gives me an error:

    Code:
    ffmpeg -i test.mp4 -acodec copy extractedaudio
    FFmpeg version UNKNOWN, Copyright (c) 2000-2009 Fabrice Bellard, et al.
      configuration: --disable-shared --enable-memalign-hack --enable-gpl --cpu=i686
     --enable-libmp3lame --enable-libfaac --enable-libamr-nb --enable-libamr-wb
      libavutil     50. 3. 0 / 50. 3. 0
      libavcodec    52.23. 0 / 52.23. 0
      libavformat   52.32. 0 / 52.32. 0
      libavdevice   52. 2. 0 / 52. 2. 0
      libswscale     0. 7. 1 /  0. 7. 1
      built on Apr  4 2009 11:36:42, gcc: 4.2.1-sjlj (mingw32-2)
    
    Seems stream 1 codec frame rate differs from container frame rate: 59.94 (2997/5
    0) -> 29.97 (30000/1001)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
      Duration: 00:03:05.61, start: 0.000000, bitrate: 2128 kb/s
        Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16
        Stream #0.1(und): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 29.97 t
    br, 29.97 tbn, 59.94 tbc
    Unable to find a suitable output format for 'extractedaudio'
    Last edited by sldvd; 3rd Sep 2010 at 15:36.
    Quote Quote  
  2. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by sldvd View Post
    But if I am trying to use ffmpeg in a batch file to extract audio from a bunch of different video files (MP4, FLV, MOV), then how do I know what extension (AAC, MP3, etc) to specify for the audio file?
    Hi
    I suppose you will need a more sophisticated script that would analyze each file then decide which extension to use.
    In the meantime...
    ... it's quite legal to put mp3 audio in an mp4 container too.
    So your command could be like this:-
    Code:
    ffmpeg -i foo -vn -acodec copy output.mp4
    All your audio files will have the mp4 extension whether they contained aac or mp3 audio.
    (Use the -vn option to disregard the video track)


    It's also possible to use the mka container, though some players might not recognize it.
    Like this:-
    Code:
    ffmpeg -i foo -vn -acodec copy output.mka
    Look here to find out about media containers:-http://en.wikipedia.org/wiki/Comparison_of_media_containers

    EDIT
    There's a problem here.
    If you have a video file named test.mp4 then you use my command to make an audio-only mp4 file you would need to give it a different name such as test_audio.mp4.
    If you use the same filename for the output as the input file you might over-write it.

    Alternatively, you could create a new folder to hold the audio files and direct the output files there.
    Like this:-
    Code:
    ffmpeg -i foo -vn -acodec copy ~/new_folder/output.mp4
    Last edited by bat999; 7th Sep 2010 at 06:59.
    Quote Quote  
  3. Member
    Join Date
    Jan 2007
    Location
    United States
    Search PM
    Thanks for that information. I am just starting to realize the difference between containers and formats.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!