-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common Time base normalization support(?) #455
Comments
TBH I'm not sure about how tbn works, but I believe that we shouldn't automatically change the tbn for all files that are being processed in losslesscut. I think this may be caused by a flag like |
Could you try the new smart cut option? It will apply the same timebase to all segments. |
This issue is about merging mp4 files with different timebase values. Videos merged in this way break in VLC and other players when transitioning into the next video stream. I'm only seeing 'smart cut' when in cut mode during the export options screen. This doesn't seem to popup during a merge operation. |
Ah, right. I misunderstood and thought you were cutting+merging which you are obviously not. Maybe losslessCut in the future can set a common timebase also when merging multiple files. However I'm not sure if simply setting |
Applying
Does Matroska even have a concept of |
I see. I can imagine a merging with first converting tbn for all segments would require double the disk space and double the processing time. |
Unfortunately that doesn't work. The concat demuxer treats input the same regardless if the output is mp4 or mkv. Basically, LosslessCut would have to ask the user if they want to modify (preprocess) their input files to have a consistent timescale (which might even be against the project's goals, though a timescale like 90k is quite lossless), or create temp files with altered timescale, there's no other way that I know of. Alternatively you can detect and alert the user when merging might result in an incompatible output file. This could also be extended to check for mismatching codecs, sample rates or AVC profiles (main vs high vs baseline), all of which can cause issues in a lossless merge, and would require re-encoding to allow proper merging. |
There are all good ideas. Definitely at the very least we should warn the user if there is a mismatch. |
Someone else reported the same issue #1215 For reference, smart cut now does something like this before merging cut segments: Line 60 in ecef901
Then it will append the argument: Line 801 in ecef901
So we could do this when concat/merging with temp files like you described. I will probably implement this in a way so that if timebase differs in two or more files, it will automatically do the intermediary temp file step. |
Is it supposed to list all mismatches, or does it only show the first warning? I tried it with two files that cannot be merged because of a mismatched timebase, but it does not warn about a timebase mismatch, only a framerate mismatch:
After fixing the timebase (and creating a playable file), the framerate warning remains, but with different numbers:
In my experience, framerates can be variable across keyframes, as is the case with adaptive livestreams, but a timebase mismatch will always break players such as VLC. I think both warnings should be listed. |
Thanks for this. I agree we should list all the errors. The reasoning behind showing only the first is that if the files are very different, the list of differing parameters would be huge, so I had decided to just show the first. I will change it so that it instead shows a popup with all the errors when clicking the exclamation icon next to one file. |
I know this issue is closed, but I want to mention that the conversion to *.ts, then concatenating those ts files in losslesscut (as mp4 output) got around the issue of the time_base mismatch losslesscut was reporting before. So @bryc is onto something that ts conversion aligns the time_base. Would be a nice enhancement if losslesscut could internally manage all that, making time_base mismatches easier to deal with :) |
this issue is not closed. I intend to implement some fix for this. Not sure why converting to mpeg ts will always(?) convert tbn to 90k (where does that number come from?) I think however preprocessing all videos first and appending the same |
Not sure to be honest. I don't know anything about time_base, but when I encountered the message in llc, I googled for it and came upon this thread here. And just converting it to ts, as @bryc mentioned above, allowed me to proceed in merging several files that otherwise llc couldn't deal with. P.S.: Reading up a bit more, ts files always appear to have a fixed timescale of 90k as per the top answer in this thread. |
I tested further with the video_track_timescale option and have run into issues. |
Correct me if i’m wrong but I think you’re supposed to use 30000 (not 30) |
Indeed 30000 worked well! Both individual files are playable after the conversion, as is the llc-concatenated output file. Great! For reference, the original mismatch warning was The only other remaining issue I see is that losslesscut is still giving me a different warning |
From a comment here: https://stackoverflow.com/questions/43333542/what-is-video-timescale-timebase-or-timestamp-in-ffmpeg
Though in practice, it can be as low as 14625 for 30 fps and still be fine (I think). The only thing that matters is that the videos all have the same value, and that its 'big enough'. @cannondale0815 As far as I remember, merging works fine with different codec profiles (Baseline / Main / High). Though not 100% sure about different levels. |
@bryc Sounds like 90k is the winner then :) I have a bunch of video files from PAL & NTSC recordings, so using a base that works well with all common fps seems like a good idea. |
I have to say, the detour via ts conversion is ingenious -- I have a few cases where losslesscut is unable to cut/merge elements from a single large mkv or mp4 file, but when I convert the entire source file to ts beforehand, those same cuts/merges work just fine. I may have to fall back to this more often now :) |
updated troubleshooting to include this trick |
Using LosslessCut I was trying to merge videos which had the same resolution and codecs, and comparable bit rates. But it failed as the second video became 'frozen' with the audio still playing. VLC could play further into the video, but some others could not. It seems that 'time base' was to blame.
The only major difference between the files are the timebase (tbn) and/or frame rate:
I got around this issue by converting them to .ts (
ffmpeg -i $1 -c copy $1.ts
), which then changed all tbn values to 90k:As far as I can tell, it created a fully valid video, and is still lossless and audio is in sync.
So LosslessCut can't do this itself - could this process be automated (using common tbn value) and implemented into the app?
Might be a considerable reliability improvement.
The text was updated successfully, but these errors were encountered: