Log in

View Full Version : High Res H.264 through Flash


jordana309
30th October 2011, 01:01
I'm trying to encode videos from DV to H.264 to play through Flash. The videos are originally 720x480, at about 30Mbit/sec. The problem is that when I tried to encode it down to 12 or even 10 Mbs using Apple Compressor, the quality was so bad I couldn't use it. I turned to x264 through MeGUI. I encoded down to 10Mbps and then again to 7Mbps when I found the overall playback speed was no better in Flash. I don't think that I can drop below 7 and still have it good enough quality.

I feed MeGUI an avs file with the following in it:
#Import Video and Audio, then resize the video to the exact dimensions of the host screen so Flash won't have to scale it.
sound = FFAudioSource("VideoInDVCFormat.mov")
vid = FFVideoSource("VideoInDVCFormat.mov").BilinearResize(1360,768)
#Combine them
AudioDub(vid,sound)
#x264 needs it in YV12, so convert it
ConvertToYV12()

Then, I use the following arguments into x264 (as shown in MeGUI):
program --level 4.1 --preset slower --tune film --pass 3 --bitrate 5000 --stats ".stats" --deblock 1:3 --keyint 96 --min-keyint 24 --qpmin 5 --qpmax 40 --vbv-bufsize 4500 --vbv-maxrate 6500 --output "output" "input"

I'm not completely new to x264 usage, but I'm no expert either. I then exported the audio as an AAC at 160kbps, then combined the two through QuickTime 7.

Finally, I took that over to my Adobe AIR program running on a Mac Mini (2.4GHz, dual core Intel Core 2 Duo, 2GB 1067 DDR3 RAM, and a 256MB NVidia 320M graphics card), and both the 10 and 7 ran with latency, dropping several frames about every 2 seconds.

Now, the odd thing is that a video with 7.022Mbps at 30fps at 1280x800 rand just fine through this same program.

Does anybody know how I might optimize this video to play through flash? That's the main question. Sorry to bog you down with too many details...I feel like I've tried everything...

Blue_MiSfit
20th November 2011, 00:52
Flash is pretty awful. I'd suggest a few things:

1) Why are you upscaling? Don't!
2) DV is usually interlaced. I don't see any handling of interlacing here. You should probably deinterlace!
3) You should try nerfing down the complexity of your encode, like with --no-cabac for example.
4) Some of your settings make no sense. I can understand wanting a fairly short keyint, but don't adjust min-keyint, or qpmax/qpmin.

Blue_MiSfit
20th November 2011, 02:46
Also, this belongs in the H.264 encoding forum, not in authoring. I've moved it for you :)

smok3
20th November 2011, 12:50
- make sure videos are deinterlaced (if they are not progressive allready)
- as said, downsize them to appropriate 1:1 sar (720x400 should be close), no point in upsizing crappy dv
- the video bitrate you are using is way to high, check --crf encoding
- use mp4box for muxing
(get the apple software out of the workflow entirely)

- why adobe air for bechmarking?
(check http://osmf.org/dev/latest/debug.html?src=rtmp://cp67126.edgefcs.net/ondemand/mp4:mediapm/osmf/content/test/sample1_700kbps.f4v&logFilter=videoClasses&enableStageVideo=true & http://www.osmf.org/configurator/fmp/ )

- if you are encoding on mac you can check my hippy drag&drop ffmpeg "gui"
http://forum.doom9.org/showthread.php?p=1528488
( -vf yadif=0,scale=700:400 )

benwaggoner
22nd November 2011, 04:30
Note that your decode complexity is really based on maxrate; your settings will have sections as hard as a 6500 Kbps CBR file.

But yeah, don't upsample! You are tripling your pixels/sec and your required bitrate, which is roughly tripling your CPU requirements. You can't expect older-ish PCs to be able to play back >720p like this! They need fallback streams.

Using CAVLC instead of CABAC is generally the next step in improving decodability. If that's not enough, I then turn off Reference B-frames and reduce max B-frames to 2.

jordana309
22nd November 2011, 19:57
Thank you all for your suggestions! I got my files from a client through apple software. I appreciate your tips on encoding, also. I didn't realize how much I was up-scaling :P Thanks also for moving my thread! The client wants these files in a kiosk, which I've done in Flash (mistake!). I have a problem with my player itself. After implementing your suggestions, I have been able to get the video playing smoothly in the pre-packaged VideoDisplay component that ships with Flex, but my component still has issues, so at least the video part works well :)

Thanks again!

Blue_MiSfit
23rd November 2011, 17:43
You're quite welcome. Pass it along!

benwaggoner
24th November 2011, 00:03
Thank you all for your suggestions! I got my files from a client through apple software. I appreciate your tips on encoding, also. I didn't realize how much I was up-scaling :P Thanks also for moving my thread! The client wants these files in a kiosk, which I've done in Flash (mistake!). I have a problem with my player itself. After implementing your suggestions, I have been able to get the video playing smoothly in the pre-packaged VideoDisplay component that ships with Flex, but my component still has issues, so at least the video part works well :)!

If you're using Flash to decode, make sure the kiosk and Flash install are set up to use hardware decode, and you're using the latest Flash version. Those can help HUGELY.

atl
28th November 2011, 00:49
1. If the Apple compressor fails on this at 12 Mb/s then you have interlaced video trying to encode as progressive or really noise video or both.
2. Resizing to 1360x768 makes no sense, do it to 848x480 for NTSC materials
3. 5 Mb/s is overkill for SD, somewhere around 2.5 will work on most cases
4. Fixed bitrate should be avoided too, use CRF and vbv-bufsize vbv-maxrate to cap top
5. A lot of settings not make sense, leave it on default, set only the CRF and VBV
6. Deinterlace and properly denoise the video. QTGMC (http://forum.doom9.org/showthread.php?t=156028) is a good way to do both