Author Topic: FFMS2 (The Fabulous FM Source 2)  (Read 121875 times)

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
FFMS2 (The Fabulous FM Source 2)
« on: December 03, 2009, 11:51:49 AM »
This thread shall begin much like one of my previous ones...

One day I got bored (again) and thought it would nice to have a plugin to open mkvs and similar things. That attempt failed miserably because it turns out that ffmpeg has just as much documentation as the average open source project.

But as you all know you can't let computers win. Ever.

This plugin should support decoding of all FFmpeg supported video formats with frame accurate seeking in avi, mkv and mp4 and possibly some others. Haali's parser is used for matroska since the ffmpeg one has serious issues and FFmpeg for everything else. Opening files is however a bit slow due to the required indexing.

All current downloads and the source can now be found at the Google code project. This also includes TheRyuu's most recent FFmpeg-mt compiles as well as the old 1.21 version. (list deprecated downloads to make it appear)

Google code project

Full changelog
IVTC.ORG - Framing the debate about fields

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #1 on: December 03, 2009, 11:58:35 AM »
This is the full todo list for FFMS2. Vote on the features/fixes you want the most or suggest your own. Lots of stuff has been pruned and from the old list.

Todo
  • Write a graphic indexing app using QT creator (it will look at least twice as good as DGIndex)
  • Support uncompressed formats and formats that need codec properties to be set from the container values properly (added width and height reading for all formats, currently only supported in LAVF opened files but wav in mkv/ts is so uncommon I don't think anyone's noticed)
  • Implement incremental indexing (this would be a pure API improvement and never show up in avisynth because of its limitations)
  • Regression tests
  • Add support for transport streams that do not start on a packet boundary with Haali's parser (I probably won't implement this but patches are welcome, it could still be useful to reduce the number of needed steps to open some files)
  • Make wrappers for using the FFMS2 library in other applications such as virtualdub and premiere import plugins if there's any real interest
  • Make all calls to SWScale and PP multithreaded
  • Export metadata information in the API (needed for a GUI to be more user friendly)
  • Figure out why h.264 in TS/PS decoding shows artifacts
  • Implement raw mpeg 1/2/4 and h.264 parsers to support those input formats for more than linear reading
  • Improve the horribly inefficient index format, currently a ~5MB index becomes 20kb after zipping
« Last Edit: September 14, 2010, 08:46:47 AM by Myrsloik »
IVTC.ORG - Framing the debate about fields

Offline JEEB

  • fushizenなDTVエンコーダー
  • Administrator
  • Member
  • *****
  • Posts: 117
    • View Profile
    • Yet Another x264 Builder
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #2 on: December 03, 2009, 12:20:01 PM »
  • ...
  • Write a graphic indexing app using QT creator (it will look at least twice as good as DGIndex)
  • Regression tests
  • Make wrappers for using the FFMS2 library in other applications such as virtualdub and premiere import plugins if there's any real interest
  • Figure out why h.264 in TS/PS decoding shows artifacts
  • ...

As someone rarely using the SWScale / PP stuff, I probably would vote for these, bolding the one I currently think as the most problematic thing for wide usage and italics meaning that it probably would make me less happy than the others.

Offline D404

  • Member
  • Posts: 23
  • 8-to-1 Mux
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #3 on: December 03, 2009, 01:25:29 PM »
  • Write a graphic indexing app using QT creator (it will look at least twice as good as DGIndex)
  • Figure out why h.264 in TS/PS decoding shows artifacts
  • Implement raw mpeg 1/2/4 and h.264 parsers to support those input formats for more than linear reading

My votes.

Offline Dark Shikari

  • x264 developer
  • Administrator
  • Member
  • *****
  • Posts: 650
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #4 on: December 03, 2009, 01:37:24 PM »
Vote for incremental indexing here; it would be a huge benefit once we add FFMS2 input to x264.

Offline Emess

  • Member
  • Posts: 27
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #5 on: December 03, 2009, 07:05:25 PM »
  • Write a graphic indexing app using QT creator (it will look at least twice as good as DGIndex)
  • Implement incremental indexing (this would be a pure API improvement and never show up in avisynth because of its limitations)
  • Figure out why h.264 in TS/PS decoding shows artifacts
  • Implement raw mpeg 1/2/4 and h.264 parsers to support those input formats for more than linear reading
My votes, I can attempt helping on the first one as well :S

