View Full Version : x264/AVI to MP4 conversions choppy
toejam13
27th June 2005, 06:53
All,
I am sorry if this is a repost. I spent about an hour looking for a similar question and didn't see any clear response.
Tools used:
VirtualDubMod 1.5
x264 VFW Revision 270
avi2raw 1.2.8
mp4box gpac 0.3.0
ffdshow-20050303
Media Player Classic 6.4
VLC 0.8.2
I encoded my movie using VDM and x264. The codec was configured with all options enabled except 8x8 DCT. B-frames were set to "max consecutive: 3". Partition quality was set to "6/RDO", ME method was set to "exhaustive". Video size was 480x480, frame rate was 24fps, target bitrate was set to 1000Kb/s (dual pass). Movie was saved within an AVI container. No audio was encoded into the AVI.
The movie plays wonderful in MPC and VLC.
I then ran the AVI through AVI2RAW and exported a raw H264 file. I then ran that file through MP4BOX and exported a MPEG-4 system file.
MP4BOX gives the following stats about my video:
Import results: 180056 samples - Slices: 2089 I 68397 P 109570 B - 1 SEI - 1942 IDR
The file plays in both MPC and VLC, however the video is choppy in some sections. CPU utilization never goes above 28%, so its not due to limited processor time.
If I re-run the raw H264 file through MP4BOX with an audio source muxed in (AAC audio file encoded in Nero), the audio plays fine. However, the video is still choppy.
Is this a limitation of the media player, a poor conversion by MP4BOX, or out-of-spec frame generation by x264?
Thank you in advance.
bond
27th June 2005, 11:09
first of all you can encode with x264 directly to .mp4. there is no need to go via .avi
just use megui for that
than plz post the complete commandline you used
if possible upload a small .avi sample which can be used to reproduce the choppyness
than what you describe sounds like you used an old version of mp4box for muxing. than again you write that its 0.3.0 which should be a new one
you can also try to mux with mp4creator (compile from celtic_druid) to .mp4 and check if its choppy too
than i want to know which filters you used for playing the file in MPC, nero or haali or ffdshow or...?
moved to where it belongs
toejam13
28th June 2005, 07:45
Quote from bond
first of all you can encode with x264 directly to .mp4. there is no need to go via .avi
Actually, I may be forced to go with this method. My version of x264.exe (build 269) seems to be incompatable with VFAPIConv (FourCC: vifp) AVI files.
When I attempt to import a VIFP-AVI directly into x264.exe, it aborts with the error message:
. avis [error]: unsupported input format (VIFP)
. could not open input file 'movie-intro_tpr_vfapi.avi'
When I try to import the same VIFP-AVI running through Avisynth (version 2.5) with either an AVISource() or DirectShowSource() call, it aborts with the error message:
. avis [error]: unsupported input format (DIB )
. could not open input file 'movie-intro.avs'
VirtualDubMod 1.5 can handle both the VIFP-AVI and the AVS fine, so I think it may be a limitation of x264.exe.
you can also try to mux with mp4creator (compile from celtic_druid) to .mp4 and check if its choppy too
I replaced mp4box with mp4creator and tried again:
demux my H264-AVI with avi2raw-1.2.8
multiplex my H264-RAW with mp4creator-1.3
display using vlc-0.8.2
The video was still choppy in the same locations as when I used mp4box to store the video stream in a MP4 container. Again, CPU never peaks above 30% and it only occurs in scenes that tend to pan or zoom.
I also tried mp4box again with the "-isma" flag to no avail.
I tried a few loss-less codecs to get around the VIFP issue, but those codecs are not compatable with x264.exe.
Suggestions?
toejam13
28th June 2005, 08:21
Also...
When playing back in VLC with debug logging enabled, the following line is displayed in the debug console each time the video stream stutters:
[h264 @ 009298F8]concealing 0 DC, 0 AC, 0 MV errors
bond
28th June 2005, 10:46
what are VIFP-AVI files? is VIFP a codec?
if you can open such a file in virtualdub you should also be able to open it via avisource() and x264.exe, cause all three use the same method to open the file: vfw
you use mp4creator 1.3, there is already 1.3.2, always use the latest version!
than let me repeat:
post the complete commandline you usedupload a small .avi sample which can be used to reproduce the choppynessi want to know which filters you used for playing the file in MPC, nero or haali or ffdshow or...?
toejam13
28th June 2005, 21:19
what are VIFP-AVI files? is VIFP a codec?
VFAPI Reader encoded files. (http://www.doom9.org/index.html?/mpg/vfapi_reader_codec.htm)
if you can open such a file in virtualdub you should also be able to open it via avisource() and x264.exe, cause all three use the same method to open the file: vfw
Then I must be encountering a bug with x264.exe. Virtual Dub and Media Player can read the AVI files while x264.exe can not. I've already listed the error message x264.exe generates above.
post the complete commandline you used
For AVI2RAW:
avi2raw movie.h264.avi movie.h264
For MP4BOX:
mp4box -fps 24 -add movie.h264 movie.mp4
For MP4CREATOR:
mp4creator -rate=24 -create=movie.h264 movie.mp4
i want to know which filters you used for playing the file in MPC: nero or haali or ffdshow
FFDShow-20050303
Note:
I upgraded my FFDShow codec to 20050619 and strangely enough Media Player Classic will no longer render my MP4 files (even after reassigning FFDShow to all formats within its decoder configuration tool), although Nero ShowTime still plays them using FFDShow to decode them. (I don't have a Nero H264/AVC license, so ShowTime uses FFDShow)
upload a small .avi sample which can be used to reproduce the choppyness
<LINK REMOVED>
you use mp4creator 1.3, there is already 1.3.2, always use the latest version!
The newest version I've been able to find is 1.3. If you have a URL for the 1.3.2 mp4creator and/or mpeg4ip-toolbox, I will download it ASAP and try again.
bond
28th June 2005, 22:05
ok i now checked it myself and i also get a few jerks here and there. as i have a weak cpu i am not sure if this is because of the lack of cpu (but shouldnt be the case with a 480x480 resolution stream)
1) the cts seems to be fine and is the same with both mp4box and mp4creator
also the nero parser shows the choppyness, so its not a cts error
2) your ffdshow from march is totally outdated, but i also get a jerks with latest ffdshow
3) your stream is 480x480?
try resizing to a sane resolution via avisynth (so no anamorphic resize is done) and check whether playback is still jerky (maybe your graphic card has problems with anamorphic resize like mine (nvidia tnt2))
4) i assume these VFAPI fake .avi files are not decoded via vfw, x264.exe only handles .avi files which can be decoded via vfw
i guess your input is mpeg-1 or mpeg-2? try decoding via dgdecode in avisynth without vfapi
5) try using exactly the same settings on the x264.exe commandline (eg via megui) together with directly outputting to .mp4 and report back if the result is also choppy
toejam13
28th June 2005, 23:33
1) the cts seems to be fine and is the same with both mp4box and mp4creator also the nero parser shows the choppyness, so its not a cts errorI'll assume that having a correct CTS is a good thing.
2) your ffdshow from march is totally outdated, but i also get a jerks with latest ffdshowWhich is why I updated from 20050303 to 20050619 when testing. However, the 20050619 did something to MPC so I can no longer use that as a media playback option. I've gone into the FFDShow configuration utility and reapplied all of the MPEG4 codecs to libavcodec, but MPC still refuses to view my MP4 files now. Weird.
3) your stream is 480x480? try resizing to a sane resolution via avisynth (so no anamorphic resize is done) and check whether playback is still jerky (maybe your graphic card has problems with anamorphic resize like mineThe original VOB files are 720x480. I performed a resize within VirtualDub to make the video compress better with the low 1000Kbit/s bitrate.
I re-encoded the scene with the resolution unchanged at 720x480. No difference. Video is still jerky.
FYI, my video card is a Geforce 6600GT with Forceware driver rev 77.72.
4) i assume these VFAPI fake .avi files are not decoded via vfwMy understanding is that it is registered as a valid VFW codec. Almost every utility I have in my collection (VirtualDubMod-1.5, TMPEnc-2.5, Xilisoft 3G-2.1.46, Media Player-9.0, Media Player Classic-6.4, VLC-0.8.2., WinAMP-5.092) will play VFAPI VIFP-AVI videos. Other than x264.exe, the only other app that does not is Quicktime-7.0.2a.
i guess your input is mpeg-1 or mpeg-2? try decoding via dgdecode in avisynth without vfapiCorrect. The video is sourced from a DVD. The VOB files were touched with DVD-Decryptor-3.5.4.0 before imported into DGIndex 1.2.1. The audio was decoded to WAV and the video saved into a *.d2v project file. Then, I imported the DGIndex .d2v project into VFAPI Reader where the video was saved into a *.avi wrapper file. Next, I imported the AVI into VirtualDubMod-1.5, applied a resize filter, and finally performed my two pass encode using x264.
Let me update my version of DGIndex/DGMPGDec to 1.4.0rc4 and see if that helps. I'll also try to bypass the VFAPI step and import the *.d2v project file into AviSynth directly.
bond
29th June 2005, 00:00
another idea:
try disabling b-pyramid and check if the choppyness goes away, than try disabling b-frames too and check
I'll assume that having a correct CTS is a good thing.yes
Which is why I updated from 20050303 to 20050619 when testing. However, the 20050619 did something to MPC so I can no longer use that as a media playback option. I've gone into the FFDShow configuration utility and reapplied all of the MPEG4 codecs to libavcodec, but MPC still refuses to view my MP4 files now. Weird.you have to enable "h.264"
The original VOB files are 720x480. I performed a resize within VirtualDub to make the video compress better with the low 1000Kbit/s bitrate.absolutely not necessary and a bad idea
I re-encoded the scene with the resolution unchanged at 720x480. No difference. Video is still jerky.hm did you try with the nero decoder too? also try latest ffdshow as described above
My understanding is that it is registered as a valid VFW codec. Almost every utility I have in my collection (VirtualDubMod-1.5, TMPEnc-2.5, Xilisoft 3G-2.1.46, Media Player-9.0, Media Player Classic-6.4, VLC-0.8.2., WinAMP-5.092) will play VFAPI VIFP-AVI videos. Other than x264.exe, the only other app that does not is Quicktime-7.0.2a.i dunno, but i assume its a vfw codec
Correct. The video is sourced from a DVD. The VOB files were touched with DVD-Decryptor-3.5.4.0 before imported into DGIndex 1.2.1. The audio was decoded to WAV and the video saved into a *.d2v project file. Then, I imported the DGIndex .d2v project into VFAPI Reader where the video was saved into a *.avi wrapper file. Next, I imported the AVI into VirtualDubMod-1.5, applied a resize filter, and finally performed my two pass encode using x264.
no need to go via vfapi
simply load the .d2v via mpeg2source and by loading dgdecode.dll (the decoder) into an avisynth script (as also described in doom9s various guides)
after that feed x264.exe with it!
toejam13
29th June 2005, 03:26
no need to go via vfapi, simply load the .d2v via mpeg2source and by loading dgdecode.dll (the decoder) into an avisynth script (as also described in doom9s various guides), after that feed x264.exe with it!
..
another idea: try disabling b-pyramid and check if the choppyness goes away, than try disabling b-frames too and check
Done. I replaced the AVISource() and DirectShowSource() calls in my AVS script with MPEG2Source(), skipping the VFAPI Reader AVI wrapper.
My initial encode with the same specs as in VirtualDubMod/x264-VFW showed the same skipping error:
x264 -B 1000 -p 2 -b 3 -A all -m 6 -o movie.mp4 movie.avs
My next encode was to decrease the B-frame length from 3 to 1:
x264 -B 1000 -p 2 -b 1 -A all -m 6 -o movie.mp4 movie.avs
The resulting video plays fine with VLC with no more choppiness.
So the question is... why can I use a B-frame length of 3 with AVI files but no more than 1 with MP4 files?
bond
29th June 2005, 11:05
hm if didnt tell the opposite i would say this smells like a lack of cpu error
also try different players so you can be sure its not an error in vlc:
so what result do you get for the 3 b-frames sample in a dshow based player, eg with the ffdshow or nero decoder
also try different parser (nero and haali)
can you upload this 3 b-frames sample outputted by x264.exe too plz
toejam13
30th June 2005, 19:58
hm if didnt tell the opposite i would say this smells like a lack of cpu error
CPU utilization is typically < 30%. When Cool&Quiet drops my MULTI from x12 to x5, CPU utilization still remains < 50%.
also try different parser (nero and haali)
This has corrected the issue with MPC not being able to read .MP4 files. I notice that it still uses ffdshow for decoding, though.
also try different players so you can be sure its not an error in vlc:
so what result do you get for the 3 b-frames sample in a dshow based player, eg with the ffdshow or nero decoder
When playing the .MP4 files back in Nero ShowTime, the jerking is still there, but not as bad as in VLC.
When playing the .MP4 files back in MPC, the jerking is no longer there.
can you upload this 3 b-frames sample outputted by x264.exe too plz
http://www.capybara.org/~drizzit/mp4-clips.zip
The .MP4 files were encoded using x264.exe & Avisynth (same flags as before).
The .AVI files were encoded with VirtualDub, VFAPI Reader & x264-VFW.
This file has brought me over my disk quota, so it will only be available for 7 days (when the quota daemon will then delete it).
When playing the .MP4 files back in Nero ShowTime, the jerking is still there, but not as bad as in VLC.
When playing the .MP4 files back in MPC, the jerking is no longer there.which filters did you use for playing the file in showtime and MPC?
its strange that there is a difference between the players, cause they should normally use the same filters
http://www.capybara.org/~drizzit/mp4-clips.zip
The .MP4 files were encoded using x264.exe & Avisynth (same flags as before).i tested the samples:
cant get the 3b mp4 sample to play in videolan correctly (one time showed only a black picture, than it showed decoding artefacts)
i assume either vlc isnt stable or the compile of vlc i have uses an old libavcodec not able to decode the stream correctly
mplayer plays the file fine
with the nero parser i get problems with both 1b and 3b mp4, eg shortly before the boy in the bed is displayed the picture freezes and than the picture continues playing on later parts where the person sitting in front of the boy is shown already (it seems the problem is always at the same parts with the nero parser)
when playing the 3b avi sample i get the same problem with the videosoft decoder. for me this looks heavily like a lack of cpu problem
it seems to play fine in directshow with the haali parser (doesnt matter if ffdshow or nero is used for decoding)
the nero parser has some strange internal workarounds, which should make borked mp4 files with wrong cts play correctly, which the haali parser doesnt do
maybe the nero parser is therefore not able to handle mp4 files with the unusual 24 fps framerate (as it expects only 25, 23.976 or 29.970 fps)...
edit: no, doesnt seem to be the case. remuxed the stream with 25fps and i get the same freeze, as described above
toejam13
13th July 2005, 00:19
Originally Posted by bond
which filters did you use for playing the file in showtime and MPC?
I used the Haali filter for both players.
I've given up on the issue, as I now encode with only the CLI varient of x264.exe since its both faster and easier.
I'm also keeping my B-frames limited to only 1-consecutive frame as well, since I feel that a majority of my issues stemmed from the use of B-frames.
My latest encodes play great on everything I throw them at: VLC, MPC and Showtime.
Thanks for the help!
/edit: I did some digging and I found that AVISynth actually has a VFAPIReader plug-in built in via the LoadVFAPIplugin() command. I've been using this to load up TMPEnc .tpr projects that I've exported.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.