GithubHelp home page GithubHelp logo

a-schild / jave2 Goto Github PK

View Code? Open in Web Editor NEW
1.2K 35.0 245.0 793 MB

The JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project

License: GNU General Public License v3.0

Java 100.00%
java ffmpeg-wrapper ffmpeg converter encoder decoder

jave2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jave2's Issues

Let's add Sponsor Button

I think this is a new functionality on Github.

You can go to settings :

chrome_2019-05-31_11-05-47

And put your links for Sponsoring.

Checkout how it looks for XR3Player :

chrome_2019-05-31_11-06-27

Below is an example file (Modify it on your needs so it points your paypal and stuff) :

# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: GOXR3PLUSTUDIO
open_collective: # Replace with a single Open Collective username
ko_fi: goxr3plusstudio
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: https://www.paypal.me/GOXR3PLUSCOMPANY

Convert .wma to mp3 failed

Using the following attributes to convert .wma to .mp3 failed:

File source = new File("source.wav");
File target = new File("target.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

The error:

[libmp3lame @ 0000000000500340] Queue input is backward in time

cannot get the duration of the aac audio

i have two acc audios,use jave to calculate the duration, one of them is correct,the other get -1. how can i get the real duration?

the result:

0.aac: 60050
1.aac: -1

i use the music player,all of them can run correct。

Strange error with audio

Today i got this strange error and the fun fact is that i can't reproduce it even with the same variables and audio ...

ws.schild.jave.EncoderException: In step: 3 Error in line 30 : <[mp3 @ 00000266d57fa660] invalid new backstep -1>
Calculting WAV amplitudes
	at ws.schild.jave.ConversionOutputAnalyzer.analyzeNewLine(ConversionOutputAnalyzer.java:155)
	at ws.schild.jave.Encoder.encode(Encoder.java:530)
	at main.java.com.goxr3plus.xr3player.xplayer.waveform.WaveFormService$1.transcodeToWav(WaveFormService.java:345)
	at main.java.com.goxr3plus.xr3player.xplayer.waveform.WaveFormService$1.processFromNoWavFile(WaveFormService.java:190)
	at main.java.com.goxr3plus.xr3player.xplayer.waveform.WaveFormService$1.call(WaveFormService.java:143)
	at main.java.com.goxr3plus.xr3player.xplayer.waveform.WaveFormService$1.call(WaveFormService.java:1)
	at javafx.graphics/javafx.concurrent.Task$TaskCallable.call(Task.java:1425)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$6(Service.java:725)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$7(Service.java:724)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.base/java.lang.Thread.run(Thread.java:844)

Can we combine TarsosTranscoder with Jave2

I have this beautiful question after finding today TarsosTranscoder Library , we are using some of the latest FFMPEG libraries for JAVE2 and TarsosTranscoder has stopped being maintained .

The code is pretty similar to Jave though it contains modifications , because i am using both JAVE2 and TarsosTranscoder for XR3Player and they create two different FFMPEG files .

Can we combine the code inside the Jave2 ?

Unknown encoder 'libvo_aacenc'

public static File encodeMp4(File mp4Video, String outputPath) throws IllegalArgumentException, InputFormatException, EncoderException {
		File LQmp4 = new File(outputPath);

		AudioAttributes audioAttr = new AudioAttributes();
		VideoAttributes videoAttr = new VideoAttributes();
		EncodingAttributes encodingAttr = new EncodingAttributes();

		audioAttr.setChannels(new Integer(2));
		audioAttr.setCodec("aac");
		audioAttr.setBitRate(new Integer(128000));
		audioAttr.setSamplingRate(new Integer(44100));
		
		videoAttr.setCodec("libx264");
		videoAttr.setBitRate(new Integer(4000000));
		
		encodingAttr.setAudioAttributes(audioAttr);
		encodingAttr.setVideoAttributes(videoAttr);
		encodingAttr.setFormat("mp4");

		Encoder encoder = new Encoder();
		encoder.encode(new MultimediaObject(mp4Video), LQmp4, encodingAttr);


		return LQmp4;
	}

I'm using this version in my pom.xml

<dependency>
		    <groupId>ws.schild</groupId>
		    <artifactId>jave-core</artifactId>
		    <version>2.4.4</version>
		</dependency>
		
		<dependency>
		    <groupId>ws.schild</groupId>
		    <artifactId>jave-native-linux64</artifactId>
		    <version>2.4.4</version>
		</dependency>

Here's the log:

15:23:17.135 [main] DEBUG ws.schild.jave.ConversionOutputAnalyzer - Input Line (25): <Unknown encoder 'libvo_aacenc'>
15:23:17.135 [main] INFO ws.schild.jave.ConversionOutputAnalyzer - Unhandled message in step: 1 Line: 25 message: <Unknown encoder 'libvo_aacenc'>
15:23:17.135 [main] ERROR ws.schild.jave.Encoder - Process exit code: 1 for in.mp4 to out.mp4
Exception in thread "main" ws.schild.jave.EncoderException: Exit code of ffmpeg encoding run is 1
at ws.schild.jave.Encoder.encode(Encoder.java:563)
at ws.schild.jave.Encoder.encode(Encoder.java:349)
at app.duyuinc.duyurecord.util.MidiaManagement.encodeMp4(MidiaManagement.java:55)
at app.duyuinc.duyurecord.DuyurecordApplication.main(DuyurecordApplication.java:22)

convert .amr to mp3 failed

    File source = new File("one.amr");
    File target = new File("two.mp3");

    AudioAttributes audio = new AudioAttributes();
    audio.setCodec("libmp3lame");

// audio.setBitRate(new Integer(128000));
// audio.setChannels(new Integer(2));
// audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
try {
Encoder encoder = new Encoder();
encoder.encode( new MultimediaObject(source), target, attrs);
} catch (Exception e) {
e.printStackTrace();
}

run exception:
ws.schild.jave.InputFormatException: Invalid data found when processing input
at ws.schild.jave.MultimediaObject.parseMultimediaInfo(MultimediaObject.java:171)
at ws.schild.jave.MultimediaObject.getInfo(MultimediaObject.java:113)
at ws.schild.jave.Encoder.encode(Encoder.java:546)
at ws.schild.jave.Encoder.encode(Encoder.java:357)
at com.yanhua.demo.service.TestService.changeToMp3(TestService.java:67)
at com.yanhua.demo.service.TestService.main(TestService.java:18)

.ogg -> .mp3 throws exception, but seems to complete anyway

I'm using your latest release. Conversion code:

  new AudioAttributes audio;
  audio.setCodec("libmp3lame");
  new EncodingAttributes attrs;
  attrs.setFormat("mp3");
  attrs.setAudioAttributes(audio);
  new Encoder().encode(new MultimediaObject(ogg), mp3, attrs);

Audio file: buggy.ogg

Error:

Converting /root/JavaX-Data/Stored Voice Messages/66383863-1535117667872.ogg to /root/JavaX-Data/Stored Voice Messages/66383863-1535117667872.mp3
ws.schild.jave.EncoderException: In step: 3 Error in line 14 : <[ogg @ 0x4fd9c80] Packet processing failed: Invalid data found when processing input>
	at ws.schild.jave.ConversionOutputAnalyzer.analyzeNewLine(ConversionOutputAnalyzer.java:155)
	at ws.schild.jave.Encoder.encode(Encoder.java:530)
	at ws.schild.jave.Encoder.encode(Encoder.java:340)
	at main.oggToMP3(m1017517.java:339)
	at main$2$1$1.run(m1017517.java:117)

Platform is Linux 64. ffmpeg seems to handle the same file fine.

"Process hasn't exited"

Anything to worry about? File is converted fine...

Converting /root/JavaX-Data/Stored Voice Messages/604039341-1535322635081.ogg to /root/JavaX-Data/Stored Voice Messages/604039341-1535322635081.mp3
java.lang.IllegalThreadStateException: process hasn't exited
	at java.base/java.lang.ProcessImpl.exitValue(ProcessImpl.java:521)
	at ws.schild.jave.FFMPEGExecutor.getProcessExitCode(FFMPEGExecutor.java:209)
	at ws.schild.jave.Encoder.encode(Encoder.java:553)
	at ws.schild.jave.Encoder.encode(Encoder.java:349)

Unknown encoder 'libvo_aacenc'

`public static File encodeMp4(File mp4Video, String outputPath) throws IllegalArgumentException, InputFormatException, EncoderException {
File LQmp4 = new File(outputPath);

	AudioAttributes audioAttr = new AudioAttributes();
	VideoAttributes videoAttr = new VideoAttributes();
	EncodingAttributes encodingAttr = new EncodingAttributes();

	audioAttr.setChannels(new Integer(2));
	audioAttr.setCodec("aac");
	audioAttr.setBitRate(new Integer(128000));
	audioAttr.setSamplingRate(new Integer(44100));
	
	videoAttr.setCodec("libx264");
	videoAttr.setBitRate(new Integer(4000000));
	//videoAttr.setFrameRate(new Integer(24));
	
	encodingAttr.setAudioAttributes(audioAttr);
	encodingAttr.setVideoAttributes(videoAttr);
	encodingAttr.setFormat("mp4");

	Encoder encoder = new Encoder();
	encoder.encode(new MultimediaObject(mp4Video), LQmp4, encodingAttr);


	return LQmp4;
}`

Problem encoding multi-channel vorbis audio

Hi. I have the following source code and I try to encode a four channel OGG-vorbis file to a four channel flac.

        File source = new File("source.ogg");
        File target = new File("target.flac");
        
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec("flac");
        audio.setBitRate(new Integer(360000));
        audio.setChannels(new Integer(4));
//        audio.setVolume(new Integer(1000));
//        audio.setQuality(new Integer(1000));
        audio.setSamplingRate(new Integer(48000));
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("flac");
        attrs.setAudioAttributes(audio);
        
        Encoder encoder = new Encoder();
        
        String formats[] = null;
        try {
            System.out.println("Supported decoding formats");
            System.out.println("--------------------------");
            formats = encoder.getSupportedDecodingFormats();
            for (String frm : formats) { System.out.println(frm); }
            
            System.out.println("Supported encoding formats");
            System.out.println("--------------------------");
            encoder.getSupportedEncodingFormats();
            for (String frm : formats) { System.out.println(frm); }
            
            System.out.println("Audio decoders");
            System.out.println("--------------");
            formats = encoder.getAudioDecoders();
            for (String frm : formats) { System.out.println(frm); }
                    
            System.out.println("Audio encoders");
            System.out.println("--------------");
            formats = encoder.getAudioEncoders();
            for (String frm : formats) { System.out.println(frm); }
        } catch (EncoderException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        try {
            MultimediaObject mo = new MultimediaObject(source);

            MultimediaInfo info = mo.getInfo();
            System.out.println(info.getAudio().getBitRate());
            System.out.println(info.getAudio().getChannels());
            System.out.println(info.getAudio().getDecoder());
            System.out.println(info.getAudio().getSamplingRate());
            
            encoder.encode(mo, target, attrs);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (EncoderException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }/* catch (InputFormatException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }*/

There are various problems reading the source file.

  1. The getBitRate() of MultimediaInfo returns 959. It seems totally strange bitrate and really low.
  2. The channel counts are reported as -1.
  3. When encoding it to flac, the flac ends having 4 channels but only the first 2 are valid as the 3rd is empty and the 4th has the combination of the 3rd and 4th channel. (Please check both source and target files and you will understand - they do contain only DTMF tones). It actually reports:
    INFO: Unhandled message in step: 2 Line: 10 message: <[flac @ 000002414c2c5cc0] Channel layout not supported by Flac, output stream will have incorrect channel layout.>
  4. Finally, there is no documentation for the setVolume & setQuality functions. What is the range of their parameters? The setVolume complains and reports the following:
    Feb 19, 2019 4:28:40 PM ws.schild.jave.ConversionOutputAnalyzer analyzeNewLine INFO: Unhandled message in step: 2 Line: 7 message: <-vol has been deprecated. Use the volume audio filter instead.> Feb 19, 2019 4:28:40 PM ws.schild.jave.ConversionOutputAnalyzer analyzeNewLine INFO: Unhandled message in step: 2 Line: 8 message: <-vol is forwarded to lavfi similarly to -af volume=3.906250.>
    I attach also a screenshot of the input and the wrong output waveforms.

waveforms

4chan.zip

Does it support the format speex?

Hi, I meet a problem in my project that I should convert .speex to .wav or .mp3.
I think if jave2 can help me do this.
Thank you :)

How to upgrade the library to the Latest FFMPEG

I want to contribute in this library , i am experienced in Java though i don't know how internally works . I mean for example , where did you found the ffmp3-amd64.exe for example ? In the original jave-1.0.2 can't i replace the internal ffmpeg.exe with a newer and make it work ?

Please respond this is very important for me , i am making a Media Player based on that -> https://github.com/goxr3plus/XR3Player

FXConverter application based on Jave2

HELLOOOO :)

I will start making a converter based on Jave2 fully , for UI i will use JavaFX and the repository is here https://github.com/goxr3plus/XR3Converter

I want to add you as a collaborator . Currently thinking to implement the UI etc.

Main functionality 👍

  1. Convert any audio to any audio
  2. Convert any video to any video
  3. Extract audio from any video

What you think ? You like the idea :) ? I don't know how to make the ui in terms of many settings for converting any audio to any audio the user must be able to modify any parameters :)

