Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

Pages: (4) 1 [2] 3 4  ( Go to first unread post )
Caching input driver, with FFMpeg, in development
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
shekh
Posted: Dec 5 2014, 02:04 PM


Advanced Member


Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14



Known issues:

Image sequence doesnt work (can be solved)

Direct copy video/audio doesnt work

Audio may have problems (clicks).
Unfortunately I found some files where sound frame timestamp cannot be translated precisely to sample number. The only workaround that I think of is to read whole stream sequentially (this is why player doesnt have problem).

mts file examples do not seek immediately.
As I understand there are no keyframes at all, but decoder somehow knows when enough delta-frames are decoded to build complete picture.
I decided not to seek to requested frame but instead inform which frame is actually available.

A somewhat unusual feature:
To solve priority battle I divided plugin into two parts "default" and "select". Each can be given individual priority in ini file.
The "default" takes all formats and should be -2 because it cannot open image sequences now.
The "select" opens only avi, mp4, mov. I set it to high priority to have any avc asp open without problems (that was my main motivation after all).
Also ini file can specify which file extensions to show in open file dialog.
The full supported list is way too big, so when the dropdown opened it crossed multiple displays.

There is something with color formats.
I dont understand why VD allows so many formats to select in UI.
I tried to fit something usable:
1) default: pass format with least transcoding (everything that VD knows like yuv420 is not processed at all)
This gives both best speed and best quality.
2) xrgb
When yuv is transcoded to xrgb by ffmpeg the quality is the same as way 1 but the speed is much worse.
This is because ffmpeg fast conversion is very very bad quality.
Something to compare:
analyze pass 1280*960@48 h264 30000kbps
passed to VD as yuv420: 70fps
passed to VD as xrgb high quality: 30fps
passed to VD as xrgb low quality: 150fps
 
     Top
dloneranger
Posted: Dec 7 2014, 06:30 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



That's a nice start for your plugin
The splitting the video/audio + buffering is a great improvement
I look forwards to you completing it smile.gif

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
ALbino
Posted: Dec 7 2014, 09:22 PM


Advanced Member


Group: Members
Posts: 101
Member No.: 26983
Joined: 9-February 10



This is all above my head, but I've been following it and can't wait to try out the finished product. Thanks so much shekh!
 
     Top
shekh
Posted: Dec 8 2014, 11:17 AM


Advanced Member


Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14



Albino, no need to wait. Download and report if you have issues!
 
     Top
dloneranger
Posted: Dec 8 2014, 11:48 AM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



atm the main issues seem to be

1) the stream duration error message for many formats that stop them loading eg mkv
2) not decoding frames correctly (grey frame and error reading source frame message in virtualdub's status bar)
3) some access violation crashes

1
you can get the duration from the format as a fallback, the source is in the code but commented out ?
(i've added that back in here just for testing on my pc)

2
eg https://archive.org/details/Windows7Wildlif...lifeSampleVideo the wmv sample shows many of the grey frame errors

3
eg load video2.wmv, fastforward and crash
clip at http://www.lehman.edu/faculty/hoffmann/itc...eo_samples.html

ps
I have great sympathy for anyone trying to get the correct frame out of ffmpeg's dlls, it sucks like a very sucky thing

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
shekh
Posted: Dec 8 2014, 02:03 PM


Advanced Member


Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14



1) I first added that code to allow mkv to show something but immediately got another issue: the frame timestamp does not translate to frame number. Maybe the same problem as you report about wmv.
I`ll try to approach it.

When I first touched ffmpeg examples it seemed straightforward but now I am disappointed. Just nothing is consistent at high level. Already read good part of ffmpeg source to figure anything.
 
     Top
dloneranger
Posted: Dec 8 2014, 03:04 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



OK, think I've spotted one problem in videosource::handle_frame
(testing with the wildlife.wmv clip)

you have
pos = int((ts - start_time) * time_base.num / time_base.den);

when I replace the other ones ts to pos function it works out the right pos
double scale = m_pStreamCtx->r_frame_rate.num *m_pStreamCtx->time_base.num / (double)(m_pStreamCtx->r_frame_rate.den *m_pStreamCtx->time_base.den);
int64_t pos2 = (int64_t)((ts - start_time)*scale + 0.5);

in the debugger
m_pStreamCtx->time_base num=1 den=1000
your time_base num=30 den=1001

so, rework that to see what's going on
double pos3d = double(((ts - start_time)*time_base.num)) / time_base.den;
and the problem looks like a simple error of using ints for maths
for frame 1, yours =0 , pos3d=0.989

this should be fine
int64_t pos4 =int64_t( double(((ts - start_time)*time_base.num)) / time_base.den + 0.5);

you may want to check for other places where you've used int maths by mistake


--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
shekh
Posted: Dec 8 2014, 04:11 PM


Advanced Member


Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14



Thanks, I`ll check it.
I started with "normal" files where timebases and framerates are exact, and made conclusion that integer math is appropriate.

