View Full Version : Change FPS rate/scale ratio
newpath
19th November 2008, 06:00
I posted this message in the VideoHelp and the Afterdawn forums, but have had no responses except a good suggestion to post here. I apologize for the cross-posting.
As many of you may know, the Hauppauge HD PVR produces some nice looking recordings from HD cable or satellite. However, the file format is a bit odd in that the files are difficult to edit and/or re-encode. I have been trying to come up with an effective and reproducible method for re-encoding the H.264 recorded files with a lower bitrate to reduce file size. It has not been consistent. I have been reading about frame rates and how they are computed within a video stream using a rate and scale: fps = rate/scale. The HD PVR produces H.264 streams with very odd rate/scale ratios. For example, a recording I made of CSI in HD had rate = 10000000 and scale = 166833 for 10000000/166833 = 59.9401797. As I understand it, these odd ratios can adversely affect playback and seeking with some software players. Hence, I would like to change the ration to 60000/1001 = 59.94005994.
I have been working with x264 and DivX264 to re-encode my HD PVR recordings, but I cannot seem to change the rate/scale ratio using either encoder. Using the parameter --fps 60000/1001 does not change the ratio in the recorded file. Can anyone help me to determine if the rate/scale ratio can be changed and, if so, how? In addition, if I am incorrect in my assumptions or following a dead-end, let me know. Any help would be appreciated.
poisondeathray
19th November 2008, 06:08
Are you using DGAVCIndex? It will give FPS 120000 / 2002 usually, which is correct. You can manually edit the .dga file to something different in a text editor (but it's not required)
There are several threads here and on videohelp about how to edit and re-encode these if you search. If you record in progressive mode, it is very easy to edit without re-encoding (on keyframes) with avidemux, or h264ts_cutter. Interlaced mode is more difficult and you have to re-encode usually
If you still have specific questions after reading those threads, post here again and I'll try to help you out
EDIT: there might be the possibility that your recordings are non-standard, the specific broadcast is weird, or your device is faulty. If so, upload a small sample to a free hosting site, and someone will have a look at it. All the streams that I have done were always indexed as 120000/2002 in DGAVCIndex, if there was any sync issues, it was always from a transmission drop out or broadcast error, which needed to be cut out.
newpath
19th November 2008, 08:43
Thanks, poisondeathray, but I was not having difficulties with editing and/or re-encoding, per se, and I have read MANY threads on handling H.264 video. I record HD from DirecTV through a Hauppauge HD PVR using both SageTV and Beyond TV. I record at 720p (obviously progressive) and all of the recordings are AVC/H.264 video at 59.94 fps calculated from the rate/scale ratio of 10000000/166883. I do not want to change the frame rate, but rather the ratio from which it is calculated. I suggested 60000/1001, but your suggestion of 120000/2002 would be perfectly acceptable.
I normally use DGAVCIndex to serve my h.264 videos to an encoder and your are right that the .dga file specifies a ratio of 120000/2002. But this is done only to meet the profile constraints of the encoder, as is necessary for both x264 and DivX264. It has, however, no influence on the re-encoded file which maintains the ratio of the original, in my case 10000000/166833, which is non-standard. My reading has led me to speculate that this non-standard ratio may cause problems with some software players and seeking through the video. But, I may well be dead wrong and am tempted to drop the issue to focus on other ways of dealing with HD PVR recordings. This all speaks of the very odd h.264 files that the Hauppauge HD PVR produces reflected most recently by SnapStream deciding to leave their support for the HD PVR in beta because of the problems Beyond TV has with the recorded files.
By the way, I have processed many recordings using the software alluded to in your post, especially avidemux and h264ts_cutter. However, I have found greater success using Cut Assistant (+ AviDemux GTK+) and x264 re-encoding with Xvid4PSP. Cut Assistant provides almost frame-accurate editing and Xvid4PSP seems to be more forgiving of the HD PVR recordings. In truth, the resultant files I get from these two programs, muxed into mkv, play and seek quite well in the software players I use. Maybe I have obviated my own question, but I like the problem solving.
In any event, I will keep looking and post back if I find anything addressing the rate/scale change issue.
neuron2
19th November 2008, 14:51
...all of the recordings are AVC/H.264 video at 59.94 fps calculated from the rate/scale ratio of 10000000/166883... What makes you think that? I too have that device and the H.264 streams specify 60000 / 1001.
I normally use DGAVCIndex to serve my h.264 videos to an encoder and your are right that the .dga file specifies a ratio of 120000/2002. But this is done only to meet the profile constraints of the encoder, as is necessary for both x264 and DivX264. DGAVCIndex reports what is in the stream. It does not change anything to meet any constraints as you say. Can you post a link to a short sample stream that shows this claimed nonstandard ratio?
This all speaks of the very odd h.264 files that the Hauppauge HD PVR produces It's not "very odd". The only quirk is that the device produces streams without IDRs unless you enable them. What do you think is very odd about them?
newpath
20th November 2008, 04:54
neuron2, I would like to find out what the discrepancy is and I replied to your response in the Videohelp forum. Which forum would you like to use?
I would like to know how you determine the rate/scale ratio from your HD PVR captures. Furthermore, if, as you say, your ratios are 60000/1001 and DGAVCIndex only reports what is in the video, then why does the .dga file show 120000/2002? It is apparent that I am missing something here.
You are obviously for more knowledgeable in the video area than I, but I am trying to learn as much as I can. However, there is a relatively large on-line literature from users of the HD PVR pointing out various difficulties in working with its recordings. I know from experience that Beyond TV 4.9 throws errors if you try to use ShowSqueeze, SmartChapter, and automatic commercial editing on HD PVR recordings. In any event, this is a diversion and I should not have mentioned it in my previous post.
neuron2
20th November 2008, 06:21
I prefer Doom9. :)
OK, this is a bit tricky.
Bottom line: DirectShowSource() cannot be trusted to return correct frame rate information. That's why it has an fps parameter -- so you can set it correctly!
Here's how to definitively get the frame rate. First, the frame rate is determined by the syntax elements num_units_in_tick and time_scale. See here:
http://www.atsc.org/standards/a_72_part_1.pdf
...Table 6.2.
So, frame rate = time_scale / (2 * num_units_in_tick)
Now to see those elements in your stream, first open it in DGAVCIndex. Set a small range including the start. Do Save Project and Demux Video. Now you have an elementary .264 file. Now get Jongov's H264VideoESViewer from here:
http://tsviatko.jongov.com/index_prj_h264videoesviewer.htm
Open the .264 file and highlight a Sequence parameter set. Then expand the vui_parameters in the right pane. Look for the variables above.
You can short circuit all that by just seeing what DGAVCIndex reports, because it simply reports the frame rate based on the equation above, unless the vui data is missing, in which case it defaults to 25 fps. Since in this case it shows something other than 25 fps, then the vui data is present and 120000 / 2002 is written in the DGA file (I multiply the denominator by 2 so that the ratio is the frame rate). Note that DGAVCIndexNV shows 60000 / 1001 in the DGA file. It's the same rate but the numerator and denominator are divided by 2.
I'd be happy to address the other oddities you say exist with some other applications. Maybe we can solve those problems!
neuron2
20th November 2008, 14:58
Bump for important edits to above post.
newpath
21st November 2008, 06:08
Thanks neuron2, that does indeed clear things up. As a relative novice, I assumed too much about avisynth script commands and directshow. Jongov's viewer is excellent, but I will have to do a lot more study to understand even a little more of what it's telling me.
My issues with HD PVR recordings mostly center around playback of the original files. Seeking almost always causes Media Player Classic and Windows Media Player to lock up and sometimes crash. I don't use codec packs and try to stick with CoreAVC for playback. VLC media player seems to play the files fine without external codecs. However, I am now focusing on Cut Assistant and Xvid4PSP to edit and re-encode, although x264 CLI works well, also. I have noticed that after an x264 re-encode (to reduce file size) that all playback problems seem to be gone. I will keep working with these recordings and create a new thread if I can specifically describe any problems.
FYI, I am using DGAVCIndex version 1.0.6. I intend to purchase DGAVCIndexNV as soon as I get a CUDA video card.
Thanks again.
neuron2
21st November 2008, 14:53
Your problems are almost certainly due to the lack of IDRs (seek points) in the stream. This is what you get by default from the Hauppaauge driver. To enable IDRs, you need to use Graphedit to access the properties page of their driver. This is described in several places on the internet. Here's one:
http://blog.arogan.com/2008/06/hauppauge-hd-pvr-model-1212.html
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.