Let me know your opinion on how to design it . Believe me it will be one of the best out there once we start it :)

convert mkv to mp4 fail

    <dependency>
        <groupId>ws.schild</groupId>
        <artifactId>jave-core</artifactId>
        <version>2.4.1</version>
    </dependency>
    <dependency>
        <groupId>ws.schild</groupId>
        <artifactId>jave-native-win64</artifactId>
        <version>2.4.1</version>
    </dependency>

13:48:11.472 [main] DEBUG ws.schild.jave.FFMPEGExecutor - Executable path: C:\Users\ding\AppData\Local\Temp\jave\ffmpeg-amd64-2.4.1.exe
13:48:11.472 [main] DEBUG ws.schild.jave.FFMPEGExecutor - ffmpeg executable found: C:\Users\ding\AppData\Local\Temp\jave\ffmpeg-amd64-2.4.1.exe
13:48:11.472 [main] DEBUG ws.schild.jave.FFMPEGExecutor - About to execute C:\Users\ding\AppData\Local\Temp\jave\ffmpeg-amd64-2.4.1.exe -i K:\ceshi\1.mkv -vcodec copy -acodec copy -y K:\ceshi\test.mp4 -hide_banner
13:48:14.059 [main] DEBUG ws.schild.jave.FFMPEGExecutor - About to execute C:\Users\ding\AppData\Local\Temp\jave\ffmpeg-amd64-2.4.1.exe -i K:\ceshi\1.mkv -hide_banner
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Input #0, matroska,webm, from 'K:\ceshi\1.mkv':
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Metadata:
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: encoder : libebml v1.3.4 + libmatroska v1.4.5
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: creation_time : 2018-06-19T12:16:12.000000Z
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Duration: 02:19:55.70, start: 0.000000, bitrate: 1816 kb/s
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Metadata:
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: BPS : 1686071
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: BPS-eng : 1686071
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: DURATION : 02:19:55.637000000
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: DURATION-eng : 02:19:55.637000000
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_FRAMES: 201294
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_FRAMES-eng: 201294
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_BYTES : 1769455275
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_BYTES-eng: 1769455275
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_APP: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_APP-eng: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_DATE_UTC: 2018-06-19 12:16:12
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_DATE_UTC-eng: 2018-06-19 12:16:12
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: Metadata:
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: BPS : 127989
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: BPS-eng : 127989
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: DURATION : 02:19:55.691000000
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: DURATION-eng : 02:19:55.691000000
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_FRAMES: 393548
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_FRAMES-eng: 393548
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_BYTES : 134319826
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: NUMBER_OF_BYTES-eng: 134319826
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_APP: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_APP-eng: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:14.122 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_DATE_UTC: 2018-06-19 12:16:12
13:48:14.137 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_WRITING_DATE_UTC-eng: 2018-06-19 12:16:12
13:48:14.137 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:14.137 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:14.137 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: At least one output file must be specified
13:48:14.137 [main] DEBUG ws.schild.jave.MultimediaObject - Output line: null
13:48:14.570 [main] DEBUG ws.schild.jave.Encoder - Input Line (1): Input #0, matroska,webm, from 'K:\ceshi\1.mkv':
13:48:14.989 [main] DEBUG ws.schild.jave.Encoder - Input Line (2): Metadata:
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (3): encoder : libebml v1.3.4 + libmatroska v1.4.5
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (4): creation_time : 2018-06-19T12:16:12.000000Z
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (5): Duration: 02:19:55.70, start: 0.000000, bitrate: 1816 kb/s
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (6): Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (7): Metadata:
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (8): BPS : 1686071
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (9): BPS-eng : 1686071
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (10): DURATION : 02:19:55.637000000
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (11): DURATION-eng : 02:19:55.637000000
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (12): NUMBER_OF_FRAMES: 201294
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (13): NUMBER_OF_FRAMES-eng: 201294
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (14): NUMBER_OF_BYTES : 1769455275
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (15): NUMBER_OF_BYTES-eng: 1769455275
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (16): _STATISTICS_WRITING_APP: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (17): _STATISTICS_WRITING_APP-eng: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (18): _STATISTICS_WRITING_DATE_UTC: 2018-06-19 12:16:12
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (19): _STATISTICS_WRITING_DATE_UTC-eng: 2018-06-19 12:16:12
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (20): _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (21): _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (22): Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (23): Metadata:
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (24): BPS : 127989
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (25): BPS-eng : 127989
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (26): DURATION : 02:19:55.691000000
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (27): DURATION-eng : 02:19:55.691000000
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (28): NUMBER_OF_FRAMES: 393548
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (29): NUMBER_OF_FRAMES-eng: 393548
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (30): NUMBER_OF_BYTES : 134319826
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (31): NUMBER_OF_BYTES-eng: 134319826
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (32): _STATISTICS_WRITING_APP: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (33): _STATISTICS_WRITING_APP-eng: mkvmerge v10.0.0 ('To Drown In You') 32bit
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (34): _STATISTICS_WRITING_DATE_UTC: 2018-06-19 12:16:12
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (35): _STATISTICS_WRITING_DATE_UTC-eng: 2018-06-19 12:16:12
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (36): _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
13:48:15.512 [main] DEBUG ws.schild.jave.Encoder - Input Line (37): _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Disconnected from the target VM, address: '127.0.0.1:59224', transport: 'socket'
13:48:15.528 [main] DEBUG ws.schild.jave.Encoder - Input Line (38): Output #0, mp4, to 'K:\ceshi\test.mp4':
ws.schild.jave.EncoderException: Output #0, mp4, to 'K:\ceshi\test.mp4':
at ws.schild.jave.Encoder.encode(Encoder.java:601)

