FFmpeg plugin question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

FFmpeg plugin question

Stein Rørvik
The Fiji update site for FFMPEG links to
http://fiji.sc/~schindelin/ffmpeg-plugins/
This plugin works as advertised.

But where can I find the source code of this ImageJ plugin (FFMPEG_IO.jar)?
What I would like to do is to is to see if it can be modified to support modern codecs like H.264

Under
http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
we find the library files for the respective platforms,
but they are a bit outdated (2013).
Where can I find newer versions of the native libraries (ffmpeg.dll for Windows) ?

Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Curtis Rueden
Hi Stein,

The code for the FFMPEG update site can be found here:
  https://github.com/scifio/scifio-javacv/tree/ffmpeg

Development moved on from there a lot in that repository. If I recall
recorrectly, Johannes's goal was to implement a SCIFIO Format plugin based
on JavaCV, instead of using FFMPEG native libraries. But it never reached a
releasable state.

The native FFMPEG libraries were built in a pretty crazy way by making
system calls to configure and make via Java (!), which you can see from the
source at that tag. I would not recommend trying to hack on the code from
that point, but rather from the master branch, which leans on the javacv
library for the FFMPEG native interface.

Happy to advise further if you decide to seriously work on this. Although
you may want to post on forum.image.sc in the Development category rather
than on this mailing list, in that case.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Have you tried the Image.sc Forum? https://forum.image.sc/



On Fri, Mar 1, 2019 at 12:53 PM Stein Rørvik <[hidden email]> wrote:

> The Fiji update site for FFMPEG links to
> http://fiji.sc/~schindelin/ffmpeg-plugins/
> This plugin works as advertised.
>
> But where can I find the source code of this ImageJ plugin (FFMPEG_IO.jar)?
> What I would like to do is to is to see if it can be modified to support
> modern codecs like H.264
>
> Under
> http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> we find the library files for the respective platforms,
> but they are a bit outdated (2013).
> Where can I find newer versions of the native libraries (ffmpeg.dll for
> Windows) ?
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Stein Rørvik
Thanks;

I do not plan to do much work on this as I am not a programmer, I just research possible existing solutions. Sometimes one can make such a plugin export in a different format by just changing the name of the codec, since it is ffmpeg that does the conversion. My java programming skills is limited to changing existing code once I understand how it works, not writing anything complex from scratch.

So far I have found three plugins / libraries capable of exporting movies via ffmpeg from ImageJ, but none of them work correctly for H.264. Most work fine with MPEG4 but I have not yet found any that produces H.264 correctly. So today I convert on the command line. From that I see that H.264 gives the best quality video for my data, with MPEG4 second best. MPEG2 and MPEG1 gives inferior quality; all when comparing at the same bitrate.

Looking at the source code at the link you provided, I see that the codec is auto-determined by the library from the chosen file extension. The default is .mpg which gives a mpeg1video codec. So I tried to just change the output file extension to .mp4, and then I get a video file with an mpeg4 codec, which is much better. Unfortunately changing to .mkv did not result in any H.264 codec (which is usually the default for this container) but an mpeg4 codec too. Anyway, going from mpeg1 to mpeg4 is a big improvement, and the simple way to do this (just changing the output file extension) was not obvious to me until I saw the source code.

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Curtis Rueden
Sent: 1. mars 2019 21:55
To: [hidden email]
Subject: Re: FFmpeg plugin question

Hi Stein,

The code for the FFMPEG update site can be found here:
  https://github.com/scifio/scifio-javacv/tree/ffmpeg

Development moved on from there a lot in that repository. If I recall recorrectly, Johannes's goal was to implement a SCIFIO Format plugin based on JavaCV, instead of using FFMPEG native libraries. But it never reached a releasable state.

The native FFMPEG libraries were built in a pretty crazy way by making system calls to configure and make via Java (!), which you can see from the source at that tag. I would not recommend trying to hack on the code from that point, but rather from the master branch, which leans on the javacv library for the FFMPEG native interface.

