Body: <p>I'm using this command line to extract the audio</p>
  
  <pre><code>$ffmpeg -i video.mkv -c:a pcm_s16le audio.wav
  </code></pre>
  
  <p>this is its output</p>
  
  <pre><code>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 -&gt; #0:0 (aac -&gt; 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%
  </code></pre>
  
  <p>Then the audio is normalized and put back into the video file</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Sometimes the video won't play in my ipod touch, or plays muted</p>
  
  <p>When that happens, I convert the video to AVI, with the same quality, wich gives a bigger file more often than not</p>
  
  <pre><code>ffmpeg -sameq -i video.mp4 video.avi
  </code></pre>
  
  <p>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</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-16T17:49:00.557Z
Comments.Text: Why do you want AVI? It's dated and modern alternatives exist. [Do not use `-sameq`](http://superuser.com/a/478550/110524).
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-16T18:29:51.200Z
Comments.Text: @LordNeckbeard Normally I normalize the audio and play the video using [iMediaPlayer](https://itunes.apple.com/us/app/imedia-player/id544635606) 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.
Comments.UserDisplayName: rraallvv
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-16T18:36:58.550Z
Comments.Text: @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.
Comments.UserDisplayName: rraallvv
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-16T19:02:30.593Z
Comments.Text: 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.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-16T21:40:27.850Z
Comments.Text: @LordNeckbeard I've added the output, but removed the metadata
Comments.UserDisplayName: rraallvv
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-17T17:08:27.890Z
Comments.Text: The console output is missing stuff. I was interested in the ffmpeg version and the input and output file details. You should include everything except errors that repeat many times.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-18T00:30:34.107Z
Comments.Text: @LordNeckbeard added the missing stuff, it shows ver 1.0, and there is also the metadata
Comments.UserDisplayName: rraallvv
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-18T02:55:42.933Z
Comments.Text: 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.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-12-18T05:02:52.833Z
Comments.Text: Thanks a lot... the video plays smoothly, I can accept your suggestion on the comment as the answer.
Comments.UserDisplayName: rraallvv
Tags: <video><conversion><ffmpeg>
Title: ffmpeg - convert video to iDevice format, replace sound with normalized WAV file, while maintaining the original video quality?
UserDisplayName: rraallvv
ThreadText: # ffmpeg - convert video to iDevice format, replace sound with normalized WAV file, while maintaining the original video quality?
  
  (Asked by: username_0 on 2012-12-15)
  
  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
  
  **Tags:** video, conversion, ffmpeg
  
  > **Comments:**
  > **username_1**: Why do you want AVI? It's dated and modern alternatives exist. [Do not use `-sameq`](http://superuser.com/a/478550/110524).  
  > **username_0**: @LordNeckbeard Normally I normalize the audio and play the video using [iMediaPlayer](https://itunes.apple.com/us/app/imedia-player/id544635606) 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.  
  > **username_0**: @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.  
  > **username_1**: 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.  
  > **username_0**: @LordNeckbeard I've added the output, but removed the metadata  
  > **username_1**: The console output is missing stuff. I was interested in the ffmpeg version and the input and output file details. You should include everything except errors that repeat many times.  
  > **username_0**: @LordNeckbeard added the missing stuff, it shows ver 1.0, and there is also the metadata  
  > **username_1**: 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.  
  > **username_0**: Thanks a lot... the video plays smoothly, I can accept your suggestion on the comment as the answer.  
  
  ---
  
  ## 0 answers
  
  