Licensing issue

The original JAVE is distributed under GPLv3 (see here).

The ws.schild:jave-core module (which is an evolution of JAVE) lists APLv2 in its pom.xml.

The whole project, on the other hand, states that

JAVE2 is Free Software and it is licensed under GPL 2

Is anything of the above legal?

I believe GPLv3 code can be re-licensed under neither GPLv2 nor APLv2, unless you're the author of the original code.

Publish new release 2.4.1

Publish the new release 2.4.1 if you wish :) or add the jars to Maven .

People can always get the jars using something like , but for your github rep instead of mine :)

		<dependency>
			<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId>
			<artifactId>jave-all-deps</artifactId>
			<version>2.4.1</version>
			<exclusions>
				<exclusion>
					<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId>
					<artifactId>jave-native-win32</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId>
					<artifactId>jave-native-linux32</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId>
					<artifactId>jave-native-linux64</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId>
					<artifactId>jave-native-osx64</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

2 issues

Downloaded your new project just before 2 hours , i am amazed by how much you changed it , even used some of my code :) ( Happy for that ).

We have two issues :

screenshot_3

Should we replace common-logging with Standart Java Logging ? What is your opinion : ?

screenshot_4

Converting any audio with new Java2 fails

So i just forked the project to test it https://github.com/GOXR3PLUS-STUDIO/jave2 and published a release to use it with a random Maven project https://jitpack.io/#GOXR3PLUS-STUDIO/jave2/2.3 .

