|
|
| shekh |
| Posted: Nov 25 2014, 01:31 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
This plugin originated as intent to fill the gap between avc mp4 camera clips (specifically gopro avc as I use one) and VirtualDub. It supports many other formats as well, provided by ffmpeg library.
When I tried other solutions (including codecs, input drivers, converters, other editors), I got one or all of the following: 1) screwed frame order (ffdshow, x264vfw) 2) truncated color range 3) wrong color space 4) corrupted audio 5) lost frames (begin/end) 6) poor performance
What my version can do: It can open mp4 h264 (and with luck many other formats too) without requirement for any additional codecs (thanks to ffmpeg) and without any loss in quality. It can deliver frames reasonably fast. I am able to navigate forward and backward etc. Initially I only wanted to find cut points and convert the clip to other format for further processing, but now I can apply color correction etc as well.
Limitations: This is not fully standard input driver, so it cannot work in modes other than full processing.
Good for: Trim original mp4, apply color correction or other simple editing, save to cineform. Filters with lots of scattered access like deshaker should work too (with care) - havent tried yet.
http://sourceforge.net/projects/vdcachingdriver/
recent updates: * Improved stream selection from files with multiple stream choices. * Fixed decoding unhandled formats. For example, utvideo rgb was not decoding.
This post has been edited by shekh on Jan 24 2015, 06:44 PM |
 |
| dloneranger |
| Posted: Nov 25 2014, 03:34 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
Just a quick look but the J formats are deprecated Their source says the normal code should be used and avframe_set_color_range should be used instead - but color range is set by libavcodec on decoding itself ? [edit] Just did a quick test, and if you force change the color_range manually before swscale then it does in fact change the color range Full range video is already set as that so makes no difference, changing it to mpeg does look different So I'm not sure what your problem is [/edit]
If you have the time to do it, the whole thing could be redone from scratch to actually make more sense If you have fixes I can merge your source into the existing code if you want
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| shekh |
| Posted: Nov 27 2014, 10:28 AM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
| QUOTE (dloneranger @ Nov 25 2014, 03:34 PM) | Just a quick look but the J formats are deprecated Their source says the normal code should be used and avframe_set_color_range should be used instead - but color range is set by libavcodec on decoding itself ? [edit] Just did a quick test, and if you force change the color_range manually before swscale then it does in fact change the color range Full range video is already set as that so makes no difference, changing it to mpeg does look different So I'm not sure what your problem is [/edit] | Sorry I subscribed but there is no email for some reason. More detail: The source video is mp4 h264 from hero 3. ffmpeg decoder set this info: pix_fmt = AV_PIX_FMT_YUVJ420P color_range = AVCOL_RANGE_JPEG
ffmpeg declares pix_fmt deprecated, nevertheless passing it to sws_getContext works. Correct conversion to full range: sws_getContext(w, h, pix_fmt, w, h, AV_PIX_FMT_YUVJ420P, ...); In this case both in and out pixel format is the same and actually sws_scale should reduce to plain copy and can be skipped. Another option would be to call sws_setColorspaceDetails but since above worked for me I didnt bother. Maybe using it is good idea too. |
 |
