Blog‎ > ‎

Youtube to iPhone best quality audio

posted Jul 22, 2018, 7:47 AM by MUHAMMAD MUN`IM AHMAD ZABIDI   [ updated Jul 23, 2018, 3:23 AM ]
The iPhone uses the m4a format which supersedes mp3. The best codec is Fraunhofer, which is non GPL compliant.

To convert a YouTube video to Fraunhofer m4a, download the audio then open the audio file in iTunes if possible. Then simply save in m4a format.

If you don't care for the best format, skip this post. There are simpler ways to get the m4a files directly from YouTube.

When you asked for the best audio quality, YouTube will probably give you OGG and OPUS files which are not recognized by iTunes. So multiples steps are required.

First give the command to extract the best audio in the codec used by YouTube. Enter command in GREEN.

BigMac:~ munim$ youtube-dl -f bestaudio --extract-audio  --audio-quality 0
[youtube] zRIbf6JqkNc: Downloading webpage
[youtube] zRIbf6JqkNc: Downloading video info webpage
[youtube] zRIbf6JqkNc: Extracting video information
WARNING: unable to extract uploader nickname
[download] Destination: Guns N' Roses - Don't Cry-zRIbf6JqkNc.webm
[download] 100% of 4.59MiB in 01:58
[ffmpeg] Destination: Guns N' Roses - Don't Cry-zRIbf6JqkNc.opus
Deleting original file Guns N' Roses - Don't Cry-zRIbf6JqkNc.webm (pass -k to keep)

Then use ffmpeg with libfdk option. You must have previously compiled ffmpeg with libfdk. Enter command in GREEN.

BigMac:~ munim$ ffmpeg -i Guns\ N\'\ Roses\ -\ Don\'t\ Cry-zRIbf6JqkNc.opus -c:a libfdk_aac DontCry.m4a
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.1.2_1/include/openjpeg-2.1 --enable-nonfree --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, ogg, from 'Guns N' Roses - Don't Cry-zRIbf6JqkNc.opus':
  Duration: 00:05:13.05, start: 0.007500, bitrate: 121 kb/s
    Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp
      LANGUAGE        : eng
      ENCODER         : Lavf57.71.100
Stream mapping:
  Stream #0:0 -> #0:0 (opus (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
Output #0, ipod, to 'DontCry.m4a':
    encoder         : Lavf57.71.100
    Stream #0:0(eng): Audio: aac (libfdk_aac) (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 139 kb/s
      LANGUAGE        : eng
      encoder         : Lavc57.89.100 libfdk_aac
size=    5395kB time=00:05:13.03 bitrate= 141.2kbits/s speed=30.8x   
video:0kB audio:5337kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.089336%

BigMac:~ munim$ ls Guns*
Guns N' Roses - Don't Cry-zRIbf6JqkNc.opus