Salmaan Salmaan - 2 months ago 17
Android Question

Incorrect Codec Parameters, Could not write header for output file: FFMPEG - Android

Why do I get Incorrect Codec Parameters....???

I am creating video using Android

MediaRecorder
, use
FFMPEG
over it to trim it.
I am just trying to trim the video using
FFMPEG
.

String[] ffmpegCommand = {
"/data/data/uk.org.humanfocus.hfi/ffmpeg",
"-ss",
"00:00:00",
"-i",
path, // string variable, path of file
"-t",
"00:00:05", // duration of video
"-c",
"copy",
destination + "/trimmmmm.mp4" }; // string


This is log I get..

It is from starting of
FFMPEG
processing until it ends.

10-24 18:02:06.039: V/ss(22093): ***Starting FFMPEG***
10-24 18:02:06.144: V/asd(22093): ***ffmpeg version N-63700-gbf0e5ac Copyright (c) 2000-2014 the FFmpeg developers***
10-24 18:02:06.144: V/asd(22093): *** built on Jun 3 2014 13:27:45 with gcc 4.8 (GCC)***
10-24 18:02:06.144: V/asd(22093): *** configuration: --prefix=/Users/aliasa/Downloads/android-ndk-r9/sources/ffmpeg/android/arm --enable-shared --disable-static --disable-doc --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-doc --disable-symver --cross-prefix=/Users/aliasa/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi- --target-os=linux --arch=arm --enable-cross-compile --sysroot=/Users/aliasa/Downloads/android-ndk-r9/platforms/android-9/arch-arm/ --extra-cflags='-Os -fpic -marm' --extra-ldflags=***
10-24 18:02:06.149: V/asd(22093): *** libavutil 52. 89.100 / 52. 89.100***
10-24 18:02:06.149: V/asd(22093): *** libavcodec 55. 66.100 / 55. 66.100***
10-24 18:02:06.149: V/asd(22093): *** libavformat 55. 42.100 / 55. 42.100***
10-24 18:02:06.149: V/asd(22093): *** libavfilter 4. 5.100 / 4. 5.100***
10-24 18:02:06.149: V/asd(22093): *** libswscale 2. 6.100 / 2. 6.100***
10-24 18:02:06.149: V/asd(22093): *** libswresample 0. 19.100 / 0. 19.100***
10-24 18:02:06.289: V/asd(22093): ***Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/copymade.mp4':***
10-24 18:02:06.289: V/asd(22093): *** Metadata:***
10-24 18:02:06.289: V/asd(22093): *** major_brand : isom***
10-24 18:02:06.289: V/asd(22093): *** minor_version : 0***
10-24 18:02:06.289: V/asd(22093): *** compatible_brands: isom3gp4***
10-24 18:02:06.289: V/asd(22093): *** creation_time : 2014-10-24 12:25:55***
10-24 18:02:06.294: V/asd(22093): *** Duration: 00:00:11.65, start: 0.000000, bitrate: 3147 kb/s***
10-24 18:02:06.294: V/asd(22093): *** Stream #0:0(eng): Video: h263 (s263 / 0x33363273), yuv420p, 720x480 [SAR 12:11 DAR 18:11], 3276 kb/s, 16.61 fps, 16.67 tbr, 90k tbn, 29.97 tbc (default)***
10-24 18:02:06.294: V/asd(22093): *** Metadata:***
10-24 18:02:06.294: V/asd(22093): *** creation_time : 2014-10-24 12:25:55***
10-24 18:02:06.294: V/asd(22093): *** handler_name : VideoHandle***
10-24 18:02:06.294: V/asd(22093): *** Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 12 kb/s (default)***
10-24 18:02:06.294: V/asd(22093): *** Metadata:***
10-24 18:02:06.294: V/asd(22093): *** creation_time : 2014-10-24 12:25:55***
10-24 18:02:06.294: V/asd(22093): *** handler_name : SoundHandle***
10-24 18:02:06.294: V/asd(22093): ***[mp4 @ 0x50ce0] Could not find tag for codec h263 in stream #0, codec not currently supported in container***
10-24 18:02:06.294: V/asd(22093): ***Output #0, mp4, to '/storage/emulated/0/trimmmmm.mp4':***
10-24 18:02:06.294: V/asd(22093): *** Metadata:***
10-24 18:02:06.294: V/asd(22093): *** major_brand : isom***
10-24 18:02:06.294: V/asd(22093): *** minor_version : 0***
10-24 18:02:06.294: V/asd(22093): *** compatible_brands: isom3gp4***
10-24 18:02:06.294: V/asd(22093): *** encoder : Lavf55.42.100***
10-24 18:02:06.294: V/asd(22093): *** Stream #0:0(eng): Video: h263 (s263 / 0x33363273), yuv420p, 720x480 [SAR 12:11 DAR 18:11], q=2-31, 3276 kb/s, 16.61 fps, 90k tbn, 90k tbc (default)***
10-24 18:02:06.294: V/asd(22093): *** Metadata:***
10-24 18:02:06.294: V/asd(22093): *** creation_time : 2014-10-24 12:25:55***
10-24 18:02:06.294: V/asd(22093): *** handler_name : VideoHandle***
10-24 18:02:06.294: V/asd(22093): *** Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 8000 Hz, mono, 12 kb/s (default)***
10-24 18:02:06.294: V/asd(22093): *** Metadata:***
10-24 18:02:06.294: V/asd(22093): *** creation_time : 2014-10-24 12:25:55***
10-24 18:02:06.299: V/asd(22093): *** handler_name : SoundHandle***
10-24 18:02:06.299: V/asd(22093): ***Stream mapping:***
10-24 18:02:06.299: V/asd(22093): *** Stream #0:0 -> #0:0 (copy)***
10-24 18:02:06.299: V/asd(22093): *** Stream #0:1 -> #0:1 (copy)***
10-24 18:02:06.299: V/asd(22093): ***Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument***
10-24 18:02:06.299: V/asdas(22093): ***Ending FFMPEG***


I am badly stuck here from 2 3 days, please help me out.

Answer

With the help of @JasonYang answer and description i concluded that H.264 should be used..
While initializing MediaRecorder...

i was using prMediaRecorder.setVideoEncoder(VideoEncoder.DEFAULT);
instead i used prMediaRecorder.setVideoEncoder(VideoEncoder.H264);

and it worked magically :)

Comments