Offline Thesis

  • Member
  • Posts: 10
    • View Profile
    • Thesis' stuff
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #6 on: December 03, 2009, 07:15:06 PM »
Would it be possible to implement AVC indexing support? DGAVCindex it's quite buggy.

Disregard if it has been asked before.

Offline checkers

  • Member
  • Posts: 72
    • View Profile
    • MeWiki
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #7 on: December 03, 2009, 07:19:57 PM »
Incremental indexing for x264.exe tastiness

Offline Emess

  • Member
  • Posts: 27
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #8 on: December 03, 2009, 07:24:32 PM »
Would it be possible to implement AVC indexing support? DGAVCindex it's quite buggy.

Disregard if it has been asked before.
What? ffms2 indexes everything it can read, this includes AVC. The main reason it shouldn't be used for BD loading is that some m2ts files get funky blocking issues, and others have severe seeking and framecount issues. It's a problem with the m2ts container and how libavformat handles it, not AVC itself. ffms2 is essentially just a wrapper for ffmpeg's libraries, that is, libavformat for splitting, libavcodec for decoding, libswscale for scaling, and libavfilter for ffpp and other filtering things. Try loading an mkv and you should have no problem, however remuxing an m2ts to mkv still has issues IIRC.
« Last Edit: December 03, 2009, 07:26:13 PM by Emess »

Offline Thesis

  • Member
  • Posts: 10
    • View Profile
    • Thesis' stuff
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #9 on: December 03, 2009, 07:34:39 PM »
I was doing it wrong lol. Ok then I vote for incremental indexing for x264 sake.

Offline TheRyuu

  • warpsharpened
  • Member
  • Posts: 42
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #10 on: December 03, 2009, 08:09:24 PM »
What? ffms2 indexes everything it can read, this includes AVC. The main reason it shouldn't be used for BD loading is that some m2ts files get funky blocking issues, and others have severe seeking and framecount issues. It's a problem with the m2ts container and how libavformat handles it, not AVC itself. ffms2 is essentially just a wrapper for ffmpeg's libraries, that is, libavformat for splitting, libavcodec for decoding, libswscale for scaling, and libavfilter for ffpp and other filtering things. Try loading an mkv and you should have no problem, however remuxing an m2ts to mkv still has issues IIRC.

Remuxing to mkv (should) fixes the blocking issues if and only if you're doing linear access to it.  Seeking will still produce issues (presumably because it's seeking to an I frame and not an IDR frame).
« Last Edit: December 03, 2009, 08:16:54 PM by TheRyuu »

Offline Emess

  • Member
  • Posts: 27
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #11 on: December 03, 2009, 08:23:50 PM »
Yes, linear access as far as the blocking issues goes is fine, seeking makes it hurf though. The incorrect framecount seems to be there regardless, at least going by my tests.

Offline Mr VacBob

  • Global Moderator
  • Member
  • *****
  • Posts: 40
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #12 on: December 04, 2009, 09:51:45 AM »
It'd be nice if you could report any problems with libavformat on the ffmpeg bug tracker~

I promise to read them and then forget about it for a year.

Offline Zarxrax

  • Member
  • Posts: 8
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #13 on: December 04, 2009, 02:54:31 PM »
I'll vote for #6. It would be nice to have import plugins for Premiere (and also Sony Vegas)

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #14 on: December 04, 2009, 03:48:30 PM »
I tried to read the plugin API documentation for premiere and didn't understand it at all (apart from the fact that it has a shitload of weird backward compatibility stuff). Is there a more accessible explanation to it somewhere?
IVTC.ORG - Framing the debate about fields

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #15 on: December 04, 2009, 03:49:45 PM »
It'd be nice if you could report any problems with libavformat on the ffmpeg bug tracker~

I promise to read them and then forget about it for a year.

That's what I/my minions do whenever it clearly is one. Nobody likes to write code so I try to offload it to other people.
IVTC.ORG - Framing the debate about fields

Offline Zarxrax

  • Member
  • Posts: 8
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #16 on: December 04, 2009, 04:36:50 PM »
I tried to read the plugin API documentation for premiere and didn't understand it at all (apart from the fact that it has a shitload of weird backward compatibility stuff). Is there a more accessible explanation to it somewhere?
I don't think so, but it might be handy to look at the AviSynth import plugin as an example: http://sourceforge.net/projects/videoeditorskit/files/

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #17 on: December 05, 2009, 02:01:27 AM »
I don't think so, but it might be handy to look at the AviSynth import plugin as an example: http://sourceforge.net/projects/videoeditorskit/files/
Maybe it's better if someone who actually understands premiere/vegas does it... the obfuscation is just too much for me to bother unless I'm getting paid.
IVTC.ORG - Framing the debate about fields

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #18 on: December 06, 2009, 01:00:17 PM »
This is an exclusive status update!