Then in the random Maven Project i added jave2 as a dependency , excluding the jars that are not needed ( i kept only windows64 , like :

<dependency>                                                                                               
<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId>                                                   
<artifactId>jave-all-deps</artifactId>                                                                 
<version>2.3</version>                                                                                 
<exclusions>                                                                                           
	<exclusion>                                                                                        
		<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId> <!-- Exclude Project-E from Project-B --> 
			<artifactId>jave-native-win32</artifactId>                                                    
	</exclusion>                                                                                       
	<exclusion>                                                                                        
		<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId> <!-- Exclude Project-E from Project-B --> 
			<artifactId>jave-native-linux32</artifactId>                                                  
	</exclusion>                                                                                       
	<exclusion>                                                                                        
		<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId> <!-- Exclude Project-E from Project-B --> 
			<artifactId>jave-native-linux64</artifactId>                                                  
	</exclusion>                                                                                       
	<exclusion>                                                                                        
		<groupId>com.github.GOXR3PLUS-STUDIO.jave2</groupId> <!-- Exclude Project-E from Project-B --> 
			<artifactId>jave-native-osx64</artifactId>                                                    
	</exclusion>                                                                                       
</exclusions>                                                                                          
</dependency>                                                                                              

So , the below error appears no matter which extension i try ...

screenshot_5

New DefaultFFMPEGLocator solving issue #7

This is a new DefaultFFMPEGLocator which solves the problem of new version could not work due to previous .exe FFMPEG . Give it a check i am using it :)

