couldn't render an audio after extracting the audio from the video - java

hi … I am trying to use FFmpegFrameRecorder to extract an audio from a video using this code
FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(mp4Path);
frameGrabber.start();
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(new
File("C:/Users/ASUS/Desktop/audio.aac"),audioChannels);
recorder.setAudioMetadata(frameGrabber.getAudioMetadata());
recorder.setFrameRate(frameGrabber.getFrameRate());
recorder.setTimestamp(frameGrabber.getTimestamp());
recorder.start(frameGrabber.getFormatContext());
Frame f=null;
//get audio sample and record it
while ((f = frameGrabber.grabSamples()) != null) {
recorder.record(f);
}
frameGrabber.stop();
recorder.stop();
recorder.close();
LOGGER.info("C:/Users/ASUS/Desktop/audio.aac");
but when I run it it gives me in terminal:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/ASUS/Desktop/Lou.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:00:39.10, start: 0.000000, bitrate: 116 kb/s
Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709,
progressive), 256x144 [SAR 1:1 DAR 16:9], 63 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 46 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[aac # 000000001afd7080] noise_facs_q 31 is invalid
[h264 # 000000001ad8bc40] mmco: unref short failure
[h264 # 000000001ad8bc40] mmco: unref short failure
[h264 # 000000001ad8bc40] mmco: unref short failure
[h264 # 000000001ad8bc40] mmco: unref short failure
[h264 # 000000001ad8bc40] mmco: unref short failure
and so on ...
Output #0, adts, to 'C:\Users\ASUS\Desktop\aud.aac':
Metadata:
encoder : Lavf59.16.100
Stream #0:0: Audio: aac (HE-AAC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 46 kb/s
and when I try to run the audio it is not running
what's the wrong thing I did?

Related

double precision no truncation when typecast to int

The following:
double x = .43;
BigDecimal bd = new BigDecimal(z);
System.out.println(bd);
outputs:
.4299999.....
why does
double u = z*100;
bd = new BigDecimal(u);
System.out.println(u);
output:
43?
more generally I'm trying to find a case where the double representation causes a truncation problem. Consider the following:
double d;
int j;
BigDecimal bd;
for(int i = 0; i<10000;i++){
d= (double)(i/100.);
j = (int)(d*100.);
bd = new BigDecimal(j);
System.out.println(bd);
}
In not a single case is truncating occurring
In not a single case is truncating occurring
That is incorrect. Truncation occurs many times, you just didn't look close enough.
E.g. for i = 29:
int i = 29;
double d= i / 100.;
int j = (int)(d * 100.);
BigDecimal bd = new BigDecimal(j);
System.out.println(bd);
Output
28
OOPS!!!
Though I don't know what the point of converting j to bd is, since new BigDecimal(int) is always exact.
If you want to see all the truncation errors, try this:
for (int i = 0; i < 10000; i++){
double d = i / 100.;
int j = (int)(d * 100.);
if (i != j)
System.out.println(i + ": " + j);
}
Output
29: 28
57: 56
58: 57
113: 112
114: 113
115: 114
116: 115
201: 200
203: 202
205: 204
207: 206
226: 225
228: 227
230: 229
232: 231
251: 250
253: 252
255: 254
402: 401
406: 405
410: 409
414: 413
427: 426
431: 430
435: 434
439: 438
452: 451
456: 455
460: 459
464: 463
477: 476
481: 480
485: 484
489: 488
502: 501
506: 505
510: 509
803: 802
804: 803
812: 811
820: 819
828: 827
829: 828
837: 836
845: 844
853: 852
854: 853
862: 861
870: 869
878: 877
879: 878
887: 886
895: 894
903: 902
904: 903
912: 911
920: 919
928: 927
929: 928
937: 936
945: 944
953: 952
954: 953
962: 961
970: 969
978: 977
979: 978
987: 986
995: 994
1003: 1002
1004: 1003
1012: 1011
1020: 1019
1606: 1605
1608: 1607
1615: 1614
1624: 1623
1631: 1630
1633: 1632
1640: 1639
1649: 1648
1656: 1655
1658: 1657
1665: 1664
1674: 1673
1681: 1680
1683: 1682
1690: 1689
1699: 1698
1706: 1705
1708: 1707
1715: 1714
1724: 1723
1731: 1730
1733: 1732
1740: 1739
1749: 1748
1756: 1755
1758: 1757
1765: 1764
1774: 1773
1781: 1780
1783: 1782
1790: 1789
1799: 1798
1806: 1805
1808: 1807
1815: 1814
1824: 1823
1831: 1830
1833: 1832
1840: 1839
1849: 1848
1856: 1855
1858: 1857
1865: 1864
1874: 1873
1881: 1880
1883: 1882
1890: 1889
1899: 1898
1906: 1905
1908: 1907
1915: 1914
1924: 1923
1931: 1930
1933: 1932
1940: 1939
1949: 1948
1956: 1955
1958: 1957
1965: 1964
1974: 1973
1981: 1980
1983: 1982
1990: 1989
1999: 1998
2006: 2005
2008: 2007
2015: 2014
2024: 2023
2031: 2030
2033: 2032
2040: 2039
3205: 3204
3212: 3211
3216: 3215
3223: 3222
3230: 3229
3237: 3236
3241: 3240
3248: 3247
3255: 3254
3262: 3261
3266: 3265
3273: 3272
3280: 3279
3287: 3286
3291: 3290
3298: 3297
3305: 3304
3312: 3311
3316: 3315
3323: 3322
3330: 3329
3337: 3336
3341: 3340
3348: 3347
3355: 3354
3362: 3361
3366: 3365
3373: 3372
3380: 3379
3387: 3386
3391: 3390
3398: 3397
3405: 3404
3412: 3411
3416: 3415
3423: 3422
3430: 3429
3437: 3436
3441: 3440
3448: 3447
3455: 3454
3462: 3461
3466: 3465
3473: 3472
3480: 3479
3487: 3486
3491: 3490
3498: 3497
3505: 3504
3512: 3511
3516: 3515
3523: 3522
3530: 3529
3537: 3536
3541: 3540
3548: 3547
3555: 3554
3562: 3561
3566: 3565
3573: 3572
3580: 3579
3587: 3586
3591: 3590
3598: 3597
3605: 3604
3612: 3611
3616: 3615
3623: 3622
3630: 3629
3637: 3636
3641: 3640
3648: 3647
3655: 3654
3662: 3661
3666: 3665
3673: 3672
3680: 3679
3687: 3686
3691: 3690
3698: 3697
3705: 3704
3712: 3711
3716: 3715
3723: 3722
3730: 3729
3737: 3736
3741: 3740
3748: 3747
3755: 3754
3762: 3761
3766: 3765
3773: 3772
3780: 3779
3787: 3786
3791: 3790
3798: 3797
3805: 3804
3812: 3811
3816: 3815
3823: 3822
3830: 3829
3837: 3836
3841: 3840
3848: 3847
3855: 3854
3862: 3861
3866: 3865
3873: 3872
3880: 3879
3887: 3886
3891: 3890
3898: 3897
3905: 3904
3912: 3911
3916: 3915
3923: 3922
3930: 3929
3937: 3936
3941: 3940
3948: 3947
3955: 3954
3962: 3961
3966: 3965
3973: 3972
3980: 3979
3987: 3986
3991: 3990
3998: 3997
4005: 4004
4012: 4011
4016: 4015
4023: 4022
4030: 4029
4037: 4036
4041: 4040
4048: 4047
4055: 4054
4062: 4061
4066: 4065
4073: 4072
4080: 4079
4087: 4086
4091: 4090
6407: 6406
6410: 6409
6421: 6420
6424: 6423
6432: 6431
6435: 6434
6446: 6445
6449: 6448
6457: 6456
6460: 6459
6471: 6470
6474: 6473
6482: 6481
6485: 6484
6496: 6495
6499: 6498
6507: 6506
6510: 6509
6521: 6520
6524: 6523
6532: 6531
6535: 6534
6546: 6545
6549: 6548
6557: 6556
6560: 6559
6571: 6570
6574: 6573
6582: 6581
6585: 6584
6596: 6595
6599: 6598
6607: 6606
6610: 6609
6621: 6620
6624: 6623
6632: 6631
6635: 6634
6646: 6645
6649: 6648
6657: 6656
6660: 6659
6671: 6670
6674: 6673
6682: 6681
6685: 6684
6696: 6695
6699: 6698
6707: 6706
6710: 6709
6721: 6720
6724: 6723
6732: 6731
6735: 6734
6746: 6745
6749: 6748
6757: 6756
6760: 6759
6771: 6770
6774: 6773
6782: 6781
6785: 6784
6796: 6795
6799: 6798
6807: 6806
6810: 6809
6821: 6820
6824: 6823
6832: 6831
6835: 6834
6846: 6845
6849: 6848
6857: 6856
6860: 6859
6871: 6870
6874: 6873
6882: 6881
6885: 6884
6896: 6895
6899: 6898
6907: 6906
6910: 6909
6921: 6920
6924: 6923
6932: 6931
6935: 6934
6946: 6945
6949: 6948
6957: 6956
6960: 6959
6971: 6970
6974: 6973
6982: 6981
6985: 6984
6996: 6995
6999: 6998
7007: 7006
7010: 7009
7021: 7020
7024: 7023
7032: 7031
7035: 7034
7046: 7045
7049: 7048
7057: 7056
7060: 7059
7071: 7070
7074: 7073
7082: 7081
7085: 7084
7096: 7095
7099: 7098
7107: 7106
7110: 7109
7121: 7120
7124: 7123
7132: 7131
7135: 7134
7146: 7145
7149: 7148
7157: 7156
7160: 7159
7171: 7170
7174: 7173
7182: 7181
7185: 7184
7196: 7195
7199: 7198
7207: 7206
7210: 7209
7221: 7220
7224: 7223
7232: 7231
7235: 7234
7246: 7245
7249: 7248
7257: 7256
7260: 7259
7271: 7270
7274: 7273
7282: 7281
7285: 7284
7296: 7295
7299: 7298
7307: 7306
7310: 7309
7321: 7320
7324: 7323
7332: 7331
7335: 7334
7346: 7345
7349: 7348
7357: 7356
7360: 7359
7371: 7370
7374: 7373
7382: 7381
7385: 7384
7396: 7395
7399: 7398
7407: 7406
7410: 7409
7421: 7420
7424: 7423
7432: 7431
7435: 7434
7446: 7445
7449: 7448
7457: 7456
7460: 7459
7471: 7470
7474: 7473
7482: 7481
7485: 7484
7496: 7495
7499: 7498
7507: 7506
7510: 7509
7521: 7520
7524: 7523
7532: 7531
7535: 7534
7546: 7545
7549: 7548
7557: 7556
7560: 7559
7571: 7570
7574: 7573
7582: 7581
7585: 7584
7596: 7595
7599: 7598
7607: 7606
7610: 7609
7621: 7620
7624: 7623
7632: 7631
7635: 7634
7646: 7645
7649: 7648
7657: 7656
7660: 7659
7671: 7670
7674: 7673
7682: 7681
7685: 7684
7696: 7695
7699: 7698
7707: 7706
7710: 7709
7721: 7720
7724: 7723
7732: 7731
7735: 7734
7746: 7745
7749: 7748
7757: 7756
7760: 7759
7771: 7770
7774: 7773
7782: 7781
7785: 7784
7796: 7795
7799: 7798
7807: 7806
7810: 7809
7821: 7820
7824: 7823
7832: 7831
7835: 7834
7846: 7845
7849: 7848
7857: 7856
7860: 7859
7871: 7870
7874: 7873
7882: 7881
7885: 7884
7896: 7895
7899: 7898
7907: 7906
7910: 7909
7921: 7920
7924: 7923
7932: 7931
7935: 7934
7946: 7945
7949: 7948
7957: 7956
7960: 7959
7971: 7970
7974: 7973
7982: 7981
7985: 7984
7996: 7995
7999: 7998
8007: 8006
8010: 8009
8021: 8020
8024: 8023
8032: 8031
8035: 8034
8046: 8045
8049: 8048
8057: 8056
8060: 8059
8071: 8070
8074: 8073
8082: 8081
8085: 8084
8096: 8095
8099: 8098
8107: 8106
8110: 8109
8121: 8120
8124: 8123
8132: 8131
8135: 8134
8146: 8145
8149: 8148
8157: 8156
8160: 8159
8171: 8170
8174: 8173
8182: 8181
8185: 8184
That is 573 times, i.e. 5.73% of the time.

ffmpeg not converting entire video in java application

My code converts a video into different formats (160p to 2160p). The codec of video with rotate tag 90 needs to be changed. below id the code for the same which works fine for all videos till date.
log_wfm.debug("Changing the codec video for file [" + orgFileName + "] and name of source file ["
+ srcFileName + "]");
String codecFlipCommand = "ffmpeg -i " + orgFileName + " -c:v libx264 -preset ultrafast " + srcFileName;
log_wfm.info("Executing command to change the codec of video!");
fp = Runtime.getRuntime().exec(codecFlipCommand);
inputStream = new BufferedReader(new InputStreamReader(fp.getInputStream()));
outputStream = new BufferedReader(new InputStreamReader(fp.getErrorStream()));
StringBuffer output = new StringBuffer();
String line;
while ((line = inputStream.readLine()) != null) {
output.append(line).append('\n');
}
log_wfm.debug("stdInputForCodecChange: " + output);
output = new StringBuffer();
while ((line = outputStream.readLine()) != null) {
output.append(line).append('\n');
}
log_wfm.debug("stdErrorForCodecChange: " + output);
now have a file of size 1.5Gb. The video does not create the file with changed codec. The file till size 848.5 MB is created and then the program hangs (with no exception or error logs)
Please suggest some way to finish this codec change process.The ffmpeg command converts the video, but via java application, the process hangs Logs While converting via commandLine :
ffmpeg version N-83433-ge87a4a8 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20161221 (Red Hat 6.3.1-1)
configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
libavutil 55. 46.100 / 55. 46.100
libavcodec 57. 75.100 / 57. 75.100
libavformat 57. 66.101 / 57. 66.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 73.100 / 6. 73.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/urvashi/test/SachinSagaGameLaunchEvent.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-12-07T06:26:23.000000Z
com.android.version: 7.1.1
Duration: 00:14:16.02, start: 0.000000, bitrate: 14231 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 13971 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2017-12-07T06:26:23.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
creation_time : 2017-12-07T06:26:23.000000Z
handler_name : SoundHandle
[libx264 # 0x4601a20] using SAR=1/1
[libx264 # 0x4601a20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x4601a20] profile Constrained Baseline, level 4.0
[libx264 # 0x4601a20] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to '/home/urvashi/test/Manual_SachinSagaGameLaunchEvent.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 7.1.1
encoder : Lavf57.66.101
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1080x1920 [SAR 1:1 DAR 9:16], q=-1--1, 29.92 fps, 11488 tbn, 29.92 tbc (default)
Metadata:
handler_name : VideoHandle
creation_time : 2017-12-07T06:26:23.000000Z
encoder : Lavc57.75.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2017-12-07T06:26:23.000000Z
handler_name : SoundHandle
encoder : Lavc57.75.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help Past duration 0.600212 too large 48193kB time=00:00:27.26 bitrate=14479.2kbits/s speed=2.07x
Past duration 0.998863 too large
frame=25611 fps= 55 q=-1.0 Lsize= 1721466kB time=00:14:16.04 bitrate=16473.7kbits/s dup=0 drop=17 speed=1.85x
video:1707295kB audio:13453kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.041757%
[libx264 # 0x4601a20] frame I:103 Avg QP:22.16 size:242916
[libx264 # 0x4601a20] frame P:25508 Avg QP:25.17 size: 67557
Thanks in Advance.

Final Rendered Video is Sped Up Compared to Animation Played in Processing

Recently I made an Audio Visualizer in Processing. From there I wanted to render the animation created in Processing into a mp4 file. I am on a windows computer, and am using ffmpeg to convert my TIF files produced in Processing into mp4.
When I do this I am able to render the images into an mp4 file, but when I playback this file the animation is sped up compared to the animation when I play it on Processing. Because of this the animation does not sync with the audio when I combine the mp4 file and audio on a video editing program.
When I set my frame rate to 25 and have the limit on the number of frames to be 250 and render it into a mp4 file it is 10 seconds long like it should be, but it contains more than 10 seconds of the animation when compared to the animation played directly in Processing.
I have no idea why this is so any help will be much appreciated.
My Processing code:
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer player;
PImage img;
FFT fft;
void setup() {
size(728, 546);
minim = new Minim(this);
// this loads mysong.wav from the data folder as a stream with a internal buffer of size 1024
player = minim.loadFile("new_years_good.mp3");
fft = new FFT(player.bufferSize(), player.sampleRate());
player.play();
img= loadImage("cat-in-shades-.jpg");
frameRate(25);
}
void draw() {
image(img, 0, 0);
//tint(0, 100, 150);
stroke(255);
strokeWeight(4);
float a = 0;
float angle = (2*PI) / 200;
fft.forward(player.mix);
for(int i=0; i < player.bufferSize() - 1; i++) {
//player.mix.get(i) is a value between [-1,1]
float x = 250 + cos(a) * (20 * player.mix.get(i) + 100);
float x2 = 540 + cos(a) * (20 * player.mix.get(i) + 100);
float y = 230 + sin(a) * (20 * player.mix.get(i) + 100);
float y2 = 240 + sin(a) * (20 * player.mix.get(i) + 100);
float xFinal = 250 + cos(a+angle) * (20 * player.mix.get(i+1) + 100);
float x2Final = 540 + cos(a+angle) * (20 * player.mix.get(i+1) + 100);
float yFinal = 230 + sin(a+angle) * (20 * player.mix.get(i+1) + 100);
float y2Final = 240 + sin(a+angle) * (20 * player.mix.get(i+1) + 100);
line(x,y,xFinal,yFinal);
line(x2,y2,x2Final,y2Final);
a += angle;
}
noStroke();
fill(255, 0, 0, 128);
for(int i = 0; i < 250; i++)
{
float b = fft.getBand(i);
float yAxis = random(-b, b) + 480;
float xAxis = i*3;
ellipse(xAxis, yAxis, b, b);
}
saveFrame("frame-####.tif");
if(frameCount>250)
{
noLoop();
stop();
}
}
void stop() {
player.close();
minim.stop();
super.stop();
}
What I input into the command line (as one line) on the cmd:
C:\Users\Robert\Documents\Processing\AudioVisulizer>ffmpeg -i C:\Users\Robert\Do
cuments\Processing\AudioVisulizer\frame-%04d.tif -r 25 -pix_fmt yuv420p smallVid
.mp4
What it outputted:
ffmpeg version N-77836-g62dfe1d Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --
enable-lzma --enable-decklink --enable-zlib
libavutil 55. 13.100 / 55. 13.100
libavcodec 57. 22.100 / 57. 22.100
libavformat 57. 21.101 / 57. 21.101
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 23.100 / 6. 23.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, image2, from 'C:\Users\Robert\Documents\Processing\AudioVisulizer\fram
e-%04d.tif':
Duration: 00:00:10.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: tiff, rgb24, 728x546, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 # 00000092cd5e3700] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 00000092cd5e3700] profile High, level 3.0
[libx264 # 00000092cd5e3700] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pski
p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_
adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2
5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.6
0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'smallVid.mp4':
Metadata:
encoder : Lavf57.21.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 728x54
6, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.22.100 libx264
Side data:
unknown side data type 10 (24 bytes)
Stream mapping:
Stream #0:0 -> #0:0 (tiff (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 52 fps=0.0 q=28.0 size= 77kB time=00:00:00.00 bitrate=N/A speed=
frame= 74 fps= 65 q=28.0 size= 127kB time=00:00:00.88 bitrate=1178.0kbits/
frame= 93 fps= 57 q=28.0 size= 164kB time=00:00:01.64 bitrate= 820.0kbits/
frame= 113 fps= 52 q=28.0 size= 201kB time=00:00:02.44 bitrate= 676.3kbits/
frame= 136 fps= 51 q=28.0 size= 245kB time=00:00:03.36 bitrate= 596.3kbits/
frame= 157 fps= 49 q=28.0 size= 282kB time=00:00:04.20 bitrate= 550.2kbits/
frame= 178 fps= 48 q=28.0 size= 324kB time=00:00:05.04 bitrate= 527.2kbits/
frame= 199 fps= 47 q=28.0 size= 362kB time=00:00:05.88 bitrate= 504.1kbits/
frame= 219 fps= 46 q=28.0 size= 403kB time=00:00:06.68 bitrate= 494.2kbits/
frame= 242 fps= 46 q=28.0 size= 452kB time=00:00:07.60 bitrate= 486.8kbits/
frame= 251 fps= 38 q=-1.0 Lsize= 623kB time=00:00:09.96 bitrate= 512.3kbits
/s speed=1.52x
video:619kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing o
verhead: 0.607807%
[libx264 # 00000092cd5e3700] frame I:2 Avg QP:21.74 size: 56596
[libx264 # 00000092cd5e3700] frame P:66 Avg QP:23.36 size: 2523
[libx264 # 00000092cd5e3700] frame B:183 Avg QP:31.50 size: 1932
[libx264 # 00000092cd5e3700] consecutive B-frames: 0.8% 4.0% 6.0% 89.2%
[libx264 # 00000092cd5e3700] mb I I16..4: 10.9% 72.6% 16.5%
[libx264 # 00000092cd5e3700] mb P I16..4: 0.0% 0.0% 0.2% P16..4: 4.4% 2.3
% 3.3% 0.0% 0.0% skip:89.7%
[libx264 # 00000092cd5e3700] mb B I16..4: 0.0% 0.0% 0.5% B16..8: 3.2% 2.0
% 2.3% direct: 1.3% skip:90.7% L0:50.9% L1:42.2% BI: 7.0%
[libx264 # 00000092cd5e3700] 8x8 transform intra:50.2% inter:10.1%
[libx264 # 00000092cd5e3700] coded y,uvDC,uvAC intra: 83.4% 32.6% 14.2% inter: 3
.5% 0.2% 0.0%
[libx264 # 00000092cd5e3700] i16 v,h,dc,p: 22% 8% 8% 62%
[libx264 # 00000092cd5e3700] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 12% 19% 6% 9%
9% 9% 9% 9%
[libx264 # 00000092cd5e3700] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 14% 22% 6% 9%
8% 8% 5% 6%
[libx264 # 00000092cd5e3700] i8c dc,h,v,p: 74% 12% 12% 2%
[libx264 # 00000092cd5e3700] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 00000092cd5e3700] ref P L0: 41.8% 3.9% 24.3% 30.0%
[libx264 # 00000092cd5e3700] ref B L0: 64.5% 25.0% 10.5%
[libx264 # 00000092cd5e3700] ref B L1: 82.2% 17.8%
[libx264 # 00000092cd5e3700] kb/s:504.56
The fact that you managed to get the sound and the video synchronized in the running program probably means you run it on a free CPU
If music and video are two separate threads (as I understand it) its not guaranteed that the CPU will run them always so.
So if you want to have your final video .mp4 synchronized you have to work outside the program: take them together to a video editing software and synchronize them.
But if you want them synchronized in the program you are fine.

'Not in gzip format" error when decompressing gzip inputstream in java

My code is attempting to decompress an input stream read from a gzipped file.
Here is the code snippet:
InputStream is = new GZIPInputStream(new ByteArrayInputStream(fcontents.getBytes()));
The file itself is fine:
$cat storefront3.gz | gunzip
180028796
80026920
180028796
180026921
8002790180
800001
1800002
1800007
800008
800009
The data read in prior to the top code snippet via FileInputStream sure looks like gzip stuff (note the original file was storefront3.tsv):
��[�Rstorefront3.tsvu���0k{)�?�/FBģ��Y'��Q�a���s~���}6���d�{2+���O���D�m~�O��
But get the following:
Caused by: java.io.IOException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:141)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:56)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:65)
Here is a hex dump of the .gz file
23:40:44/storefronts:72 $od -cx storefront3.gz
0000000 037 213 \b \b 201 [ 347 R \0 003 s t o r e f
8b1f 0808 5b81 52e7 0300 7473 726f 6665
0000020 r o n t 3 . t s v \0 u 212 273 025 200 0
6f72 746e 2e33 7374 0076 8a75 15bb 3080
0000040 \f 003 k { 032 ) 200 ? 373 / F B ģ ** 302 131
030c 7b6b 291a 3f80 2ffb 4246 a3c4 cdc2
0000060 Y ' 261 200 Q 331 a 276 276 350 001 s ~ 222 262 175
2759 80b1 d951 be61 e8be 7301 927e dcb2
0000100 } 6 226 231 367 d 200 { 2 + 211 337 342 020 O 022
367d 9996 64f7 7b80 2b32 df89 10e2 f14f
0000120 022 343 035 246 D 211 m ~ 003 326 O 235 030 236 \0 \0
e312 a61d 8944 7e6d d603 9d4f 9e18 0000
0000140 \0
0000
UPDATE
I also tried to use FileInputStream. Following gives same error
GZIPInputStream strm = new GZIPInputStream(new FileInputStream(tmpFileName));
Since fcontents contains your gzipped data it should be a byte[] and not a String?
I recommend using IOUtils for reading the file into a byte array as reading it into a string will most likely corrupt your data.

Lucene Index Size

I have data like
1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 28 30 36 37 39 40 41 46 48 49 51 52 53 54 55 56 58 60 66 67 68 71 72 74 77 78 85 89 90 91 108 109 110 116 117 118 120 121 123 137 138 145 146 147 148 154 157 159 162 165 166 168 175 179 181 198 201 203 212 215 216 223 231 233 254 266 270 274 323 327 329 331 347 352 355 360 363 370 411 415 434 438 442 444 445 462 470 471 477 486 495 499 503 524 525 536 542 595 603 608 636 644 646 647 670 692 694 698 762 763 798 809 822 970 981 987 992 1040 1057 1066 1079 1089 1111 1233 1244 1302 1315 1327 1333 1336 1387 1411 1412 1432 1458 1486 1498 1509 1572 1573 1574 1607 1625 1784 1808 1824 1909 1933 1938 1940 2011 2077 2081 2093 2286 2289 2395 2427 2467 2911 2944 2962 2975 3121 3170 3172 3197 3236 3267 3334 3699 3731 3905 3945 3982 3999 4008 4161 4234 4235 4296 4374 4457 4494 4526 4717 4720 4723 4820 4875 5352 5423 5472 5728 5799 5813 5821 6032 6230 6244 6278 6859 6868 7186 7280 7401 8734 8832 8885 8886 8925 9363 9510 9517 9592 9707 9802 10002 11097 11192 11715 11716 11836 11945 11996 12025 12482 12703 12706 12887 13122 13372 13482 13577 14150 14161 14169 14461 14626 16057 16268 16415 17183 17398 17440 17464 18097 18690 18731 18834 20576 20603 21558 21839 22202 26201 26497 26654 26658 26776 28088 28531 28551 28775 29122 29407.
This is one line of data many are there like that, stored in "training.txt". I am index it using following lucene indexing code
public class training
{
public static void main(String args[]) throws IOException, ParseException
{
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
// IndexWriter w = new IndexWriter(FSDirectory.open(new File("../search/index")), analyzer, true, new IndexWriter.MaxFieldLength(1000000));
IndexWriter w = new IndexWriter(FSDirectory.open(new File("index")), analyzer, true, new IndexWriter.MaxFieldLength(2139999999));
File file = new File("training.txt");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
File file1 = new File("fileName.txt");
FileInputStream fis1 = null;
BufferedInputStream bis1 = null;
DataInputStream dis1 = null;
try {
fis = new FileInputStream(file);
// Here BufferedInputStream is added for fast reading.
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
fis1 = new FileInputStream(file1);
// Here BufferedInputStream is added for fast reading.
bis1 = new BufferedInputStream(fis1);
dis1 = new DataInputStream(bis1);
// dis.available() returns 0 if the file does not have more lines.
while (dis.available() != 0 && dis1.available() != 0 ) {
String tempImg=dis1.readLine();
String temp=dis.readLine();
addDoc(w,tempImg,temp);
// System.out.println(temp);
}
// dispose all the resources after using them.
fis.close();
bis.close();
dis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
w.optimize();
w.close();
}
private static void addDoc(IndexWriter w, String value1,String value2) throws IOException
{
Document doc = new Document();
doc.add(new Field("fileId", value1, Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("visualId", value2, Field.Store.YES, Field.Index.ANALYZED));
w.addDocument(doc);
}
}
There is another file "fileName.txt", for file name. My "training.txt" is of size 127.1 MB & index folder is getting created of size 217.2 MB. I believe it should get reduced.
My Search Code :
public class search
{
public static void main(String args[]) throws IOException, ParseException
{
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
String fname = "test.txt";
File file = new File(fname);
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
Writer fos = null;
File outputFile = new File("outList.txt");
fos = new BufferedWriter(new FileWriter(outputFile));
// Here BufferedInputStream is added for fast reading.
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while (dis.available() != 0)
{
Query q = new QueryParser(Version.LUCENE_CURRENT, "visualId", analyzer).parse(dis.readLine());
//3.search
int hitsPerPage = 200;
IndexSearcher searcher = new IndexSearcher(IndexReader.open(FSDirectory.open(new File("index")), true));
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage, true);
long startTime = System.currentTimeMillis();
searcher.search(q, collector);
long endTime = System.currentTimeMillis();
ScoreDoc[] hits = collector.topDocs().scoreDocs;
for(int i=0;i<hits.length;++i) {
int docId = hits[i].doc;
Document d = searcher.doc(docId);
String text = d.get("fileId");
fos.write(text);
fos.write("\n");
}
searcher.close();
}
// dispose all the resources after using them.
fis.close();
fos.close();
bis.close();
dis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//out.close();
}
}
My "test.txt" is having content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 55 56 57 58 59 60 61 63 64 65 66 67 69 70 72 73 76 77 78 80 82 83 85 86 88 89 90 91 92 93 94 95 97 99 100 102 105 106 107 108 109 110 111 112 114 115 116 117 118 119 120 121 122 124 126 127 128 129 130 132 133 135 136 137 138 141 142 143 144 145 147 148 151 153 154 155 156 157 160 164 165 167 168 169 170 172 173 174 175 176 178 179 180 181 182 183 184 190 191 194 195 199 200 202 206 208 211 215 216 217 220 228 231 234 239 246 248 250 254 259 264 266 267 268 270 271 272 275 276 278 281 284 285 292 296 297 300 306 307 314 316 317 320 321 322 323 325 326 327 330 331 333 336 343 345 348 349 350 351 353 354 355 357 358 360 361 362 364 365 367 371 372 379 381 384 385 386 388 391 396 398 399 404 405 406 407 409 412 415 423 424 427 428 429 431 432 434 435 436 442 443 444 453 458 461 462 466 468 472 479 493 494 495 496 500 501 502 503 504 506 507 508 509 510 515 518 519 521 526 528 533 535 537 538 540 544 545 547 549 551 569 570 574 582 583 586 597 599 601 605 607 618 623 624 632 644 645 649 651 661 683 694 701 702 718 737 738 739 743 751 762 776 777 778 792 797 800 803 809 811 812 813 817 825 828 833 843 853 854 875 889 892 900 918 919 922 941 949 951 961 963 964 965 966 967 969 975 976 977 979 980 990 992 993 1000 1007 1008 1009 1029 1036 1045 1047 1051 1052 1053 1058 1059 1061 1062 1064 1065 1066 1070 1072 1075 1081 1082 1083 1086 1093 1094 1101 1114 1116 1117 1136 1143 1152 1154 1158 1159 1165 1172 1188 1194 1198 1212 1216 1218 1220 1227 1236 1245 1269 1272 1280 1283 1284 1285 1287 1293 1295 1296 1303 1305 1307 1327 1329 1332 1358 1373 1374 1375 1384 1385 1386 1397 1404 1415 1416 1436 1437 1478 1481 1482 1485 1487 1489 1501 1503 1505 1506 1508 1511 1517 1518 1520 1521 1522 1524 1525 1527 1529 1545 1555 1556 1564 1577 1579 1583 1599 1606 1610 1611 1612 1615 1620 1632 1636 1640 1648 1654 1706 1711 1721 1746 1750 1758 1792 1796 1802 1814 1820 1853 1869 1872 1897 1931 1932 1935 1946 1953 1982 2049 2082 2104 2107 2155 2211 2213 2216 2228 2253 2286 2329 2330 2332 2334 2377 2390 2399 2408 2427 2428 2433 2435 2440 2452 2475 2484 2498 2529 2559 2563 2626 2666 2675 2699 2754 2758 2765 2822 2847 2852 2882 2889 2893 2895 2898 2902 2906 2908 2925 2929 2932 2936 2939 2940 2971 2977 2980 2999 3022 3023 3024 3028 3086 3107 3134 3136 3140 3152 3156 3160 3174 3176 3182 3186 3192 3195 3197 3209 3216 3225 3242 3247 3249 3259 3279 3283 3303 3341 3349 3350 3352 3407 3429 3455 3462 3475 3476 3495 3515 3564 3581 3595 3637 3648 3653 3660 3681 3707 3735 3807 3817 3839 3850 3852 3856 3860 3878 3884 3889 3909 3916 3920 3980 3988 3997 4075 4120 4122 4123 4125 4152 4156 4157 4159 4191 4211 4244 4248 4307 4310 4434 4444 4446 4455 4462 4466 4503 4509 4516 4517 4525 4532 4551 4554 4559 4563 4564 4565 4573 4576 4581 4586 4634 4666 4669 4691 4730 4738 4748 4796 4817 4829 4832 4837 4846 4859 4896 4909 4919 4943 4962 5119 5132 5162 5237 5251 5275 5376 5387 5407 5441 5461 5559 5606 5608 5616 5692 5792 5797 5806 5837 5858 5947 6146 6245 6313 6320 6466 6632 6640 6648 6683 6759 6859 6987 6988 6989 6995 7003 7131 7171 7197 7223 7225 7280 7283 7299 7304 7320 7355 7357 7424 7451 7493 7586 7678 7690 7878 7997 8024 8096 8261 8275 8294 8465 8542 8556 8646 8667 8679 8685 8695 8707 8718 8724 8774 8786 8795 8808 8817 8819 8913 8932 8941 8996 9065 9069 9071 9085 9258 9321 9403 9408 9420 9456 9468 9481 9523 9528 9546 9559 9575 9584 9590 9592 9626 9648 9675 9727 9740 9742 9747 9776 9778 9836 9850 9909 10022 10046 10049 10056 10222 10288 10366 10385 10425 10429 10485 10546 10691 10744 10786 10912 10945 10958 10980 11043 11120 11205 11420 11451 11518 11551 11557 11568 11580 11633 11635 11652 11667 11728 11749 11760 11940 11963 11990 12225 12360 12367 12370 12375 12455 12468 12472 12476 12573 12632 12633 12731 12732 12745 12921 12922 12931 13303 13331 13332 13338 13364 13366 13386 13397 13510 13528 13548 13551 13575 13597 13654 13662 13676 13688 13689 13690 13693 13694 13720 13728 13743 13757 13901 13999 14007 14074 14190 14214 14245 14389 14452 14487 14496 14511 14538 14578 14689 14726 14756 14829 14887 15357 15395 15485 15710 15754 15824 16128 16161 16220 16323 16384 16678 16819 16825 16848 17075 17375 17391 17417 17511 17575 17841 18439 18734 18940 18961 19399 19896 19920 19945 20050 20276 20578 20960 20964 20967 20986 21009 21393 21513 21591 21670 21676 21839 21849 21898 21911 21960 22066 22072 22271 22354 22480 22759 23033 23070 23635 23990 24073 24287 24784 24824 24882 25395 25625 25668 25938 26002 26036 26054 26056 26085 26122 26153 26173 26321 26358 26385 26423 26450 26456 26739 26796 26823 26987 27196 27206 27214 27255 27773 27962 28209 28225 28260 28369 28405 28443 28568 28585 28637 28676 28724 28753 28770 28775 28877 28944 29026 29180 29221 29225 29240 29327 29333 29507
Thanks,
Ravi.
When you are adding Field.Store.YES to a Lucene field it is stored as well as indexed. The result would be that your index becomes larger than expected.

Categories