Happy to advise further if you decide to seriously work on this. Although you may want to post on forum.image.sc in the Development category rather than on this mailing list, in that case.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden Have you tried the Image.sc Forum? https://forum.image.sc/



On Fri, Mar 1, 2019 at 12:53 PM Stein Rørvik <[hidden email]> wrote:

> The Fiji update site for FFMPEG links to
> http://fiji.sc/~schindelin/ffmpeg-plugins/
> This plugin works as advertised.
>
> But where can I find the source code of this ImageJ plugin (FFMPEG_IO.jar)?
> What I would like to do is to is to see if it can be modified to
> support modern codecs like H.264
>
> Under
> http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> we find the library files for the respective platforms, but they are a
> bit outdated (2013).
> Where can I find newer versions of the native libraries (ffmpeg.dll
> for
> Windows) ?
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Curtis Rueden
In reply to this post by Curtis Rueden
Hi Stein,

> going from mpeg1 to mpeg4 is a big improvement

Glad to hear.

> the simple way to do this (just changing the output file extension)
> was not obvious to me until I saw the source code.

One thing you could do to help others is to edit the wiki at
https://imagej.net/Video to document this behavior.

Regards,
Curtis


On Sat, Mar 2, 2019, 06:32 Stein Rørvik <[hidden email]> wrote:

