Skip to content
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

WIP: Add loopAttribute to EncodingAttributes #79

Merged
merged 2 commits into from
Jul 14, 2020

Conversation

chrysophylax
Copy link
Contributor

See #78

@chrysophylax
Copy link
Contributor Author

Hmmm. This doesn't seem to jive very well. I must've fessed something up with the order as I'm getting 1 returns from ffmpeg.

@chrysophylax chrysophylax changed the title Add loopAttribute to EncodingAttributes WIP: Add loopAttribute to EncodingAttributes Mar 3, 2020
@a-schild
Copy link
Owner

a-schild commented Mar 3, 2020

I think you must add both as separate arguments like here:

if (codec != null)
            {
                ffmpeg.addArgument("-vcodec");
                ffmpeg.addArgument(codec);
            }

@chrysophylax
Copy link
Contributor Author

Indeed, that fixed the erroneous return messages. On the other hand, I seem to have entered either an infinite loop or my duration calculation is wrong in my test code where duration = (25 * 1000)

From what I understand, duration as set in EncodingAttributes is supposed to be in milliseconds. Is this correct?

@a-schild
Copy link
Owner

a-schild commented Mar 3, 2020

For testing, it might be simpler to get ffmpeg.exe working in the commandline, and then integrating it in jave

@a-schild
Copy link
Owner

a-schild commented Mar 3, 2020

Do you mean this https://trac.ffmpeg.org/wiki/Slideshow

@chrysophylax
Copy link
Contributor Author

chrysophylax commented Mar 3, 2020

Yes, the use case was basically for a single image

Single image

Example with output video duration set to 30 seconds with -t 30:

ffmpeg -loop 1 -i img.jpg -c:v libx264 -t 30 -pix_fmt yuv420p out.mp4

so something similar is the desired output (although I am testing with vp9 and webm and it works, I'm just getting infinitely growing .webm video files :-) )

@chrysophylax
Copy link
Contributor Author

chrysophylax commented Mar 3, 2020

OK, digging into EncodingAttributes.java I see it's seconds here

Sets the duration (seconds) of the re-encoded stream.

whereas in MultimediaInfo duration is given as milliseconds which probably confused me ;)

@chrysophylax
Copy link
Contributor Author

So I did what you suggested @a-schild and tested with the included binary. What I need is basically something like the following exposed. This PR adds the loop attribute but not the -shortest flag.

./ffmpeg-amd64 -loop 1 -i /tmp/test/image.png -i /tmp/test/audio.ogg -c:v libvpx-vp9 -c:a copy -shortest mux.webm

@chrysophylax
Copy link
Contributor Author

Seems -loop 1 is only used for the image demuxer so it must always precede -i ...image.png. Interesting.

@a-schild
Copy link
Owner

a-schild commented Mar 3, 2020

Can you please also add some test cases to the project?

See here for some existing test cases.
https://github.com/a-schild/jave2/tree/master/jave-core-test/src/test/java/ws/schild/jave

Just create a new class to test the image->video stuff in different variations.
You can use the existing test images for this or/and add new ones as required

@a-schild a-schild merged commit 6aea383 into a-schild:master Jul 14, 2020
@a-schild
Copy link
Owner

Your merge request is included in the 2.8.0-SNAPSHOT release.
Can you please test it and giveok for a final release if everything is OK?

Thanks for your submission

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants