Log in

View Full Version : Convert 51.43 fps video in 59.94 fps container to blu-ray compliant 50 fps video


mr_lou
5th May 2016, 08:14
I have perhaps a slightly unusual issue.

I'm recording videos from my Amstrad CPC464 computer, using an X-RGB Mini Framemeister and a Hauppauge HD PVR Rocket recorder. The end goal is to put these on a blu-ray disc. I'm using Ubuntu Linux for this.

The Amstrad CPC464 is an old 8-bit retro computer from 1984, and it's sending out a 51.43hz signal to the Framemeister.
The Framemeister receives this signal and converts it to a 720p@51.43fps stream which it then sends to the Hauppauge device.
The Hauppauge recorder then records fine - but the result is a 51.43fps video inside a 59.94fps container.

These recorded videos confuses both VLC and Kdenlive, showing a lot of jerkiness. Frames duplicated and some seemingly missing.

I can fix this by running a 2-pass x264 command, using two terminals.

Pass 1 in terminal 1:
mkfifo stream.y4m
mplayer -vo yuv4mpeg:file=stream.y4m -nosound recording.mp4

Pass 1 in terminal 2:
x264 --bitrate 13000 --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 50 --fps 50 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 1 -o recording-fixed.264" stream.y4m

Pass 2 in terminal 1:
mkfifo stream.y4m
mplayer -vo yuv4mpeg:file=stream.y4m -nosound recording.mp4

Pass 2 in terminal 2:
x264 --bitrate 13000 --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 50 --fps 50 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 2 -o recording-fixed.264 stream.y4m

(These commands should be down to blu-ray spec, except the --fps variable, producing a compliant blu-ray h264 video stream, at least if the source video were somewhat "normal". It still needs to be muxed with audio at this point, but this thread isn't about that part).

The resulting recording-fixed.264 file now plays great in a blu-ray player (after muxing with audio into a m2ts file). 50 fps without any duplicates and no frames missing either. Very nice smooth animation as it should be. But various tools seem to indicate that the video now resides inside a 100 fps container, and I'm afraid this might cause some trouble with certain blu-ray players.

So trying another approach I use the first method on this site, in order to convert the source into a 50 fps video in a 50 fps container:
http://www.hdslr-cinema.com/news/workflow/convert-between-framerates/


extract the frames as rawvideo
ffmpeg -i input.mov -f rawvideo -b 50000000 -pix_fmt yuv420p -vcodec rawvideo -s 1280x720 -y temp.raw
recreate the video with new framerate
ffmpeg -f rawvideo -b 50000000 -pix_fmt yuv420p -r 50 -s 1280x720 -i temp.raw -y output.mov


The result is indeed a 50 fps video inside a 50 fps container - but it seems to have taken all 59.94 fps from the source now rather than the actual 51.43 fps, resulting in a lot of duplicate frames and of course therefore a video that is far too slow.

So, now I have to ask here:

How would you go about converting such a weird 51.43 fps video in a 59.94 fps container into a straight 50fps video inside a 50fps container, keeping all 51.43 fps only slightly slower - i.e. no interpolation or tweening.

Thanks

sneaker_ger
5th May 2016, 10:27
The x264 commands you have used are absolutely correct for 1280x720. Nothing you do before x264 will change the compatibility of the output in any way. It's simply not possible. x264 only receives one raw frame after the other and encodes it according to the command. So if you already found a way to create smooth 50 fps do not change it. It won't make any difference.

Why do your "various tools" show 100 fps? Several possibilities:
1) Your "various tools" suck
2) You misinterpret what "various tools" are showing (time_scale can be double frame rate in H.264)
2) Your muxer sucks
3) You have not actually used the x264 command you said you did

(These commands should be down to blu-ray spec, except the --fps variable
You have used --fps correctly. It is BluRay compliant.

mr_lou
5th May 2016, 11:07
Thanks a lot for taking time to reply sneaker.

It's great to hear that the output the x264 command can't be wrong.
I may be misunderstanding some output of these tools, but I think some also just gives wrong output...

ffprobe recording-fixed.264

FFprobe version 0.6, Copyright (c) 2007-2010 the FFmpeg developers
built on Aug 16 2010 11:19:24 with gcc 4.4.3
configuration:
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.11. 0 / 0.11. 0
[h264 @ 0xa57f010]Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'recording-fixed.264':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 1200k tbn, 100 tbc


It may have been that "100 tbc" that confused me after seeing warnings from the 51.43 fps file about the container not matching.

tcprobe -i recording-fixed.264

[tcprobe] Digital Video (NTSC)
[tcprobe] summary for recording-fixed.264, (*) = not default, 0 = not detected
import frame size: -g 720x480 [720x576] (*)
aspect ratio: 4:3 (*)
frame rate: -f 29.970 [25.000] frc=4 (*)


This is clearly wrong. It's definitely not 29.97 fps.

Also, when importing recording-fixed.264 into Kdenlive, Kdenlive says it's a 25 fps clip.

But I'm glad to hear that I can trust x264. Thanks!