/*
 * JAVE - A Java Audio/Video Encoder (based on FFMPEG) Copyright (C) 2008-2009 Carlo Pelliccia (www.sauronsoftware.it) This program is free software:
 * you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package it.sauronsoftware.jave;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.LocalDate;
import java.time.ZoneId;

/**
 * The default ffmpeg executable locator, which exports on disk the ffmpeg executable bundled with the library distributions. It should work both for
 * windows and many linux distributions. If it doesn't, try compiling your own ffmpeg executable and plug it in JAVE with a custom
 * {@link FFMPEGLocator}.
 *
 * @author Carlo Pelliccia
 */
public class DefaultFFMPEGLocator extends FFMPEGLocator {
	
	/**
	 * Trace the version of the bundled ffmpeg executable. It's a counter: every time the bundled ffmpeg change it is incremented by 1.
	 */
	private static final int MY_EXE_VERSION = 2;
	
	/**
	 * Keep a LocalDate of current Jave2 Version
	 */
	private static final LocalDate local_date = LocalDate.of(2018, 06, 21);
	
	/**
	 * The ffmpeg executable file path.
	 */
	private final String path;
	
	/**
	 * It builds the default FFMPEGLocator, exporting the ffmpeg executable on a temp file.
	 */
	public DefaultFFMPEGLocator() {
		String os = System.getProperty("os.name").toLowerCase();
		boolean isWindows = os.contains("windows");
		boolean isMac = os.contains("mac");
		
		// Dir Folder
		File dirFolder = new File(System.getProperty("java.io.tmpdir"), "jave-" + MY_EXE_VERSION);
		if (!dirFolder.exists())
			dirFolder.mkdirs();
		
		// -----------------ffmpeg executable export on disk.-----------------------------
		String suffix = isWindows ? ".exe" : "-osx";
		String arch = System.getProperty("os.arch");
		
		//File
		File ffmpegFile = new File(dirFolder, "ffmpeg-" + arch + suffix);
		System.out.println(ffmpegFile.getAbsolutePath());
		
		//Check the version of existing .exe file
		if (ffmpegFile.exists())
			try {
				//Retrieve the File Creation Date
				BasicFileAttributes attributes = Files.readAttributes(ffmpegFile.toPath(), BasicFileAttributes.class);
				
				//Convert to Java8 LocalDate
				LocalDate date_file_created = attributes.creationTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
				
				//Check if the file was created from a previous version of Jave2
				if (date_file_created.isBefore(local_date)) {
					ffmpegFile.delete();
					System.out.println("ffmpegFile created before the latest update of Library");
				} else
					System.out.println("It's okay the date ");
				
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		
		//If the file doesn't already exists
		if (!ffmpegFile.exists())
			copyFile("ffmpeg-" + arch + suffix, ffmpegFile);
		
		// Need a chmod?
		if (!isWindows) {
			try {
				Runtime.getRuntime().exec(new String[]{ "/bin/chmod" , "755" , ffmpegFile.getAbsolutePath() });
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		// Everything seems okay
		path = ffmpegFile.getAbsolutePath();
		System.out.println(path);
	}
	
	@Override
	protected String getFFMPEGExecutablePath() {
		return path;
	}
	
	/**
	 * Copies a file bundled in the package to the supplied destination.
	 *
	 * @param path
	 *            The name of the bundled file.
	 * @param dest
	 *            The destination.
	 * @throws RuntimeException
	 *             If an unexpected error occurs.
	 */
	private void copyFile(String path , File dest) {
		copy(getClass().getResourceAsStream("native/" + path), dest.getAbsolutePath());
	}
	
	/**
	 * Copy a file from source to destination.
	 *
	 * @param source
	 *            The name of the bundled file.
	 * @param destination
	 *            the destination
	 * @return True if succeeded , False if not
	 */
	private boolean copy(InputStream source , String destination) {
		boolean success = true;
		
		try {
			Files.copy(source, Paths.get(destination), StandardCopyOption.REPLACE_EXISTING);
		} catch (IOException ex) {
			//LOG.warn("Cannot write file " + destination, ex)
			ex.printStackTrace();
			success = false;
		}
		
		return success;
	}
}

Can not use Jave2 with Java 11

I am trying to use Jave2 with Java 11 because i passed XR3Player in Java 11 =>

But i am getting this error :

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\akentros\.m2\repository\ws\schild\jave-native-win64\2.4.6\jave-native-win64-2.4.6.jar
Caused by: java.lang.IllegalArgumentException: jave.native.win64: Invalid module name: 'native' is not a Java identifier

Difference between other ffmpeg wrapper, especially javacv?

I've been looking for ffmpeg wrapper for Java and found javacv seemingly useful. That was few weeks ago. However recently I found this java2e project (via XR3Player and java-stream-player) and found that this is also actively developed, and nice-looking library. So I want to ask you what is, if you ever know about javacv, difference between those two (and possibly any other ffmpeg Java wrapper)?

Add support for internet URL for source file

Is it possible to add a support for getting source file from an internet URL? Currently MultimediaObject only accepts local File.
As far as I know it it possible to use an URL in "-i" parameter for ffmpeg command.

We should solve the issue of %TEMP%\jave-2\ .exe already existing when project is running

So after many tests i can see that once the FFMpeg.exe is copied on the destination either the user of the library has to manually delete it or it will be there forever and any time on a future release of the library we will have the same .exe there . So what i recommend .

Currently writing a new DefaultFFMPEGLocator which will have a Date , let's say (21/06/2018) . If the creation date of the .exe is older than the given date , then must be deleted and a new one to be created .

That way everytime we release a new update for Jave2 , let's say the next one 23/06/2018 , it will delete the older .exe files or whatever and replace with the new native files :)

I am interested on your opinion :)

Ability to cancel the encoder or stop it.

It's very important to add the ability to cancel the encoder , i am facing hard problems with big files 2 hours and more converting them to something other but in the middle of the long progress i decide to cancel the encoding but ... i can't .

Can we add the ability to cancel it ?

For example , let's say we use the below to convert a wav to mp3 , but the wav is 1 GB and we want to cancel it .... :

   try {                                                            
	File source = new File("file path");		                 
	File target = new File("file path);                          
                                                                 
       //Audio Attributes                                               
	AudioAttributes audio = new AudioAttributes();               
	audio.setCodec("libmp3lame");                                
	audio.setBitRate(128000);                                    
	audio.setChannels(2);                                        
	audio.setSamplingRate(44100);                                
	                                                             
	//Encoding attributes                                        
	EncodingAttributes attrs = new EncodingAttributes();         
	attrs.setFormat("mp3");                                      
	attrs.setAudioAttributes(audio);                             
	                                                             
	//Encode                                                     
	Encoder encoder = new Encoder();                             
	encoder.encode(new MultimediaObject(source), target, attrs); 
                                                                 
   } catch (Exception ex) {                                         
	ex.printStackTrace();                                        
	succeeded = false;                                           
   }    

Can't use libraries with JDK 7

Running with >= 2.4.0

It said:

java.lang.UnsupportedClassVersionError: ws/schild/jave/Encoder : Unsupported major.minor version 52.0

Any idea or solution?

Maven

Push the latest version (2.4.6) to maven repository?

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

[main] ERROR ws.schild.jave.FFMPEGExecutor - Could not find ffmpeg executable for native/ffmpeg-amd64.exe is the correct platform jar included?

I user maven import jar like this in win10 and jdk8:

<dependency>
            <groupId>ws.schild</groupId>
            <artifactId>jave-all-deps</artifactId>
            <version>2.4.4</version>
 </dependency>

and use code like this

public class MediaTimeCount {
    public static void main(String[] args) throws EncoderException {
        System.out.println("getInfo");
        File file = new File("I:\\xxx.avi");
        MultimediaObject instance = new MultimediaObject(file);
        MultimediaInfo result = instance.getInfo();
        long duration = result.getDuration();
        System.out.println(duration);
    }
}

but console print error message like this:

21:41:24.110 [main] DEBUG ws.schild.jave.FFMPEGExecutor - Executable path: C:\Users\Victory\AppData\Local\Temp\jave\ffmpeg-amd64-2.4.4.exe
Exception in thread "main" java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:203)
	at java.nio.file.Files.copy(Files.java:2984)
	at ws.schild.jave.DefaultFFMPEGLocator.copy(DefaultFFMPEGLocator.java:144)
	at ws.schild.jave.DefaultFFMPEGLocator.copyFile(DefaultFFMPEGLocator.java:123)
	at ws.schild.jave.DefaultFFMPEGLocator.<init>(DefaultFFMPEGLocator.java:84)
	at ws.schild.jave.MultimediaObject.<init>(MultimediaObject.java:60)
	at club.hicode.media.MediaTimeCount.main(MediaTimeCount.java:20)
21:41:24.124 [main] ERROR ws.schild.jave.FFMPEGExecutor - Could not find ffmpeg executable for native/ffmpeg-amd64.exe is the correct platform jar included?

should i download ffmpeg-amd64.exe and copy it to C:\Users\Victory\AppData\Local\Temp\jave ??

Find a way to cleverly define pom version only in one place and access also from Java Code.

So i have been searching a long time for this , how to define one time in pom.xml the application version and then access it from Java .

So we can use :

<dependency>                            
	<groupId>org.apache.maven</groupId> 
	<artifactId>maven-model</artifactId>
	<version>3.5.4</version>            
</dependency>                           

and read the xml from inside the java because every time we have to define it here .

  <properties>
        <revision>2.4.4-SNAPSHOT</revision>
        <!-- Don't forget to change it also in DefaultFFMPEGLocator.java  -->
    </properties>

Like you know going in every pom.xml and changing the version and then in the Java code ... hm that's boring ...

So from Java code we can access the pom.xml like this :

try {                                                         
	MavenXpp3Reader reader = new MavenXpp3Reader();           
	Model model = reader.read(new FileReader("pom.xml"));     
	System.err.println("----------------------------------"); 
	System.err.println(model.getId());                        
	System.err.println(model.getGroupId());                   
	System.err.println(model.getArtifactId());                
	System.err.println(model.getVersion());                   
	System.err.println("----------------------------------"); 
                                                              
} catch (Exception ex) {                                      
	ex.printStackTrace();                                     
}                                                             

But that's only from inside the IDE so i will find a way to access it also easy from outside the IDE . The thing is to make our releases easier ..... not every where changing the .pom every time.

Like define version=2.5.5 , one time in one pom and boom , not changing everywhere .

What you think you like the idea?

Add support for video and audio conversion quality

I’d like to know if is possible convert .wav files to .ogg using libvorbis specifying the qscale parameter in Jave2.
I’m able to run the following command with ffmpeg (based on post https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide).

./ffmpeg-amd64.exe -i audio.wav -qscale:a 1 audio.ogg

So I’d like to know how to run the same with Jave2, I’ve seen the encode method in Encoder class and I didn’t get a way to do this.

My objective is convert any audio file to some other format lighter than its original.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.