jave2
jave2 copied to clipboard
Enhancement - Using streams instead of file object
Hi, Thanks for the effort of maintaining this api. Can this be extended to use stream of file as input and output instead of creating file object itself.!!? In realtime projects it does not make sence to create a new file for each conversion.
Thanks, Arun
Can you please make an example of such an API? ffmpeg can work with input streams, but we will have to make sure the url's are handled correctly
For outgoing streaming, here you need to show me what you need
AND: Patches are welcom which enhance it in that direction :)
ffmpeg supports only http streaming out of the box. But what about the support of https URLs?
@eppjo Could you make a proposal API for this? We would then need to make some kind of https->http proxy for it
To enable https in ffmpeg seems to be enough to compile ffmpeg with openssl as discussed here:.
But I don't know if this is also valid for Windows platform.
Regarding API proposal, I need some time ;-)
We take the executables from here: https://ffmpeg.zeranoe.com/builds/ So you could ask there in the forum for OpenSSL enabled builds.
Please look in the forum first, there seems to be discussions about this topic.
Sorry, I should have tested it first.
I just ran it on the command line:
ffmpeg -i https://example-files.online-convert.com/audio/m4a/example.m4a -c:a libmp3lame output.mp3
Well, input streams seems to work for ffmpeg.
After searching for the reason:
compiler flag: --enable-openssl is not used, but flag: --enable-gnutls for the available executables.
My API proposal is, to:
- create MultimediaObject constructor also for URL and
- and add file path OR URL string as argument behind
ffmpeg -i.
The new 2.5.1-SNAPSHOT version now accepts a java.net.URL instead of File for the MultimediaObject Could you test if it works fine for you
@a-schild: where did you deploy the snapshot? I cannot find a 2.5.1-SNAPSHOT version with recent date. The one I can find here is from June, 24th not including your recent changes.
I had a problem with publishing the artifacts yesterday. Now they are published and should be available in a few minutes
There is still a problem with having two snapshot versions 2.5.1.
And java-all-deps is not updated.
But I downloaded the newly generated version as jar and did some tests.
Conversion works fine. +1
Issues recognized on using the ConvertProgressListener:
MultimediaInfoinsourceInfo()is alwaysnullprogress()always contains-1
...
15:38:50.682 [main] DEBUG ws.schild.jave.FFMPEGExecutor - About to execute C:\Users\eppjo\AppData\Local\Temp\jave\ffmpeg-amd64-2.5.1-SNAPSHOT.exe -i https://example-files.online-convert.com/audio/m4a/example.m4a -vn -acodec libmp3lame -ab 128000 -ac 2 -ar 44100 -f mp3 -y C:\Users\eppjo\AppData\Local\Temp\aud_6096813908864777333.mp3 -hide_banner
MultimediaInfo: null
15:38:53.172 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (1): <Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://example-files.online-convert.com/audio/m4a/example.m4a':>
15:38:53.172 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (2): < Metadata:>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (3): < major_brand : M4A >
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (4): < minor_version : 512>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (5): < compatible_brands: isomiso2>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (6): < title : M4A Test File>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (7): < album : Example Files>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (8): < encoder : Lavf55.33.100>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (9): < Duration: 00:00:36.65, start: 0.000000, bitrate: 197 kb/s>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (10): < Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 195 kb/s (default)>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (11): < Metadata:>
15:38:53.173 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (12): < handler_name : SoundHandler>
15:38:53.177 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (13): <Stream mapping:>
15:38:53.177 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (14): < Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))>
15:38:53.177 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (15): <Press [q] to stop, [?] for help>
15:38:53.181 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (16): <Output #0, mp3, to 'C:\Users\eppjo\AppData\Local\Temp\aud_6096813908864777333.mp3':>
15:38:53.181 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (17): < Metadata:>
15:38:53.181 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (18): < major_brand : M4A >
15:38:53.181 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (19): < minor_version : 512>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (20): < compatible_brands: isomiso2>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (21): < TIT2 : M4A Test File>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (22): < TALB : Example Files>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (23): < TSSE : Lavf58.20.100>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (24): < Stream #0:0(und): Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp, 128 kb/s (default)>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (25): < Metadata:>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (26): < handler_name : SoundHandler>
15:38:53.182 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (27): < encoder : Lavc58.35.100 libmp3lame>
15:38:53.677 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (28): <size= 256kB time=00:00:28.31 bitrate= 74.1kbits/s speed=56.6x >
p=-1
15:38:53.815 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (29): <size= 574kB time=00:00:36.67 bitrate= 128.2kbits/s speed=57.6x >
p=-1
15:38:53.815 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (30): <video:0kB audio:573kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.103366%>
...
The All-Snapshot is now also deployed to maven central. (Forgot this one)
The MultimediaInfo is empty, since I'm not sure if we can read the source stream multiple times... There is a whole lot of options which can be set for the http protocol
https://ffmpeg.org/ffmpeg-protocols.html#http
Not sure how often this will be needed in practice, but at least the info if the source can be read multiple times is probably needed to handle things correctly. When the source can't be read multiple times, then we will not have a progress indication and the info object will be null too. (Unless you see another way to handle this)
And when you use other protocols, there are also many things users can set.