> Thanks;
>
> I do not plan to do much work on this as I am not a programmer, I just
> research possible existing solutions. Sometimes one can make such a plugin
> export in a different format by just changing the name of the codec, since
> it is ffmpeg that does the conversion. My java programming skills is
> limited to changing existing code once I understand how it works, not
> writing anything complex from scratch.
>
> So far I have found three plugins / libraries capable of exporting movies
> via ffmpeg from ImageJ, but none of them work correctly for H.264. Most
> work fine with MPEG4 but I have not yet found any that produces H.264
> correctly. So today I convert on the command line. From that I see that
> H.264 gives the best quality video for my data, with MPEG4 second best.
> MPEG2 and MPEG1 gives inferior quality; all when comparing at the same
> bitrate.
>
> Looking at the source code at the link you provided, I see that the codec
> is auto-determined by the library from the chosen file extension. The
> default is .mpg which gives a mpeg1video codec. So I tried to just change
> the output file extension to .mp4, and then I get a video file with an
> mpeg4 codec, which is much better. Unfortunately changing to .mkv did not
> result in any H.264 codec (which is usually the default for this container)
> but an mpeg4 codec too. Anyway, going from mpeg1 to mpeg4 is a big
> improvement, and the simple way to do this (just changing the output file
> extension) was not obvious to me until I saw the source code.
>
> Stein
>
> -----Original Message-----
> From: ImageJ Interest Group <[hidden email]> On Behalf Of Curtis
> Rueden
> Sent: 1. mars 2019 21:55
> To: [hidden email]
> Subject: Re: FFmpeg plugin question
>
> Hi Stein,
>
> The code for the FFMPEG update site can be found here:
>   https://github.com/scifio/scifio-javacv/tree/ffmpeg
>
> Development moved on from there a lot in that repository. If I recall
> recorrectly, Johannes's goal was to implement a SCIFIO Format plugin based
> on JavaCV, instead of using FFMPEG native libraries. But it never reached a
> releasable state.
>
> The native FFMPEG libraries were built in a pretty crazy way by making
> system calls to configure and make via Java (!), which you can see from the
> source at that tag. I would not recommend trying to hack on the code from
> that point, but rather from the master branch, which leans on the javacv
> library for the FFMPEG native interface.
>
> Happy to advise further if you decide to seriously work on this. Although
> you may want to post on forum.image.sc in the Development category rather
> than on this mailing list, in that case.
>
> Regards,
> Curtis
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden Have you
> tried the Image.sc Forum? https://forum.image.sc/
>
>
>
> On Fri, Mar 1, 2019 at 12:53 PM Stein Rørvik <[hidden email]>
> wrote:
>
> > The Fiji update site for FFMPEG links to
> > http://fiji.sc/~schindelin/ffmpeg-plugins/
> > This plugin works as advertised.
> >
> > But where can I find the source code of this ImageJ plugin
> (FFMPEG_IO.jar)?
> > What I would like to do is to is to see if it can be modified to
> > support modern codecs like H.264
> >
> > Under
> > http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> > we find the library files for the respective platforms, but they are a
> > bit outdated (2013).
> > Where can I find newer versions of the native libraries (ffmpeg.dll
> > for
> > Windows) ?
> >
> > Stein
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Kenton Arkill
In reply to this post by Stein Rørvik
Dear all
Related: on the save as movie site (
https://sites.google.com/site/qingzongtseng/save-as-movie ) the ffmpeg.jar
does not link/download. is there somewhere else I can get this from?
Best
Kenton

On Fri, 1 Mar 2019 at 18:53, Stein Rørvik <[hidden email]> wrote:

> The Fiji update site for FFMPEG links to
> http://fiji.sc/~schindelin/ffmpeg-plugins/
> This plugin works as advertised.
>
> But where can I find the source code of this ImageJ plugin (FFMPEG_IO.jar)?
> What I would like to do is to is to see if it can be modified to support
> modern codecs like H.264
>
> Under
> http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> we find the library files for the respective platforms,
> but they are a bit outdated (2013).
> Where can I find newer versions of the native libraries (ffmpeg.dll for
> Windows) ?
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Curtis Rueden
In reply to this post by Stein Rørvik
Hi Kenton,

It looks like the author, Qingzong Tseng (CCed), is in the process of
moving things around.

Try browsing around the GitHub site:
https://github.com/qztseng/imagej_plugins

@Qingzong If you set up an ImageJ update site [1], users would not have
these problems.

Regards,
Curtis

[1] https://imagej.net/How_to_set_up_and_populate_an_update_site

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Have you tried the Image.sc Forum? https://forum.image.sc/



On Thu, Apr 18, 2019 at 7:21 AM Kenton Arkill <[hidden email]>
wrote:

> Dear all
> Related: on the save as movie site (
> https://sites.google.com/site/qingzongtseng/save-as-movie ) the ffmpeg.jar
> does not link/download. is there somewhere else I can get this from?
> Best
> Kenton
>
> On Fri, 1 Mar 2019 at 18:53, Stein Rørvik <[hidden email]> wrote:
>
> > The Fiji update site for FFMPEG links to
> > http://fiji.sc/~schindelin/ffmpeg-plugins/
> > This plugin works as advertised.
> >
> > But where can I find the source code of this ImageJ plugin
> (FFMPEG_IO.jar)?
> > What I would like to do is to is to see if it can be modified to support
> > modern codecs like H.264
> >
> > Under
> > http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> > we find the library files for the respective platforms,
> > but they are a bit outdated (2013).
> > Where can I find newer versions of the native libraries (ffmpeg.dll for
> > Windows) ?
> >
> > Stein
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Kenton Arkill
Thankyou very much! found it on the github address.
However I do get his error:
error:org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error
-22: Could not open video codec.
(I'm using mac OS 10.14.4, Fiji (updated, and ImageJ 1.52n, java 1.80_202),
trying to save as an MPEG)
Any help is appreciated.

Best
Kenton

On Thu, 18 Apr 2019 at 16:00, Curtis Rueden <
[hidden email]> wrote:

> Hi Kenton,
>
> It looks like the author, Qingzong Tseng (CCed), is in the process of
> moving things around.
>
> Try browsing around the GitHub site:
> https://github.com/qztseng/imagej_plugins
>
> @Qingzong If you set up an ImageJ update site [1], users would not have
> these problems.
>
> Regards,
> Curtis
>
> [1] https://imagej.net/How_to_set_up_and_populate_an_update_site
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
> Have you tried the Image.sc Forum? https://forum.image.sc/
>
>
>
> On Thu, Apr 18, 2019 at 7:21 AM Kenton Arkill <[hidden email]>
> wrote:
>
> > Dear all
> > Related: on the save as movie site (
> > https://sites.google.com/site/qingzongtseng/save-as-movie ) the
> ffmpeg.jar
> > does not link/download. is there somewhere else I can get this from?
> > Best
> > Kenton
> >
> > On Fri, 1 Mar 2019 at 18:53, Stein Rørvik <[hidden email]>
> wrote:
> >
> > > The Fiji update site for FFMPEG links to
> > > http://fiji.sc/~schindelin/ffmpeg-plugins/
> > > This plugin works as advertised.
> > >
> > > But where can I find the source code of this ImageJ plugin
> > (FFMPEG_IO.jar)?
> > > What I would like to do is to is to see if it can be modified to
> support
> > > modern codecs like H.264
> > >
> > > Under
> > > http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> > > we find the library files for the respective platforms,
> > > but they are a bit outdated (2013).
> > > Where can I find newer versions of the native libraries (ffmpeg.dll for
> > > Windows) ?
> > >
> > > Stein
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > >
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg plugin question

Stein Rørvik
I am on Windows 7 and the updated plugin found on on Github works for me in ImageJ 1.52. Apparently the author has recently updated the plugin for JavaCV 1.4.4 and OpenCV 4.0.1; did you make sure you used the updated jars for all libraries?

The legacy plugin, which the main page links to, was for JavaCV 0.1 and OpenCV 2.4.
Apparently the ffmpeg.jar for the legacy version is now missing. I downloaded it in early February this year so if you can't get the updated version to work, I can send it to you for you to try. The legacy version also works for me on Windows 7.

A third alternative that you can try (besides the existing FFMPEG_IO update site) is the one discussed in this thread:
https://forum.image.sc/t/plugins-for-reading-and-writing-compressed-video/8777

I tested all these plugins in February and found all of them to work for MPEG4, but not for H264 saved as MKV container which was my original objective. (The updated qztseng plugin works fine for H264 in MP4 container though.)

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Kenton Arkill
Sent: 18. april 2019 21:55
To: [hidden email]
Subject: Re: FFmpeg plugin question

Thankyou very much! found it on the github address.
However I do get his error:
error:org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error
-22: Could not open video codec.
(I'm using mac OS 10.14.4, Fiji (updated, and ImageJ 1.52n, java 1.80_202), trying to save as an MPEG) Any help is appreciated.

Best
Kenton

On Thu, 18 Apr 2019 at 16:00, Curtis Rueden < [hidden email]> wrote:

> Hi Kenton,
>
> It looks like the author, Qingzong Tseng (CCed), is in the process of
> moving things around.
>
> Try browsing around the GitHub site:
> https://github.com/qztseng/imagej_plugins
>
> @Qingzong If you set up an ImageJ update site [1], users would not
> have these problems.
>
> Regards,
> Curtis
>
> [1] https://imagej.net/How_to_set_up_and_populate_an_update_site
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden Have
> you tried the Image.sc Forum? https://forum.image.sc/
>
>
>
> On Thu, Apr 18, 2019 at 7:21 AM Kenton Arkill
> <[hidden email]>
> wrote:
>
> > Dear all
> > Related: on the save as movie site (
> > https://sites.google.com/site/qingzongtseng/save-as-movie ) the
> ffmpeg.jar
> > does not link/download. is there somewhere else I can get this from?
> > Best
> > Kenton
> >
> > On Fri, 1 Mar 2019 at 18:53, Stein Rørvik <[hidden email]>
> wrote:
> >
> > > The Fiji update site for FFMPEG links to
> > > http://fiji.sc/~schindelin/ffmpeg-plugins/
> > > This plugin works as advertised.
> > >
> > > But where can I find the source code of this ImageJ plugin
> > (FFMPEG_IO.jar)?
> > > What I would like to do is to is to see if it can be modified to
> support
> > > modern codecs like H.264
> > >
> > > Under
> > > http://fiji.sc/~schindelin/ffmpeg-plugins/lib/
> > > we find the library files for the respective platforms, but they
> > > are a bit outdated (2013).
> > > Where can I find newer versions of the native libraries
> > > (ffmpeg.dll for
> > > Windows) ?
> > >
> > > Stein
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > >
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html