| shekh |
| Posted: Nov 27 2014, 11:06 AM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
| QUOTE (dloneranger @ Nov 25 2014, 03:34 PM) | If you have the time to do it, the whole thing could be redone from scratch to actually make more sense If you have fixes I can merge your source into the existing code if you want | I`ll give it a run to see what did I broke before presenting.
A preview of what I changed (please correct me if you notice something wrong at this level): Overall I barely used anything except file info dialog so far. It seems missing some useful info like sample/frame counts so maybe I add that.
Isolated sound and video interfaces, each has its own AVFormatContext. The reason for this: VD does not care the streams belong to same muxer, and for example will read sound ahead few seconds. And sound/video threads are concurrent. Resolving this is soo inefficient.
Big cache for sound. For example if movie is only few minutes the whole audio track is only few megs and it will be read at most once.
Used swr_convert for sound conversion. Only target pcm_s16le 2ch atm.
Big cache for video. To allow smooth backward navigation I allow frame cache as big as 2x maximum keyframe distance. And read frames ahead backward.
Dropped all the pain involving special files: if it is either partly downloaded or written by bad codec or it is 2 hours no-keyframes or has too fancy features like variable image dimension or variable frame rate then this file is unsupported. |
 |
| dloneranger |
| Posted: Nov 27 2014, 02:03 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
| QUOTE | Isolated sound and video interfaces, each has its own AVFormatContext. The reason for this: VD does not care the streams belong to same muxer, and for example will read sound ahead few seconds. And sound/video threads are concurrent. Resolving this is soo inefficient. |
Yeah, this has been a large pain, especially if you have the audio display turned on in virtualdub For large wmv files it's been easier to turn the audio into pcm first, as seeking is so slow toward the end of the file
| QUOTE | | Used swr_convert for sound conversion. Only target pcm_s16le 2ch atm |
Atm, virtualdub only supports this and 8bit
| QUOTE | | Dropped all the pain involving special files: if it is either partly downloaded or written by bad codec or it is 2 hours no-keyframes or has too fancy features like variable image dimension or variable frame rate then this file is unsupported. |
It's amazing how many of these there are :-( As is, the ffmpeg plugin is frequently used for the 'my file wont load' problem though
Pretty much I've just been keeping it up to date with ffmpeg dlls and poking around at small parts of it as needed (I seem to spend more time going this makes no sense, what the heck was this bit of code supposed to do???)
Here's a few links for some test files that have previously had problems VID_20141027_140141.mp4 hovercraft.mts snow.mts
Number sequence files for checking seek accuracy TestSequenceOfNumbers TestSequenceOfNumbers 8bframes
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| shekh |
| Posted: Nov 27 2014, 03:07 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
| QUOTE (dloneranger @ Nov 27 2014, 02:03 PM) | Here's a few links for some test files that have previously had problems ... | Thanks, downloaded all. |
 |
| -vdub- |
| Posted: Nov 28 2014, 11:17 AM |
 |
|
Advanced Member
  
Group: Members
Posts: 613
Member No.: 27087
Joined: 24-February 10

|
| QUOTE (-vdub- @ Apr 11 2014, 07:58 PM) | Direct Copy I guess those that can do so outweighs the very few those that can't. What I meant was as other plugins are able to and that FFmpeg binaries are able to then would follow that FFmpeg Input Driver should also able to do Direct Copy video and audio. It what will make this plugin as good as those that can Direct Copy so then we will be looking to Phaeron to add this below
As many plugins will never be updated but still can be used. If Phaeron were to add a user selectable setting to always load files with a plugin the user need always to load files with |
Shekh if you see a way to enable aac direct copy
FFmpeg.exe itself is able to do this, it would be nice for the FFmpeg_Input_Driver to do it also ! |
 |
| shekh |
| Posted: Nov 28 2014, 01:43 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
| QUOTE (-vdub- @ Nov 28 2014, 11:17 AM) | Shekh if you see a way to enable aac direct copy
FFmpeg.exe itself is able to do this, it would be nice for the FFmpeg_Input_Driver to do it also ! | This is interesting if anyone is able to explain how that supposed to work. As I studied driver interfaces there is only pcm output and no indication of any kind that a direct copy is desired. For video I dont understand direct copy mechanism too. |
 |
| dloneranger |
| Posted: Nov 28 2014, 01:56 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
It's vaguely mentioned in IVDXStreamSource:: GetDirectFormat from the sdk help Might be easier to examine the source of one of the other input plugins that can do direct stream copy
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| shekh |
| Posted: Nov 30 2014, 10:05 AM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
| QUOTE (dloneranger @ Nov 28 2014, 01:56 PM) | It's vaguely mentioned in IVDXStreamSource:: GetDirectFormat from the sdk help Might be easier to examine the source of one of the other input plugins that can do direct stream copy |
I played with quicktime plugin: it works with direct mode. So I studied its source. What I understand now: 1) The input plugin cannot output both compressed and uncompressed audio. There is no interface for that. 2) There is no way to know which mode is selected in VD. 3) If the plugin outputs compressed audio, it may be further decoded by VD with help of windows installed codec, if there is one. In this case I hear it but cannot see audio display.
This is not nice. I dont like the idea to depend on windows codec when everything can be decoded by ffmpeg. However it is possible to implement both ways and an option. So if you want to install aacacm or never want to hear anything you can "enable direct mode" in the extended options...
Then how to pass the stream is not obvious yet. Maybe just copying packets data will work, or not. Takes some more time to discover. |
 |
| dloneranger |
| Posted: Nov 30 2014, 01:46 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
For what it's worth, the DirectShow plugin doesn't do direct stream copy either (and that's written by virtualdubs author) Might be leaving that on the todo list as a low priority if it's a pain
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| -vdub- |
| Posted: Dec 1 2014, 12:11 AM |
 |
|
Advanced Member
  
Group: Members
Posts: 613
Member No.: 27087
Joined: 24-February 10

|
Yes I asked because it would help if it was possible. Then when you get more familiar with the code when your ready as dloneranger says
I'm reading the thread enjoying what I read so far from you two and looking forward to what else you find and can help with. FFmpeg Input Driver I expect is used by everyone that uses virtualdub now (a much needed multi codec decoder)
I believe also as you and dloneranger do FFmpeg Input driver is one of those projects that is worth while coding to it. If I knew code like you two understand code I would code it to |
 |
| shekh |
| Posted: Dec 1 2014, 12:02 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
I run into "interesting" problem. To detect whether format is supported the plugin needs to analyze a portion of file data provided by VD (the DetectBySignature function). Maybe this can somehow work with ffmpeg but ideally I`d like to use normal ffmpeg way to open a file. But then its too late. Once the driver is picked VD wont continue to try other drivers. This is sad because it makes impossible to automatically skip formats which cannot work. Assume ffmpeg driver is high priority, and there is avi file with proprietary codec (cineform). Ideally fmpeg will refuse and VD will do vfw. But this does not work. Am I missing something? |
 |
| dloneranger |
| Posted: Dec 1 2014, 01:01 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
No, it's a limitation of Virtualdub's plugin system That's why the multi format plugins are usually low priority, so they don't mess up previously working setups (there have been requests for virtualdub to be improved in the area of matching plugins to formats)
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| shekh |
| Posted: Dec 5 2014, 01:19 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 89
Member No.: 37903
Joined: 21-April 14

|
I take break at this point. Fixed many issues, should not have big regression.
Comment will follow |
 |