Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Raw PCM 16 bit 8Khz file to GSM_MS (610) conversion using ffmpeg
20 septembre 2011, par MANNI'm trying to convert a raw PCM 8000Hz MONO 16 bit file to GSM_MS (gsm610) encoded file using the ffmpeg. I Have compiled the ffmpeg with libgsm and while executing code I'm able to get the GSM_MS codec. But as of now I'm not able to create a valid gsm_ms file. Here is my code...
void EncodeTest(uint8_t *audioData, size_t audioSize){ AVCodecContext *audioCodec; AVCodec *codec; uint8_t *buf; int bufSize, frameBytes; __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"Lets encode :%u with size %d\n",(int)audioData, (int)audioSize); //Set up audio encoder codec = avcodec_find_encoder(CODEC_ID_GSM_MS); if (codec == NULL){ __android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG,"ERROR:: Unable to find encoder(CODEC_ID_GSM)"); codec = avcodec_find_encoder(CODEC_ID_GSM); if (codec == NULL){ __android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG,"ERROR:: Unable to find encoder(CODEC_ID_GSM)"); return; } } audioCodec = avcodec_alloc_context(); audioCodec->channels = 1; audioCodec->sample_rate = 8000; audioCodec->sample_fmt = SAMPLE_FMT_S16; audioCodec->bit_rate = 13200; audioCodec->priv_data = gsm_create(); audioCodec->codec_id = CODEC_ID_GSM_MS; __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"audioCodec->codec_id == %d",audioCodec->codec_id); switch(audioCodec->codec_id) { case CODEC_ID_GSM: audioCodec->frame_size = GSM_FRAME_SIZE; audioCodec->block_align = GSM_BLOCK_SIZE; int one = 1; gsm_option(audioCodec->priv_data, GSM_OPT_WAV49, &one); break; case CODEC_ID_GSM_MS: { int one = 1; gsm_option(audioCodec->priv_data, GSM_OPT_WAV49, &one); audioCodec->frame_size = 2*GSM_FRAME_SIZE; audioCodec->block_align = GSM_MS_BLOCK_SIZE; } } audioCodec->coded_frame= avcodec_alloc_frame(); audioCodec->coded_frame->key_frame= 1; audioCodec->time_base = (AVRational){1, audioCodec->sample_rate}; audioCodec->codec_type = CODEC_TYPE_AUDIO; if (avcodec_open(audioCodec, codec) < 0){ __android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG,"ERROR:: Unable to avcodec_open"); return; } bufSize = FF_MIN_BUFFER_SIZE; buf = (uint8_t *)malloc(bufSize); if (buf == NULL) return; //frameBytes = audioCodec->frame_size * audioCodec->channels * 2; //audioCodec->frame_size = 160; frameBytes = audioCodec->frame_size * audioCodec->channels * 2; //frameBytes = buf_size * input_sample_size / output_sample_size; //frameBytes = 160;//audioSize * 8000 / 13000; FILE *fileWrite = fopen(FILE_NAME,"w+b"); if(NULL == fileWrite){ __android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG,"ERROR:: Unable to open file for reading."); } /*Write wave header*/ WriteWav(fileWrite, 127920);/*Just for test*/ /*Lets encode raw packet and write into file after header.*/ __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"Lets Encode Actual Bytes"); int nChunckSize = 0; while (audioSize >= frameBytes) { int packetSize; packetSize = avcodec_encode_audio(audioCodec, buf, bufSize, (short *)audioData); if(packetSize < 0){ __android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG,"Encoder returned -ve data, %d bytes of data\n", packetSize); } __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"Consumed Bytes: %d and encoded Bytes:%d\n", packetSize,bufSize); nChunckSize += packetSize; audioData += 160; audioSize -= 160; if(NULL != fileWrite){ fwrite(buf, 1,packetSize, fileWrite); } else{ __android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG,"Unable to open file for writting... NULL"); } } if(NULL != fileWrite){ fclose(fileWrite); } __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"----- Done with nChunckSize: %d --- ",nChunckSize); __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"*****************************"); wavReadnDisplayHeader(FILE_NAME); __android_log_print(ANDROID_LOG_INFO, DEBUG_TAG,"*****************************"); wavReadnDisplayHeader("/sdcard/Voicemail2.wav");
} code here
-
Is there a "legal" review of FFmpeg contributions ?
20 septembre 2011, par RonopolisI can't find the answer to this at the FFmpeg website.
If someone submits code to FFmpeg, is the code just reviewed for technical correctness, or is there also a (for lack of better words) legal review? A review for any potential patent or copyright issues? If someone contributes to FFmpeg, does the contributor need to sign any kind of "Contributors Statement" or disclaimer?
-
What codec do I need to convert .wav to .mp3 with ffmpeg ?
19 septembre 2011, par LedZeppelinI am able to convert from .mp3 files to .wav files.
me@me-desktop:~$ ffmpeg -i Desktop/input.mp3 Desktop/output.wav FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1, Copyright (c) 2000-2009 Fabrice Bellard, et al. configuration: --extra-version=4:0.5.1-1ubuntu1.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 1 / 52.20. 1 libavformat 52.31. 0 / 52.31. 0 libavdevice 52. 1. 0 / 52. 1. 0 libavfilter 0. 4. 0 / 0. 4. 0 libswscale 0. 7. 1 / 0. 7. 1 libpostproc 51. 2. 0 / 51. 2. 0 built on Mar 31 2011 18:53:20, gcc: 4.4.3 [mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 0 Last message repeated 1 times [mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 1 Last message repeated 1 times Input #0, mp3, from 'Desktop/input.mp3': Duration: 00:04:45.31, start: 0.000000, bitrate: 256 kb/s Stream #0.0: Audio: mp3, 48000 Hz, stereo, s16, 256 kb/s Output #0, wav, to 'Desktop/output.wav': Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding [mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 0 Last message repeated 1 times [mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 1 size= 42944kB time=229.03 bitrate=1536.0kbits/s video:0kB audio:42944kB global headers:0kB muxing overhead 0.000100%
However when I try to convert the same .wav file back to an .mp3 I get the following error: Unsupported codec for output stream #0.0
me@me-desktop:~$ ffmpeg -i Desktop/output.wav Desktop/output2.mp3 FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1, Copyright (c) 2000-2009 Fabrice Bellard, et al. configuration: --extra-version=4:0.5.1-1ubuntu1.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 1 / 52.20. 1 libavformat 52.31. 0 / 52.31. 0 libavdevice 52. 1. 0 / 52. 1. 0 libavfilter 0. 4. 0 / 0. 4. 0 libswscale 0. 7. 1 / 0. 7. 1 libpostproc 51. 2. 0 / 51. 2. 0 built on Mar 31 2011 18:53:20, gcc: 4.4.3 Input #0, wav, from 'Desktop/output.wav': Duration: 00:03:49.03, bitrate: 1536 kb/s Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s Output #0, mp3, to 'Desktop/output2.mp3': Stream #0.0: Audio: 0x0000, 48000 Hz, stereo, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Unsupported codec for output stream #0.0
I've already tried installing unstripped-51 per a suggestion from a previous question but I am still unable to convert from .wav to .mp3
-
Command to get information about a mp3 using ffmpeg ?
19 septembre 2011, par LedZeppelinIs there a command with ffmpeg that returns information about an mp3 like the bitrate or sampling frequency?
-
Interact with ffmpeg from a .NET program ?
18 septembre 2011, par ShimmyI'm trying to create a .NET wrapper for media-file conversion using ffmepg, here is what I've tried:
static void Main(string[] args) { if (File.Exists("sample.mp3")) File.Delete("sample.mp3"); string result; using (Process p = new Process()) { p.StartInfo.FileName = "ffmpeg"; p.StartInfo.Arguments = "-i sample.wma sample.mp3"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.Start(); //result is assigned with an empty string! result = p.StandardOutput.ReadToEnd(); p.WaitForExit(); } }
What actually happens is the content of the ffmpeg program is printed out to the Console app, but the
result
variable is an empty string. I want to control the conversion progress interactively, so the user doesn't even have to know I'm using ffmpeg, but he still knows the conversion progress' details and what percentage etc. the app is up to.Basically I would also be happy with a .NET wrapper for a P/Invoke to conversion function ONLY (I am not interested in a whole external library, unless I can extract the PI function from it).
Anyone with experience in ffmpeg & .NET?
Update Please view my further question, how to write input to a running ffmpeg process.