How to compress existing mp4 video with javacv/ffmpeg ??? plz help :)

780 views
Skip to first unread message

elbarid...@gmail.com

unread,
Mar 14, 2013, 6:05:38 AM3/14/13
to jav...@googlegroups.com

Samuel Audet

unread,
Mar 16, 2013, 7:44:41 AM3/16/13
to jav...@googlegroups.com
Hello,

Just do as shown with the Demo class found in the README.txt file, but
replace the "output.avi" filename with something that ends with ".mp4",
and that's it.

Samuel

elbarid...@gmail.com

unread,
Mar 19, 2013, 9:07:11 AM3/19/13
to jav...@googlegroups.com

while reading the demo class in readme file i see that framegraber grabes image, and framerecorder records them .

fine but where does the audio in the output file takes place?
 
my purpose is to compress an HD video lets say 50mb to like 5 mb.
 
Regards! 

elbarid...@gmail.com

unread,
Mar 19, 2013, 10:25:20 AM3/19/13
to jav...@googlegroups.com

thanks to ur support am able to compress the video but not with the audio.

any hint to grab the audio ?? :)
 
Regards my friend

Samuel Audet

unread,
Mar 22, 2013, 10:39:51 PM3/22/13
to jav...@googlegroups.com
On 03/19/2013 11:25 PM, elbarid...@gmail.com wrote:
> thanks to ur support am able to compress the video but not with the audio.
>
> any hint to grab the audio ?? :)

Something like this should work:

FrameGrabber grabber = new FFmpegFrameGrabber("input.mp4");
grabber.start();
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("output.mp4",
grabber.getImageWidth(), grabber.getImageHeight(),
grabber.getAudioChannels());
recorder.setFrameRate(grabber.getFrameRate());
recorder.setSampleRate(grabber.getSampleRate());
recorder.start();
Frame frame;
while ((frame = grabber1.grabFrame()) != null) {
recorder.record(frame);
}
recorder.stop();
grabber.stop();

Samuel

elbarid...@gmail.com

unread,
May 15, 2013, 8:26:25 AM5/15/13
to jav...@googlegroups.com
Dear Samuel,
 
now I am able to compress the video along with the audio! I was traveling for a while and now I came back!
I have a problem though it is driving me crazy!
 
On all htc , the compression of the video along with the audio works great
I am using the following code:
 

FrameRecorder recorder=

new FFmpegFrameRecorder(newfullpath, 240, 320,1);

 

recorder.setAudioCodec(avcodec.

AV_CODEC_ID_AAC);

recorder.setFrameRate(grabber.getFrameRate());

recorder.setSampleRate(grabber.getSampleRate());

recorder.setVideoCodec(avcodec.

AV_CODEC_ID_MPEG4);

 

 

Although, On all Samsung devices (not mentioning I have tons of trouble with camera intent also) , the audio after compression is distorted and freaky.!!!!!

I tried setting audiobitrate and sample rate with no result!!!

Please advice! ur the best :)


On Thursday, March 14, 2013 12:05:38 PM UTC+2, elbarid...@gmail.com wrote:

elbarid...@gmail.com

unread,
May 16, 2013, 6:08:14 AM5/16/13
to jav...@googlegroups.com
For whom it may concern,
 
I found the solution of the distorted sound in Samsung.
 
HTC records mp4 with audio aac but 1 channel while Samsung records mp4 with audio aac 2 channels .
 
welcome! :P
 
 
another problem whith Samsung I am having and I hope Samuel replies :
after click save video from intent.mediastore.capture_video , the activity result is not started and the app crashes saying unable to start activity with null point exception.
 
I thing the problem is related to the fact that when u launch media intent from Samsung , the activity is forced rotated to landscape  so when I click save video the activity is recreated and it crashes ! I don't have this problem on htc devices
 
I am trying to put debug breakpoints on the start of activity they are never called!
 
I tried setting config:scrrensize,keyboard,orientatiion in manifest along with orientation : portrait but also nothing.
 
weird thing is that sometimes on Samsung it works activity result gets called and sometimes not!
 
appreciate advice from anyone!
 
Regards samuel

Samuel Audet

unread,
May 19, 2013, 12:12:36 AM5/19/13
to jav...@googlegroups.com
On 05/16/2013 07:08 PM, elbarid...@gmail.com wrote:
> For whom it may concern,
> I found the solution of the distorted sound in Samsung.
> HTC records mp4 with audio aac but 1 channel while Samsung records mp4
> with audio aac 2 channels .
> welcome! :P

Great! Thanks for letting us know

> another problem whith Samsung I am having and I hope Samuel replies :
> after click save video from intent.mediastore.capture_video , the
> activity result is not started and the app crashes saying unable to
> start activity with null point exception.
> I thing the problem is related to the fact that when u launch media
> intent from Samsung , the activity is forced rotated to landscape so
> when I click save video the activity is recreated and it crashes ! I
> don't have this problem on htc devices
> I am trying to put debug breakpoints on the start of activity they are
> never called!
> I tried setting config:scrrensize,keyboard,orientatiion in manifest
> along with orientation : portrait but also nothing.
> weird thing is that sometimes on Samsung it works activity result gets
> called and sometimes not!
> appreciate advice from anyone!

Well, Android isn't exactly a paragon of stability. I'm afraid you'll
have to figure out what works exactly with your particular phone model.

Sounds like threading issue though. Make sure all the threads remain in
a consistent state.

Samuel

Reply all
Reply to author
Forward
Message has been deleted
0 new messages