Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
undefined reference error while building FFMPEG with NDK
22 mars 2015, par dev123I get this error while running build-ndk for my ffmpeg android project
make: *** [obj/local/armeabi-v7a/libffmpeg-test-jni.so] undefined reference to 'av_close_input_file' undefined reference to 'av_find_stream_info' undefined reference to 'av_open_input_file' undefined reference to 'avcodec_open'
Any solutions to get rid of this error ? I am very new to ffmpeg and Android NDK
This is my Android MK file
LOCAL_PATH := $(call my-dir) #declare the prebuilt library include $(CLEAR_VARS) LOCAL_MODULE := ffmpeg-prebuilt LOCAL_SRC_FILES := ffmpeg-2.5.4/android/armv7-a/libffmpeg.so LOCAL_EXPORT_C_INCLUDES := ffmpeg-2.5.4/android/armv7-a/include LOCAL_EXPORT_LDLIBS := ffmpeg-2.5.4/android/armv7-a/libffmpeg.so LOCAL_LDLIBS += -llog -lavutil -lavformat -lavcodec -lz -lavutil -lm LOCAL_PRELINK_MODULE := true include $(PREBUILT_SHARED_LIBRARY) #the andzop library include $(CLEAR_VARS) LOCAL_ALLOW_UNDEFINED_SYMBOLS=false LOCAL_MODULE := ffmpeg-test-jni LOCAL_SRC_FILES := ffmpeg-test-jni.c LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg-2.5.4/android/armv7-a/include LOCAL_SHARED_LIBRARY := ffmpeg-prebuilt LOCAL_LDLIBS := -llog -ljnigraphics -lz -lm $(LOCAL_PATH)/ffmpeg-2.5.4/android/armv7-a/libffmpeg.so include $(BUILD_SHARED_LIBRARY)
Any Pointers much appreciated Thanks!
-
Using AForge.Net for commercial closed-source applications
22 mars 2015, par ilay zeidmanI have application that our company want to make a product from. The application uses AForge.Net and in the AForge.Video.FFMPEG.dll which is under GPL v3 license. You can see AForge.net license
My question: can I use this dll in my product? Do my product have to be under gpl3 and the source should be available?
-
Recording voice using HTML5 and processing it with ffmpeg
22 mars 2015, par user3789242I need to use ffmpeg in my javascript/HTML5 project which allows the user to select the format he wants the audio to open with.I don't know anything about ffmpeg and I've been doing lots of research I don't know how to use it in my project. I found an example https://github.com/sopel39/audioconverter.js but the problem how can I install the ffmpeg.js which is 8 mg to m project. please if someone can help me I'll be very thankfull here is my full code:
the javascript page:
// variables var leftchannel = []; var rightchannel = []; var recorder = null; var recording = false; var recordingLength = 0; var volume = null; var audioInput = null; var sampleRate = 44100; var audioContext = null; var context = null; var outputString; if (!navigator.getUserMedia) navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; if (navigator.getUserMedia){ navigator.getUserMedia({audio:true}, success, function(e) { alert('Error capturing audio.'); }); } else alert('getUserMedia not supported in this browser.'); function getVal(value) { // if R is pressed, we start recording if ( value == "record"){ recording = true; // reset the buffers for the new recording leftchannel.length = rightchannel.length = 0; recordingLength = 0; document.getElementById('output').innerHTML="Recording now..."; // if S is pressed, we stop the recording and package the WAV file } else if ( value == "stop" ){ // we stop recording recording = false; document.getElementById('output').innerHTML="Building wav file..."; // we flat the left and right channels down var leftBuffer = mergeBuffers ( leftchannel, recordingLength ); var rightBuffer = mergeBuffers ( rightchannel, recordingLength ); // we interleave both channels together var interleaved = interleave ( leftBuffer, rightBuffer ); var buffer = new ArrayBuffer(44 + interleaved.length * 2); var view = new DataView(buffer); // RIFF chunk descriptor writeUTFBytes(view, 0, 'RIFF'); view.setUint32(4, 44 + interleaved.length * 2, true); writeUTFBytes(view, 8, 'WAVE'); // FMT sub-chunk writeUTFBytes(view, 12, 'fmt '); view.setUint32(16, 16, true); view.setUint16(20, 1, true); // stereo (2 channels) view.setUint16(22, 2, true); view.setUint32(24, sampleRate, true); view.setUint32(28, sampleRate * 4, true); view.setUint16(32, 4, true); view.setUint16(34, 16, true); // data sub-chunk writeUTFBytes(view, 36, 'data'); view.setUint32(40, interleaved.length * 2, true); var lng = interleaved.length; var index = 44; var volume = 1; for (var i = 0; i < lng; i++){ view.setInt16(index, interleaved[i] * (0x7FFF * volume), true); index += 2; } var blob = new Blob ( [ view ], { type : 'audio/wav' } ); // let's save it locally document.getElementById('output').innerHTML='Handing off the file now...'; var url = (window.URL || window.webkitURL).createObjectURL(blob); var li = document.createElement('li'); var au = document.createElement('audio'); var hf = document.createElement('a'); au.controls = true; au.src = url; hf.href = url; hf.download = 'audio_recording_' + new Date().getTime() + '.wav'; hf.innerHTML = hf.download; li.appendChild(au); li.appendChild(hf); recordingList.appendChild(li); } } function success(e){ audioContext = window.AudioContext || window.webkitAudioContext; context = new audioContext(); volume = context.createGain(); // creates an audio node from the microphone incoming stream(source) source = context.createMediaStreamSource(e); // connect the stream(source) to the gain node source.connect(volume); var bufferSize = 2048; recorder = context.createScriptProcessor(bufferSize, 2, 2); //node for the visualizer analyser = context.createAnalyser(); analyser.smoothingTimeConstant = 0.3; analyser.fftSize = 512; splitter = context.createChannelSplitter(); //when recording happens recorder.onaudioprocess = function(e){ if (!recording) return; var left = e.inputBuffer.getChannelData (0); var right = e.inputBuffer.getChannelData (1); leftchannel.push (new Float32Array (left)); rightchannel.push (new Float32Array (right)); recordingLength += bufferSize; // get the average for the first channel var array = new Uint8Array(analyser.frequencyBinCount); analyser.getByteFrequencyData(array); var c=document.getElementById("myCanvas"); var ctx = c.getContext("2d"); // clear the current state ctx.clearRect(0, 0, 1000, 325); var gradient = ctx.createLinearGradient(0,0,0,300); gradient.addColorStop(1,'#000000'); gradient.addColorStop(0.75,'#ff0000'); gradient.addColorStop(0.25,'#ffff00'); gradient.addColorStop(0,'#ffffff'); // set the fill style ctx.fillStyle=gradient; drawSpectrum(array); function drawSpectrum(array) { for ( var i = 0; i < (array.length); i++ ){ var value = array[i]; ctx.fillRect(i*5,325-value,3,325); } } } function getAverageVolume(array) { var values = 0; var average; var length = array.length; // get all the frequency amplitudes for (var i = 0; i < length; i++) { values += array[i]; } average = values / length; return average; } // we connect the recorder(node to destination(speakers)) volume.connect(splitter); splitter.connect(analyser, 0, 0); analyser.connect(recorder); recorder.connect(context.destination); } function mergeBuffers(channelBuffer, recordingLength){ var result = new Float32Array(recordingLength); var offset = 0; var lng = channelBuffer.length; for (var i = 0; i < lng; i++){ var buffer = channelBuffer[i]; result.set(buffer, offset); offset += buffer.length; } return result; } function interleave(leftChannel, rightChannel){ var length = leftChannel.length + rightChannel.length; var result = new Float32Array(length); var inputIndex = 0; for (var index = 0; index < length; ){ result[index++] = leftChannel[inputIndex]; result[index++] = rightChannel[inputIndex]; inputIndex++; } return result; } function writeUTFBytes(view, offset, string){ var lng = string.length; for (var i = 0; i < lng; i++){ view.setUint8(offset + i, string.charCodeAt(i)); } }
and here is the html code:
<script src="http://stackoverflow.com/feeds/tag/js/functions.js"></script>
-
ACC audio headers
22 mars 2015, par Rafah SamehI have ACC audio samples data , and i should encrypted them
sample 1
21-4D-FE-FF-FE-1E-CC-C7-E1-4B-AC-71-91-42-C0-00-00-00-00-00-00-CB-A6-62-F8-E0-00-74-FC-4F-25-EF-E0-01-AF-97-EE-1F-6A-00-0D-1D-BF-81-FC-B8-00-38-9A-FA-3F-58-00-0C-A3-F8-BF-A4-00-34-F5-3E-D7-CB-00-00-00-BC-A3-3F-A3-FC-DF-37-E2-00-00-00-61-73-87-B7-F2-7E-37-D9-80-00-00-67-58-CF-BC-ED-BE-F7-C6-00-00-00-00-0C-33-A8-CF-0F-8F-C1-F9-5F-17-C4-E1-80-00-00-00-05-CC-67-51-EF-7D-37-17-DE-70-BC-10-00-00-00-00-00-0D-6E-E2-47-EC-FA-3F-D7-F9-77-EC-64-0F-87
sample2
21-4E-FE-FF-FF-21-46-13-44-2C-51-99-12-EB-35-6A-D4-52-7E-A3-40-37-EE-D3-9E-0F-2D-62-46-43-BA-F1-AB-0E-EF-79-84-6F-4E-BE-43-F3-95-D3-25-24-B8-CC-55-37-A3-E5-15-D8-91-64-BA-B4-B1-0F-5C-09-A3-F1-2B-7A-9E-B5-D1-D9-95-85-12-65-C3-CE-6D-B0-38-E4-27-A8-46-E9-CB-8C-FD-0D-28-83-A4-74-DF-92-CD-27-A6-22-9B-8E-A4-7A-E8-70-3A-E9-BF-6F-0F-DD-5F-E9-75-67-F7-85-2A-EE-7E-37-C3-FF-12-1F-CF-F8-F5-C3-A1-09-91-10-20-98-08-36-91-A1-54-48-B3-98-D6-4B-53-71-A2-0C-81-45-D0-12-EA-42-DD-E9-AA-B6-D1-AB-68-BD-29-23-88-4C-CB-2F-27-E6-BE-D1-27-B4-A7-64-F6-67-6A-0C-97-84-17-65-CC-D5-81-AB-C4-DB-4A-DB-19-AE-17-E8-D0-7F-6E-56-3F-B3-C1-A6-BA-0E-BB-1C-DB-DB-90-84-1E-DB-B6-8B-56-07-4D-1F-71-C0-75-01-D4-4C-00-32-07-E0-70
for each frame start with 21 xxxx ff-ff ,for example
21-4E-FE-FF-FF..... 21-4D-FE-FF-FE....
so do you know what this header mean ?
few of samples is have the size 9 byte and take one of these values (
21-00-49-90-02-19-00-23-80
) or (20-00-49-90-02-19-00-23-80
) so do you know what these samples mean ?always the first sample reserved 26 byte and have the values (
DE-04-00-00-6C-69-62-66-61-61-63-20-31-2E-32-38-00-00-42-00-93-20-04-32-00-47
) so do you know what these sample mean ? -
Converted Avi to Mp4 using FFMPEG, Converted video not working in html 5 Tag
21 mars 2015, par SuprabhatI have a section in my web page where user can upload any types of videos of any format , currently only restricted to .mp4 and .avi. After successfull upload i have displayed the same video to the user. I have bind the path in HTML5 video so that the user can view the content he/she has uploded. Video with extension .mp4 no doubt are working properly as HTML5 support them. Tricky part is it don't support Avi files. Now here what the problem has arised. In order to display avi videos i have used FFMPEG to convert videos with extension .avi to .mp4. With lots of googling and reading forum, i have succesfully converted avi videos to mp4 . Here's what i have used :-
ffmpeg -i input.avi -acodec libfaac -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output.mp4
ffmpeg -i input.avi -c:v libx264 -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output.mp4
Above two are working perfectly, they have succesfully converted the video. But when i run them on browser in HTML5 and in new tab (Flash Player Plugin Installed), HTML5 doesn't play it and flash player return an error message "Video can't be played because the file is corrupt". But when i played them on KMplayer and in Window media player they are running perfectly.
I have been to various threads in stackoverflow related to convert avi to mp4 and here i found following in one of the forum. where one of user has accepted this a correct answer but it ain't worked out for me.
ffmpeg -y -i sample.avi -b:v 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 sample.mp4
Above argument returned me following error "File for preset 'slow' not found".
Following my futher searches i came across this thread ffmpeg convert mov file to mp4 for HTML5 video tag IE9. Here following argument worked perfectly and it able to convert video in such way that it is playble on browser.
ffmpeg -y -i input.avi -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k -pix_fmt yuv420p output.mp4
.
Problem i faced here was video is converted to 420p reso which quality is noty upto mark. Smaller resolution videos are been enlarged and seems pixelated
Thus, i had to finally put up a question. I will be very obliged if someone can give a solution for above problem. I need to convert an avi video to mp4 supported by HTML5 video tag. It should able to play it on browser and during conversion of video it should maintain original audio and video quality plus resolution.
Thanks
My C# Code:
public void Create(string input, string output, string parametri, string ThumbnailPhysicalPath, int ConvertType) { ffmpeg = new Process(); if (ConvertType == Convert.ToInt32(ConversionType.Thumbnail)) ffmpeg.StartInfo.Arguments = " -i \"" + input + "\" -vframes 1 \"" + output + "\""; else if (ConvertType == Convert.ToInt32(ConversionType.AviToMp4)) ffmpeg.StartInfo.Arguments = " -i \"" + input + "\" -c:v libx264 -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 \"" + output + "\""; //ffmpeg.StartInfo.Arguments = " -i \"" + input + "\" -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k -pix_fmt yuv420p \"" + output + "\""; ffmpeg.StartInfo.FileName = ThumbnailPhysicalPath + @"ffmpeg.exe"; ffmpeg.StartInfo.UseShellExecute = false; ffmpeg.StartInfo.RedirectStandardOutput = true; ffmpeg.StartInfo.RedirectStandardError = true; ffmpeg.StartInfo.CreateNoWindow = true; try { ffmpeg.Start(); ffmpeg.WaitForExit(); string error = ffmpeg.StandardError.ReadToEnd(); } catch (Exception Ex) { Common.WriteLog("Exception occurred during conversion. Error Message :- " + Ex.Message + "\n Input Parameter :- " + input+ "\n Output Paramenter :- "+ output); } finally { ffmpeg.Close(); if (ConvertType == Convert.ToInt32(ConversionType.AviToMp4)) UpdateConvertedVideoDetails(input,output); } }
Command Prompt FFMPEG Output :-
Sample 3 Result :-
D:\Client\WebSite\Converter_Tools>ffmpeg -y -i sample.avi -b:v 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 sample.mp4 ffmpeg version N-70239-g111d79a Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc -- enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab le-zlib libavutil 54. 19.100 / 54. 19.100 libavcodec 56. 26.100 / 56. 26.100 libavformat 56. 23.105 / 56. 23.105 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 11.101 / 5. 11.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 [avi @ 037c8480] non-interleaved AVI Guessed Channel Layout for Input Stream #0.1 : mono Input #0, avi, from 'sample.avi': Duration: 00:00:34.00, start: 0.000000, bitrate: 1433 kb/s Stream #0:0: Video: cinepak (cvid / 0x64697663), rgb24, 320x240, 15 fps, 15 tbr, 15 tbn, 15 tbc Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 22050 Hz, 1 channels, u8, 176 kb/s File for preset 'slow' not found
Sample 4 Result :-
D:\Client\WebSite\Converter_Tools>ffmpeg -y -i input.avi -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_ aacenc -b:a 128k -pix_fmt yuv420p output.mp4 ffmpeg version N-70239-g111d79a Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc -- enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab le-zlib libavutil 54. 19.100 / 54. 19.100 libavcodec 56. 26.100 / 56. 26.100 libavformat 56. 23.105 / 56. 23.105 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 11.101 / 5. 11.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, avi, from 'input.avi': Duration: 00:00:03.93, start: 0.000000, bitrate: 3255 kb/s Stream #0:0: Video: msrle ([1][0][0][0] / 0x0001), pal8, 300x250, 3301 kb/s, 15 fps, 15 tbr, 15 tbn, 15 tbc [libx264 @ 002ec860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 [libx264 @ 002ec860] profile High, level 2.2 [libx264 @ 002ec860] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subm e=8 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_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i nterlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=50 rc =cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'output.mp4': Metadata: encoder : Lavf56.23.105 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 576x480, q=-1--1, 500 kb/s, 15 fps, 15360 tbn, 15 tbc Metadata: encoder : Lavc56.26.100 libx264 Stream mapping: Stream #0:0 -> #0:0 (msrle (native) -> h264 (libx264)) Press [q] to stop, [?] for help frame= 59 fps= 30 q=-1.0 Lsize= 229kB time=00:00:03.80 bitrate= 493.5kbits/s video:227kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.637976% [libx264 @ 002ec860] frame I:3 Avg QP:26.53 size: 10657 [libx264 @ 002ec860] frame P:25 Avg QP:30.49 size: 5608 [libx264 @ 002ec860] frame B:31 Avg QP:32.26 size: 1935 [libx264 @ 002ec860] consecutive B-frames: 22.0% 16.9% 20.3% 40.7% [libx264 @ 002ec860] mb I I16..4: 16.7% 69.0% 14.4% [libx264 @ 002ec860] mb P I16..4: 11.1% 29.9% 3.8% P16..4: 21.3% 6.8% 2.6% 0.0% 0.0% skip:24.6% [libx264 @ 002ec860] mb B I16..4: 1.7% 3.0% 0.3% B16..8: 29.7% 5.6% 0.8% direct: 2.1% skip:56.8% L0:50.5% L1:45.6% BI: 3.9% [libx264 @ 002ec860] 8x8 transform intra:66.5% inter:79.4% [libx264 @ 002ec860] direct mvs spatial:93.5% temporal:6.5% [libx264 @ 002ec860] coded y,uvDC,uvAC intra: 40.3% 48.8% 25.7% inter: 12.4% 8.4% 1.4% [libx264 @ 002ec860] i16 v,h,dc,p: 19% 59% 6% 17% [libx264 @ 002ec860] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 25% 16% 7% 8% 6% 11% 7% 10% [libx264 @ 002ec860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 21% 9% 7% 9% 8% 10% 7% 10% [libx264 @ 002ec860] i8c dc,h,v,p: 41% 33% 13% 13% [libx264 @ 002ec860] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 002ec860] ref P L0: 67.6% 8.1% 9.6% 5.4% 6.6% 2.8% [libx264 @ 002ec860] ref B L0: 84.6% 10.5% 3.9% 1.0% [libx264 @ 002ec860] ref B L1: 95.9% 4.1% [libx264 @ 002ec860] kb/s:472.20