x264 2-pass not playable in iPhone

  • Thank you for developing this encoder. Finally, I have time to try out your encoder.

    I use 2-pass encoding with ABR set to 2500kbps. The output video plays fine in Windows with MPC-HC, but I cannot stream it using AirVideoHD (http://www.inmethod.com/airvideohd) nor copy it to iPhone (using FileExplorer, https://www.skyjos.com/fileexplorer/) and play it. I also cannot play it using VLC (2.2.8) in Windows. I use x264 video, AAC audio with MP4 container.

    However, if I use CRF set to 23 (or any number), while everything else remains the same, AirVideoHD and FE and iPhone will play it nicely.

    Please see log file, screenshots and sample video that is not playable on iPhone.

    Merry Christmas!

    • Official Post

    If you are targeting a hardware decode (i.e. iPhone) you need to take care about the decoding capabilities and feature sets supported. This is normally defined in the so called "Levels".

    Did you try encoding the 2-pass video with ffmpeg? Does this play on the iPhone?

  • Hi Vouk,

    Thanks for the quick reply. No, I don't have ffmpeg with x264 to try encode for iPhone. Or, do you mean using the "FFmpeg video codec #1" in the video encoder menu? But, that option does not have control for bit rates or quality.

    Anyway, I did try with latest version of Handbrake (1.2.0) and it gives good result. In fact, I started with modifying the setting on voukodor 1.1.3 to match exactly with Handbrake. I have attached the mediainfo outputs of Handbrake vs Voukodor as comparison. The main difference I see is the "Codec ID": HB: mp42, Voukodor: isom, and I don't see how to make Voukodor outputs with codec id "mp42". All other fields are almost identical, including the format profile and levels.

  • I play around with the output file and here is what I found:

    There are a couple of unrecognized lines in the video output file. Namely:

    $ mediainfo 10Sec.mp4



    Complete name : 10Sec.mp4

    Format : MPEG-4

    Format profile : Base Media

    Codec ID : isom (isom/iso2/avc1/mp41)

    File size : 5.42 MiB

    Duration : 16s 427ms

    Overall bit rate : 2 770 Kbps

    Encoded date : UTC 1904-01-01 00:00:00

    Tagged date : UTC 2018-12-25 08:29:25

    Writing application : Voukoder 1.1.3 (Premiere) - http://www.voukoder.org

    ©TIM : 00;00;00;00

    ©TSC : 30000

    ©TSZ : 1001


    I tried split up the audio and video streams with MP4Box and combine back again and the output file works great with iPhone:

    $ MP4Box -raw 1 10Sec.mp4 -out out.avc

    [iso file] Unknown box type .TIM

    [iso file] Unknown box type .TSC

    [iso file] Unknown box type .TSZ

    Extracting MPEG-4 AVC-H264 stream to h264

    $ MP4Box -raw 2 10Sec.mp4 -out out.aac

    [iso file] Unknown box type .TIM

    [iso file] Unknown box type .TSC

    [iso file] Unknown box type .TSZ

    Extracting MPEG-4 AAC

    $ MP4Box -flat -add out.avc -add out.aac out.mp4

    [avc-h264] Possible Variable Frame Rate: VUI "fixed_frame_rate_flag" absent.

    AVC-H264 import - frame size 1920 x 1080 at 29.970 FPS

    AVC Import results: 984 samples (994 NALUs) - Slices: 4 I 292 P 688 B - 2 SEI - 4 IDR

    Stream uses forward prediction - stream CTS offset: 2 frames

    AAC ADTS import - sample rate 48000 - MPEG-4 audio - 2 channels

    Saving out.mp4: Flat storage

    The recombined output from MP4Box works great with iPhone (attached mediainfo output for reference).

    So, it seems there is a problem with muxer. Thanks for looking into it.

    • Official Post

    Thanks for analyzing this!

    Note to myself:

    av_dict_set(&formatContext->metadata->metadata, "major_brand", type, 0);

    av_dict_set_int(&formatContext->metadata->metadata, "minor_version", minor_ver, 0);

  • Vouk

    Added the Label Planned
    • Official Post



    major_brand : mp42

    minor_version : 0

    compatible_brands: mp42mp41


    major_brand : MSNV

    minor_version : 19474624

    compatible_brands: MSNVmp42isom


    major_brand : M4V

    minor_version : 1

    compatible_brands: M4V mp42isom