Page 1 of 1

Converting m2ts for iPhone4 troubles.. (likely acc bug)

Posted: 01 Sep 2010 09:21
by Durentis
I've been trying to figure out how to use VLC to convert from an m2ts file to an mp4 readable by the iPhone 4 with subtitles integrated into the video.. but so far, I've not been able to get a clean output file to even bother testing on the phone.

I'm using VLC v1.1.4 and it can play the m2ts file and select the subtitles from within it (track 2) just fine.

The m2ts file has 5 streams:
  • 0 - 1920x1080p H264 - MPEG-4 AVC (part 10) (h264) at 47.952047 fps
  • 1 - 48kHz DTS Audio at 1536 kb/s
  • 2 - A52 Audio
  • 3 - BD subtitles (bdpg)
  • 4 - BD subtitles (bdpg)
Here's my most recent test case:
  • Open VLC
  • CTRL-R and browse for m2ts file
  • Check 'Show more options'
  • Edit Options is set to ':file-caching=300:sub-track=1'
  • Click the Convert/Save button
  • Set the destination file as e:\output.mp4
  • Check Deinterlace
  • Select profile iPhone 4 (Encapsulation=MP4/MOV; Video codec=H-264, Bitrate=2048, Framerate=30, Scale=1, Width=960; Audio Codec=MPEG4(AAC), Bitrate=160kb/s, Channels=2, Sample Rate=48000; Subtitles=DVB subtitle, Overlay subtitles on the video is checked)
  • Click Start
The end result is a file (1.56GB) that as good quality video, sound with a low pitch warble overlay, and no subtitles.

Now, I'll probably have to back off the bitrates and such for the phone but I don't think it should affect the resulting file for playback on my PC.

I've tried a number of different options and managed to get good quality audio at one point but never any subtitles.

Seems like this process should be pretty straight forward with VLC but I'm not having any luck at all..

Any thoughts on what I'm missing here? I'm completely stumped. :(

Edit: Just to update this w/ further failed attempts.. I switched to the CLI (in Win7 Pro 64bit) in case the GUI is buggy.

The following managed to give me subtitles and good video, but the audio still has that horrible warble throughout:
vlc -vvv "e:\input.m2ts" --sout="#transcode{vcodec=h264,vb=1024,acodec=mp4a,ab=128,soverlay,channels=2,deinterlace,scale=1,width=960,canvas-height=640}:standard{dst=e:/output.mp4,access=file}" --sub-track=1 vlc://quit

(And I'm not sure that -vvv does squat.. certainly no output in the console.)

Re: Converting m2ts for iPhone4 troubles..

Posted: 04 Sep 2010 12:42
by Durentis
Alright.. update time.

I've been trying other versions prior to 1.1.4.. it seems 1.1.4 broke the audio, as it works fine in 1.1.0 through 1.1.3. Turns out the subtitles were always in the video but disappeared when you skip through the video for versions prior to 1.1.2.

This gives a good result when played back in VLC:
vlc -vvv "e:\input.m2ts" --sout="#transcode{width=960,canvas-height=640,vcodec=h264,vb=1536,acodec=mp4a,ab=160,channels=2,deinterlace,soverlay}:standard{dst=e:/output.mp4,access=file}" --sub-track=1 --audio-track=1 vlc://quit

However, playing any of the converted mp4 files (1.1.0 through 1.1.3) in iTunes results in video that shudders (like frames being shown out of sequence: 0,2,1,4,3,6,5,8,7,...) despite it running perfectly smooth in VLC. Even with the shuddering, the audio and subtitles in 1.1.3 are in sync with the video as though it were running smoothly.

I don't know if this last part is an iTunes specific issue or if it will play back the same on the iPhone (can't test yet because FedEx missed their pre-long-weekend delivery date). Maybe It's a bitrate issue or the deinterlace setting? Hopefully it's not another bug in 1.1.3 because that version works great otherwise.

Was feeling pretty close to a solution before the shuddering video in iTunes.

Any thoughts on the shuddering or CLI settings to get a more ideal conversion?

Re: Converting m2ts for iPhone4 troubles..

Posted: 05 Sep 2010 11:25
by Durentis
After a lot more digging into available CLI options and referencing those in use by ipodrookie over at doom9 (http://forum.doom9.org/archive/index.php/t-143854.html), I finally got a conversion in 1.1.3 that works in iTunes. All that remains then is FedEx getting around to delivering my phone so I can test it there.

The problem with the shuddering was a result of bframes. These are supposedly supported by Main Profile Level 3.1 so I assume either iTunes or ffmpeg is gimped in this regard.

Here's the resulting CLI string that finally gave me a positive result on VLC-1.1.3 (though 'venc=x264{bframes=0}' was sufficient):
vlc "e:\input.m2ts" --sout="#transcode{vcodec=h264,venc=x264{profile=main,bframes=0,level=31,ref=6},vb=1536,fps=30.0,width=960,canvas-width=960,canvas-height=640,canvas-aspect=3:2,acodec=mp4a,ab=160,channels=2,soverlay}:standard{dst=e:/output.mp4,mux=mp4,access=file}" --sub-track=1 vlc://quit

Re: Converting m2ts for iPhone4 troubles.. (solved - mostly)

Posted: 08 Sep 2010 13:55
by Durentis
So I finally got the iPhone4 to test on.. the above CLI string works perfectly well except that there's no sound on the iPhone. There is in the resulting .mp4 though because both VLC and iTunes can play it.

But no matter how I mess with the bitrates and other audio settings in the string, I can't get any sound on the phone.

I've noticed that the ab=160 setting isn't respected as I get random audio bitrates in the 130-140ish range. Are my audio settings out of place or messed up in some way or is the AAC encoder flaky in 1.1.3 as well? iTunes generally doesn't let you transfer files to the phone that it can't play, but it's perfectly happy to transfer all of my .mp4 filess made with the above CLI string.

Holy frustrating.. heh

Edit: I'm moving on from VLC until it gets fixed as I'm convinced the problem lies entirely in the AAC encoder and libfaac seems to be missing (dropped?) despite the presence of libfaad. Nothing fancy or out of the ordinary from the above CLI string in VLC using WinFF (w/ libfaac) and I have a perfect working transcode.

Re: Converting m2ts for iPhone4 troubles.. (likely acc bug)

Posted: 09 Sep 2010 00:58
by rogerdpack
Also I heard that the 1.1 version "broke sound" [1] so might want to revert

[1] viewtopic.php?f=14&t=82168

Re: Converting m2ts for iPhone4 troubles.. (likely acc bug)

Posted: 09 Sep 2010 01:46
by Durentis
no, though I suppose it wouldn't hurt. Apple does specifically state h.264 with aac-lc.

Edit: 1.1.4 does encode w/ mp3 but iTunes and the iPhone won't accept it. 1.0.5 doesn't handle BD subtitles. Either way VLC is unusable for me regareless of version until the AAC issue(s) are fixed or I or someone manages to figure out a workaround for the AAC from 1.1.3 not playing on the iPhone.