Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > NLE - Non Linear Editing

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th February 2019, 14:44   #1  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
VFR to CFR conversion

VEGAS still seems to have issues (creating blended frames or fields) with the handling of (pseudo) VFR files, so I have to convert these VFR files to CFR before importing into VEGAS. I can do this without re-encoding with mkvtoolnix and subsequent remux of the .mkv to a format which Vegas accepts, e.g. m2ts with tsmuxer.
Can the VFR to CFR conversion be done in 1 step with ffmpeg? I tried various options but did not succeed without re-encoding.
Sharc is offline   Reply With Quote
Old 17th February 2019, 14:48   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,413
What is "pseudo VFR"? What is source codec? What is source container? What are you doing in mkvtoolnix exactly?
sneaker_ger is offline   Reply With Quote
Old 17th February 2019, 14:57   #3  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
"Pseudo" VFR: These are for example .mp4 clips from mobile phones which are slightly off from the standard framerates, for example 30.007 fps or 29.884 fps instead of nominal 29.97 fps. Dumping the time stamps shows that the frames are pretty much CFR with the exception of say the first or last frame(s) which are way out.

I fix these by remuxing the .mp4 to .mkv with mkvtoolnix, selecting the framerate as 30000/1001 and ticking "fix bitstream timing info" in the GUI.

Last edited by Sharc; 17th February 2019 at 15:01.
Sharc is offline   Reply With Quote
Old 17th February 2019, 15:48   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,413
Try something like:
Code:
ffmpeg -y -i "input.mp4" -c:v copy -an -sn -bsf:v h264_metadata=tick_rate=1001/60000:fixed_frame_rate_flag=1 -f rawvideo - | ffmpeg -y -fflags +genpts -i - -i "input.mp4" -map 0:v -map 1:a -c copy "output.m2ts"
But it seems there's a lot broken with ffmpeg so it may or may not work depending on the source...
sneaker_ger is offline   Reply With Quote
Old 17th February 2019, 17:33   #5  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
Thanks a lot. Unfortunately no luck, getting the error
Code:
pipe:: Invalid data found when processing input
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
frame=   14 fps=0.0 q=-1.0 Lsize=    1037kB time=00:00:00.43 bitrate=19595.8kbits/s speed=3.33x
video:1108kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
Surprisingly, VMS (Vegas Movie Studio) seems to convert these VFR sources without blending fields and without skipping/doubling frames when I select the rendering quality in VMS to the lower levels like "preview" or "draft".
Sharc is offline   Reply With Quote
Old 22nd February 2019, 12:34   #6  |  Link
Kisa_AG
Registered User
 
Join Date: Sep 2005
Location: Moscow, Russia
Posts: 56
Quote:
Originally Posted by Sharc View Post
Surprisingly, VMS (Vegas Movie Studio) seems to convert these VFR sources without blending fields...
Vegas also can do this. Just set in Project Prefs > Video > Resample Mode = Disable.
Also you can do this for any particular clip in project bu changing clip's properties.
Kisa_AG is offline   Reply With Quote
Old 22nd February 2019, 14:28   #7  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 3,828
For those "pseudo" VFR files, I would use mp4fpsmod . You can batch, and even inplace edit with "-i" (the -i means inplace edit, not "input" like ffmpeg)

eg.
Code:
"mp4fpsmod.exe" --fps 0:30000/1001  "input.mp4" -o "output_cfr.mp4"
batch inplace edit all mp4 files in a directory
Code:
for %%a in ("*.mp4") do "mp4fpsmod" "%%a" -i --fps 0:30000/1001
pause
poisondeathray is offline   Reply With Quote
Old 22nd February 2019, 17:10   #8  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
Quote:
Originally Posted by Kisa_AG View Post
Vegas also can do this. Just set in Project Prefs > Video > Resample Mode = Disable.
Also you can do this for any particular clip in project bu changing clip's properties.
Thank you for the hint. Apparently it worked for "Draft" and "Preview" project quality setting because these settings disable the resampling by default.
I found that it is also advisable to import the file at project framerate in order to obtain the desired exact output framerate. New to Vegas, still learning.
Sharc is offline   Reply With Quote
Old 22nd February 2019, 17:14   #9  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
Quote:
Originally Posted by poisondeathray View Post
For those "pseudo" VFR files, I would use mp4fpsmod . You can batch, and even inplace edit with "-i" (the -i means inplace edit, not "input" like ffmpeg)

eg.
Code:
"mp4fpsmod.exe" --fps 0:30000/1001  "input.mp4" -o "output_cfr.mp4"
batch inplace edit all mp4 files in a directory
Code:
for %%a in ("*.mp4") do "mp4fpsmod" "%%a" -i --fps 0:30000/1001
pause
Nice, thank you. I tried and it works. These "VFR" files are still a pain. Better to convert them all to CFR before processing them further.
Sharc is offline   Reply With Quote
Old 4th March 2019, 07:09   #10  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 524
What happens to audio sync, if the first frame is way off ?
hydra3333 is offline   Reply With Quote
Old 4th March 2019, 08:35   #11  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
Quote:
Originally Posted by hydra3333 View Post
What happens to audio sync, if the first frame is way off ?
I didn't notice an obvious problem, like an offset or drift. I should perhaps double-check. The clips are all very short, typically less than 30 seconds
Sharc is offline   Reply With Quote
Old 4th March 2019, 18:31   #12  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 3,828
Quote:
Originally Posted by hydra3333 View Post
What happens to audio sync, if the first frame is way off ?
If the first frame is way off, then usually other frames are way off. That would not be a "psuedo VFR" file with minor jitter in the timecodes that you could "treat" as CFR . If you look at mediainfo (view=>text) it will usually report a min/max framerate for those types of files and that will only deviate by a tiny fraction.

VFR with large deviations cannot be "fixed" with this method, you would have to convert to CFR by using the conventional re-encoding methods - adding duplicate "placeholder" frames to keep sync
poisondeathray is offline   Reply With Quote
Old 4th March 2019, 22:46   #13  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,471
How does MediaInfo determine the min. and max. framerates for VFR video files? Does it scan all timestamps of the entire video file? If so it seems to do this pretty fast.
Sharc is offline   Reply With Quote
Old 5th March 2019, 20:04   #14  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 3,828
Quote:
Originally Posted by Sharc View Post
How does MediaInfo determine the min. and max. framerates for VFR video files? Does it scan all timestamps of the entire video file? If so it seems to do this pretty fast.
I don't know, but I doubt it scans the entire video

But the videos that have large deviations usually cannot be treated as CFR with that method. Only the ones that are very slightly off can be 29.979, 30.001 etc.. can usually be treated successfully in sync
poisondeathray is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.