Meanwhile I fixed AV issue with Video2.WMV.

btw, found this: https://github.com/FFMS/ffms2
So this is so much the same effort as we do, have you looked into?
Is avisynth currently the real way users end up to open in virtualdub?
 
     Top
dloneranger
Posted: Dec 8 2014, 04:22 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Only fairly advanced users try avisynth
Pretty much most users just want to drag a file to virtualdub
One of the most common questions is 'why is my saved file so big' and the answer has to explain compression and codecs ;-)


--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
dloneranger
Posted: Dec 8 2014, 07:03 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Yup, that maths as int problem is around quite a lot
audiosource::init_start_time is broken

But init_start_time just looks wrong all around
The first audio track timestamps don't have to match the first video timestamps and shouldn't be corrected for???
It's fine for the audio track to be offset, it's often used for audio sync correction in the first place, or capture cards that start recording the audio a bit earlier that the video

That said, the maths still looks wrong
giving it a video where the audio has been delayed by 522ms to sync it up with the video
d=0
sample_count -=0
with a straight convert to double
d= -0.522
sample_count = -23.02

These numbers look very suspicious for what should be half a second of audio?

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
shekh
Posted: Dec 8 2014, 08:59 PM


Advanced Member


Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14



Can you link your example with time offset?

About correction:
as I understand both video and audio stream may begin at arbitrary and different offset. What I know for sure, I must begin "playing" video at time 0 in VD timeline. This means I must offset audio the same way I offset video to time 0.
What is wrong?

from this sample: snow.mts
video start_time 176882, timebase 1/90000
sound start time 176882, timebase 1/90000
so one cancel another, looks correct
 
     Top
dloneranger
Posted: Dec 8 2014, 09:17 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Here's a test clip I just made - the audio is delayed by about 22 seconds and is in sync from then on
If you watch it in a normal player, they just blank out the beginning and start playing when the video catches up to where the audio is marked as starting
https://dl.dropboxusercontent.com/u/1702491...%20Test%201.mkv

[edit]
I tend to do most of this stuff with mkv's as the tools are darned good
But you can do the same in virtualdub with avi's - set to direct stream copy, and on the audio menu, interleaving -change the audio skew correction and save

I made one with a long blank bit and synced audio just so it's easy to see if it's all lined up

Now this one seems fine, it all lines up nicely???
(in the other ffmpeg plugin the audio starts straight away incorrectly)

The other clips too big to upload, so never mind, if it's a problem it'll soon show up in other files I guess

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
dloneranger
Posted: Dec 8 2014, 09:38 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Ok, made another clip that's in sync to begin with, and then I delayed the audio by 1000ms forcing it out of sync
This one ignores the delay in the plugin but in a player correctly has a blank second at the beginning
https://dl.dropboxusercontent.com/u/1702491...%20Test%202.mkv
(audio display should show real audio starting at frame 23ish)

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
shekh
Posted: Dec 9 2014, 11:22 AM


Advanced Member


Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14



Some other issue: when playing, VD can buffer frames according to "render pipelining" option.
My implementation returns useless zero-length video samples to VD and it happily buffers them. But when it comes to decoding I refuse to because the requested frame is already behind my cache window (in the scenario when it is smaller than render buffers option).

I can simply boost my minimum cache to VD`s maximum 256, but it sounds too much.
Maybe I leave it alone and insert some message like "decoding behind cache? Please reduce render buffers".
 
     Top
dloneranger
Posted: Dec 9 2014, 01:27 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Hmmm, hadn't tried to play a vid

Click I button to play input and sounds fine, output frame stays as it is, input frame has half one frame and half another and does not change
Click O button and AV crash

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
54 replies since Nov 25 2014, 01:31 PM Track this topic | Email this topic | Print this topic
Pages: (4) 1 [2] 3 4 
<< Back to VirtualDub Filters and Filter Development