There are several questions I have tried to find ansawers for in order to create a frame accurate cut/merge program. While the final works as I expected, encoding only the first part up to the next I Frame and copying the rest of the cut and joining without any glitches.
However, if the encoded portion is not specified exactly as the formatting of the copied portion, when they are joined, the format becomes whatever the encoded portion is throughout the entire merged video. I have searched here and on the internet and I cannot find answers to several questions:
QUESTION 1
1. What effect does changing he timescale have on the video. (-video_track_timescale). Many videos I edit have an FPS of 29.97 and timescale of 90000. would changing it to a even multiple of 39.97 improve the final result?
2. FFMpeg seems to set the Reference Frames number depending of various reasons. I have videos that are 1, 2, 3, 4, and 5 reference frames. Does changing affect quality? Is there a 'Normal' number that is common and better?
3. Many videos that appear to my unexpert eye as just blurry, look terrible with any kind of sharpening effect. Is there a way to undo whatever causes this so normal sharpening can be applied? ( I know encoding never improves a crappy video, but just wondered if it was possible to make it 'appear' as if improved) .
4. If an encoded video has an audio that is 1-20 frames shorter than the video, does it hurt to 'stretch' the audio that amount? (E.G. 0.033367-0.66734)? Any maximum that would definitely change the audio sound?
The program I am working on has the ability to change any editing script in ffmpeg so video to video is not canned but it would be nice to have a 'standard' for the default. I'm hoping someone has the answers to these questions. Any help would be appreciated.
Thank You
+ Reply to Thread
Results 1 to 4 of 4
-
-
My only timescale experience is changing it when encoding video as variable frame rate, and I quickly discovered the encoder is smarter than I am, so I always let it set the timescale (I just add the timecodes to the x264 command line).
I can confirm though, 90000 is an even multiple of 29.97fps.
30000/1001 * 3003 = 90000
If ffmpeg lets x264 do it's usual thing (I know nothing about x265), it picks a Level according to the resolution unless you specify one yourself, and it also sets the number of ref frames according to the Level and speed preset being used. I think all tunings use the same number of reference frames except the animation tuning, which uses more if possible.
Here's some examples.
High Profile, Level 4.1, Medium Speed Preset, No Tuning - 3 ref frames
High Profile, Level 4.1, Slower Speed Preset, No Tuning - 8 ref frames
High Profile, Level 4.1, Slower Speed Preset, Animation Tuning - 16 ref frames
Once again, assuming ffmpeg works the same as the x264 command line version, x264 will limit the number of reference frames according to resolution (and possibly frame rate) even if you specify a Level. From memory, the reference frame limit for Level 4.1 and 1080p is 3 (don't quote me on that) but assuming the limit is 3 for 1080p, that's the number of ref frames x264 will use for the second two examples above, but it'll use more for lower resolutions.
Thinking about it, there's a list here. The numbers in brackets on the right are the maximum ref frames.
https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels
For the command line x264, if you specify a number of ref frames in the encoder command line, that's what it'll use and none of the above will apply.
In my case, the highest level supported by all playback devices here is Level 4.1, so I specify Level 4.1 for everything, pick a speed preset and tuning, and let the encoder set the reference frames.
If you happen to have MeGUI installed, and you enable "Advanced Settings" in the x264 encoder configuration, select a level or tuning etc, then switch to the "Frame-Type" tab. You'll see the number of ref frames in the GUI will change automatically, so if you need to know what's happening in advance, that's one way to check. It doesn't take resolution into account though. For that you need to start an encode and check the x264 section in the log file to see if the encoder has limited the number of ref frames.
What resolution are they and are they being upscaled on playback etc. That can make a difference. I use a soft upscaler with MPC-HC (Bilinear) so upscaled video tends to look a little soft. The TV in the living room uses a sharp upscaler though, and if anything it's a bit too sharp, so I'm gentle with any sharpening. I don't like video that looks sharpened anyway so I tend to sharpen less rather than more, and the only sharpening I'd use is LSFMod or CSMod because everything else I've tried sucks. What's "normal" sharpening?
If it's 20 frames shorter and you stretch the audio by 20 frames it'll be 20 frames out of sync by the end.
If you need them the same length and there's not 20 video frames at the end you can delete, you should re-encode the audio and add 20 frames worth of silence. I'd have to take anti-depressants for at least a couple of days before trying to do it with ffmpeg (I don't know how to do that sort of thing so I'd have to work it out), but assuming there's 45,672 video frames in total (I had to pick something), if you decode the video and audio together (FFMS2 rather than FFVideoSource and FFAudioSource etc) you can cut/join the audio with Trim() using frame numbers instead of having to use AudioTrim().
VA = FFMS2("SounceFile")
V = VA.Trim(0, 45671)
A = VA.Trim(0, 45651) ++ BlankClip(VA).Trim(0, 19)
Both = AudioDub(V, A)
# return V
# return A
# return Both
# Uncomment one of the above to set the script outputLast edited by hello_hello; 1st Oct 2021 at 23:07.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
All VERY good information hello_hello. It gives me a lot to work with. The only thing different is I've been forcing videos with 3 Reference frames to be encoded with 4 when normally they would be 3. Perhaps it is best to let the encoder (FFMpeg in my case) set its number of ref frames.
As far as audio goes, I like your information and will have to change my program. Since I regularly add silence with ffmpeg when I clone The beginning or ending frames for a fade out that doesn't fade out during actual video sequence of frames, that should be no problem. I do love your avisynth example and have already stored that away for reference. Thanks
Thanks again for your feed back.
Budman1 -
Actually I forgot and left something off the script I'd normally include. It's because I mostly encode audio with fb2k and it sometimes crashes if the script output includes video. So normally I'd finish the editing, then kill the video for the audio variable so it will only return audio.
I just thought I'd add that info for completeness.
VA = FFMS2("SounceFile")
V = VA.Trim(0, 45671)
A = VA.Trim(0, 45651) ++ BlankClip(VA).Trim(0, 19)
Both = AudioDub(V, A)
# return V
# return A.KillVideo()
# return Both
If I understand correctly, you're adding frames to the video, possibly cloning existing frames rather than adding blank ones, and extending the audio duration to match? This example would add 20 black video frames, add audio silence to match, and the video and audio would begin fading out 30 frames from the finish line.
VA = FFMS2("SounceFile")
VA.Trim(0, 45671) ++ BlankClip(VA).Trim(0, 19)
FadeOut0(30)
Or maybe fade out first, then add the extras if need be.
VA = FFMS2("SounceFile")
VA.Trim(0, 45671).FadeOut0(30) ++ BlankClip(VA).Trim(0, 19)
In case you're not aware, there's also a Dissolve filter for blending the end frames of one clip into the beginning frames of another clip.
http://avisynth.nl/index.php/DissolveAvisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview)
Similar Threads
-
best way to sharpen this?
By taigi in forum RestorationReplies: 25Last Post: 17th Jan 2023, 03:52 -
[After Effects] Directional sharpen effect for ae? Like PS "Smart Sharpen"
By zkri in forum EditingReplies: 2Last Post: 2nd Feb 2021, 07:59 -
How to use sharpen filters in MeGUI
By Daringbaaz in forum Newbie / General discussionsReplies: 3Last Post: 24th Aug 2019, 11:38 -
not sure how to frame question - "sharpen old audio" ?
By hydra3333 in forum AudioReplies: 10Last Post: 21st Nov 2016, 06:03 -
Short white noise bursts in AAC audio that were not there before
By Foebane72 in forum Video ConversionReplies: 18Last Post: 22nd Oct 2016, 16:06