Take the 2-minute tour ×
Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It's 100% free, no registration required.

I'm using this command line to extract the audio

$ffmpeg -i video.mkv -c:a pcm_s16le audio.wav

this is its output

ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct  1 2012 10:47:52 with gcc 4.0.1 (GCC) (Apple Inc. build 5493)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86 --enable-runtime-cpudetect
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.111.0
  Duration: 01:29:59.83, start: 0.000000, bitrate: 832 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406, 762 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 64 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : SoundHandler
Output #0, wav, to 'audio.wav':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.29.104
    Stream #0:0(eng): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:1 -> #0:0 (aac -> pcm_s16le)
Press [q] to stop, [?] for help
size= 1012464kB time=01:29:59.82 bitrate=1536.0kbits/s    
video:0kB audio:1012464kB subtitle:0 global headers:0kB muxing overhead 0.000004%

Then the audio is normalized and put back into the video file

ffmpeg -i video.mkv -i audio_normalized.wav -map 0:0 -map 1:0 -c:v copy -c:a libmp3lame -b:a 64k video_normalized.mkv

Sometimes the video won't play in my ipod touch, or plays muted

When that happens, I convert the video to AVI, with the same quality, wich gives a bigger file more often than not

ffmpeg -sameq -i video.mp4 video.avi

I just wondered whether there is a way to always change the container file to AVI with the same video quality and replace the sound with the normalized audio in one step

share|improve this question
3  
Why do you want AVI? It's dated and modern alternatives exist. Do not use -sameq. –  LordNeckbeard Dec 16 '12 at 17:49
    
@LordNeckbeard Normally I normalize the audio and play the video using iMediaPlayer on my iPod, but sometimes the video is laggy (MKV) or play muted (MP4), so I convert it to AVI because the convertion is rather fast, and -sameq give aceptable quality. I guess I could use other format suported by iMediaPlayer that can be converted fast by ffmpeg. –  rraallvv Dec 16 '12 at 18:29
    
@LordNeckbeard I guess I can test several quality options and formats, to do the fastest conversion posible from MKV or MP4, while maintaining "approximately" the same quality. –  rraallvv Dec 16 '12 at 18:36
    
Please update your question with the complete ffmpeg console output that you get from your first command. Once again, do not use -sameq. It does not mean "same quality" and this option has recently been removed from ffmpeg. –  LordNeckbeard Dec 16 '12 at 19:02
4  
The video might be laggy because not all iDevices can natively decode High profile H.264, although it does not explain why the video would apparently play fine in MP4 container. Try AAC audio in MP4 and see if that is an improvement: ffmpeg -i video.mkv -i audio_normalized.wav -map 0:0 -map 1:0 -c:v copy -c:a aac -strict experimental -b:a 192k video_normalized.mp4 I increased the audio bitrate because the native ffmpeg AAC encoder, aac, isn't great at lower bitrates. –  LordNeckbeard Dec 18 '12 at 2:55
show 4 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.