The remaining goals for 2.13 (in addition to the things already in the changelog) are to finish implementing index file compression. The test index file goes from ~9.2MB to ~0.75MB more or less for free. The other goal is to make avc in mkv work perfectly. This includes fixing the corruption on seeking when the video was remuxed from m2ts. (this definitely looks possible but we'll see what evil details show up...)

IVTC.org will also return soon. Maybe with the same old junk as before.
IVTC.ORG - Framing the debate about fields

Offline nieko_nera

  • Member
  • Posts: 3
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #19 on: December 06, 2009, 01:44:19 PM »
is this kind of video not supported, or i dont know how to use it...? Here is sample http://www.multiupload.com/70E2R2HFAD

MediaInfo:
Code: [Select]
General
ID                               : 1
Complete name                    : 12-05_19-36-08_TV3_.ts
Format                           : MPEG-TS
File size                        : 13.6 MiB
Duration                         : 55s 536ms
Overall bit rate                 : 2 056 Kbps

Video
ID                               : 801 (0x321)
Menu ID                          : 8 (0x8)
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format version                   : Version 2
Format profile                   : Main@L3.0
Format settings, CABAC           : Yes
Format settings, ReFrames        : 4 frames
Duration                         : 55s 460ms
Bit rate                         : 1 722 Kbps
Maximum bit rate                 : 2 598 Kbps
Width                            : 720 pixels
Height                           : 576 pixels
Display aspect ratio             : 4:3
Frame rate                       : 25.000 fps
Standard                         : PAL
Resolution                       : 24 bits
Colorimetry                      : 4:2:0
Scan type                        : Interlaced
Scan order                       : Top Field First
Bits/(Pixel*Frame)               : 0.166
Stream size                      : 11.4 MiB (84%)
Color primaries                  : BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM
Transfer characteristics         : BT.470-6 System B, BT.470-6 System G
Matrix coefficients              : BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM, IEC 61966-2-4 601

Audio
ID                               : 802 (0x322)
Menu ID                          : 8 (0x8)
Format                           : MPEG Audio
Format version                   : Version 1
Format profile                   : Layer 2
Duration                         : 55s 536ms
Bit rate mode                    : Constant
Bit rate                         : 192 Kbps
Maximum bit rate                 : 216 Kbps
Channel(s)                       : 2 channels
Sampling rate                    : 48.0 KHz
Resolution                       : 16 bits
Video delay                      : -1s 220ms
Stream size                      : 1.27 MiB (9%)
Language                         : Lithuanian

Menu
ID                               : 800 (0x320)
Menu ID                          : 8 (0x8)
List                             : 801 (0x321) (AVC) / 802 (0x322) (MPEG Audio, Lithuanian)
Maximum bit rate                 : 2814000

Duration                         : 55s 460ms
Frame rate                       : 25.000 fps

AVS script:
Code: [Select]
FFmpegSource2("12-05_19-36-08_TV3_.ts",atrack=-1,rffmode=1)
with:
rffmode=1 - duration 01:51, fps 25
rffmode=0 - duration 00:55, fps 49.858
rffmode=2 - duration 01:51, fps 20

Problem is that only with rffmode=1 i get correct frame rate, but video duration with this mode is doubled
« Last Edit: February 12, 2010, 11:57:27 PM by nieko_nera »
my English is bad, sorry

Offline Myrsloik

  • Member
  • Posts: 38
    • View Profile
    • IVTC.ORG
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #20 on: December 06, 2009, 02:41:10 PM »
Maybe is you specify exactly what the problem is. What makes you think it isn't supported?
Actually it's listed under known issues. RTFM.
« Last Edit: December 06, 2009, 02:51:52 PM by Myrsloik »
IVTC.ORG - Framing the debate about fields

Offline Thesis

  • Member
  • Posts: 10
    • View Profile
    • Thesis' stuff
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #21 on: December 06, 2009, 06:00:01 PM »
The other goal is to make avc in mkv work perfectly. This includes fixing the corruption on seeking when the video was remuxed from m2ts. (this definitely looks possible but we'll see what evil details show up...)
Yay /o/
Looking forward to it.

Offline Emess

  • Member
  • Posts: 27
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #22 on: December 07, 2009, 12:26:01 AM »
The test index file goes from ~9.2MB to ~0.75MB more or less for free.
So the zlib stuff stopped being shit? About time~

The other goal is to make avc in mkv work perfectly. This includes fixing the corruption on seeking when the video was remuxed from m2ts. (this definitely looks possible but we'll see what evil details show up...)
ASDF THANK YOU. This has been a major source of irritation what with dss2 not working on remuxed blurays and the only other option being unthinkable.

Offline nieko_nera

  • Member
  • Posts: 3
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #23 on: December 07, 2009, 01:40:12 AM »
Maybe is you specify exactly what the problem is. What makes you think it isn't supported?

Thank you for reply. Problem is that only with rffmode=1 i get correct frame rate, but video duration with this mode is doubled

Actually it's listed under known issues. RTFM.

What this issue is exactly? Is this it: Haali's splitter requires transport streams to be cut at packet boundaries. Use TsRemux to fix the stream before trying to open it.
I tried fixing with TsRemux, but problem still exist

Thank you
my English is bad, sorry

Offline komisar

  • Member
  • Posts: 29
    • View Profile
    • My x264 CLI/VFW builds and tools
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #24 on: December 07, 2009, 01:42:34 AM »
Sorry for the stupid question, but whether there is a 64-bit version of the plugin?

Offline JEEB

  • fushizenなDTVエンコーダー
  • Administrator
  • Member
  • *****
  • Posts: 117
    • View Profile
    • Yet Another x264 Builder
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #25 on: December 07, 2009, 04:53:20 AM »
Sorry for the stupid question, but whether there is a 64-bit version of the plugin?
IIRC kemuri-_9 built a 64bit ffms2 on #x264 earlier.
Quote from: kemuri-_9
<kemuri-_9>   lolololol, got ffms2 compiled for x64 w/avs support.... through using shared dlls for libav* and zlib
<kemuri-_9>   building ffmpeg to shared dlls was fairly easy, just need to spawn my msys environment on top of msvc's x64 env so it could use msvc's lib tool
Of course, shared dlls means lots of fun and mismatching dll versions can make it go boom randomly.

Offline Kovensky

  • Burning Hot Metal
  • Member
  • Posts: 37
    • View Profile
    • MPlayer Builds for Windows
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #26 on: December 07, 2009, 06:05:23 AM »
Of course, shared dlls means lots of fun and mismatching dll versions can make it go boom randomly.
Indeed, there's a rather big ass-thread on ffmpeg-devel about trying to solve that issue. They're debating it from a linux perspective though.
« Last Edit: December 07, 2009, 06:10:01 AM by Kovensky »

Offline skittle

  • Member
  • Posts: 32
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #27 on: December 07, 2009, 07:10:40 AM »
It would be very nice if FFMS2 could import a file list  :D

Code: [Select]
file1.vob >> list.txt
file2.vob >> list.txt

Code: [Select]
FFVideoSource("list.txt")

Offline kemuri-_9

  • Compiling Encoder
  • Member
  • Posts: 269
    • View Profile
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #28 on: December 07, 2009, 07:45:32 AM »
IIRC kemuri-_9 built a 64bit ffms2 on #x264 earlier. Of course, shared dlls means lots of fun and mismatching dll versions can make it go boom randomly.
the only way i seeing getting a 64bit version of the plugin w/o shared dlls currently would be to compile ffmpeg with ICL and use the generated static libs with ffms2.
i haven't yet tried this since
A) i don't particularly use ffms2
B) it would be a pain to edit the ffmpeg configure/makefile to use icl instead of mingw.
« Last Edit: December 07, 2009, 07:47:19 AM by kemuri-_9 »

Offline Kovensky

  • Burning Hot Metal
  • Member
  • Posts: 37
    • View Profile
    • MPlayer Builds for Windows
Re: FFMS2 (The Fabulous FM Source 2)
« Reply #29 on: December 07, 2009, 08:15:20 AM »
B) it would be a pain to edit the ffmpeg configure/makefile to use icl instead of mingw.
Does ffmpeg even compile with icl? I know it does with icc, but I heard that icl expects MSVC syntax and ffmpeg is C99...