Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How do I enable FFMPEG logging and where can I find the FFMPEG log file ?
29 mars 2017, par undefinedI want to be able to log FFMPEG processes because I am trying to work out how long a minute of video takes to convert to help with capacity planning of my video encoding server. How do I enable logging and where is the log file saved. I have FFMPEG installed on a CentOS LAMP machine.
-
Android : Demux MP4 into video and audio ?
29 mars 2017, par Jason DeruloI need to demux an MP4 file into video and audio to do some editing on the audio. I don't want to use FFMPEG, I've already attempted to use it once and it went horribly. How would I go about demuxing? From google searches, it seems like there isn't even a way to do it. Nothing ever comes up. I was thinking of converting an MP4 into an MP3, editing that and then adding that audio onto the original MP4 using MP4Parser, how can I edit the MP3? Absolutely any help is appreciated, I have no idea where to go from here.
-
FFmpeg record rtsp stream to file error
29 mars 2017, par tommyvisagroupI use ffmpeg to record rtsp stream, it work good but the output file got some proble, when I use use K-Lite Codec Pack to open the output (avi) file the video cant be seek, forward, backward and dont display video time. It lock like i am viewing streaming.
here is the command i used
ffmpeg -i rtsp://27.74.xxx.xxx:55/ufirststream -acodec copy -vcodec copy abc.avi
-
Find if video file has audio present in it
29 mars 2017, par KartosI'm trying to figure out if a video has audio present in it so as to extract the mp3 using ffmpeg. When the video contains no audio channels, ffmpeg creates an empty mp3 file which I'm using to figure out if audio was present in the video in the first place. I'm sure there is a better way to identify if audio is present in a video. Will avprobe help with this? Can anyone point me to a resource or probably a solution?
Edit: Surprisingly, the same command on my server running the latest build of ffprobe doesn't run. It throws an error saying
Unrecognized option 'select_stream'
Failed to set value 'a' for option 'select_stream'
Any ideas how to rectify this out?
-
Error decoding a simple audio file using FFmpeg library
29 mars 2017, par satyresAfter successfuly compiling the latest version of FFmpeg library and generated .a library in Ubuntu I've been struggling now for more than a week to decode and play a simple mp3 file in Android without a success ! I've followed this tutorial given by FFmpeg team in Github i've tried to use it in Android but no luck ! here is the Native code.
void Java_com_example_home_hellondk_MainActivity_audio_1decode_1example(JNIEnv * env, jobject obj, jstring file, jbyteArray array) { jboolean isfilenameCopy; const char * filename = ( * env) - > GetStringUTFChars(env, file, & isfilenameCopy); jclass cls = ( * env) - > GetObjectClass(env, obj); jmethodID play = ( * env) - > GetMethodID(env, cls, "playSound", "([BI)V"); AVCodec * codec; AVCodecContext * c = NULL; int len; FILE * f, * outfile; uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; AVFrame * decoded_frame = NULL; av_init_packet( & avpkt); printf("Decode audio file %s \n", filename); LOGE("Decode audio file %s\n", filename); /* find the MPEG audio decoder */ codec = avcodec_find_decoder(AV_CODEC_ID_MP3); if (!codec) { fprintf(stderr, "Codec not found\n"); LOGE("Codec not found\n"); exit(1); } c = avcodec_alloc_context3(codec); if (!c) { fprintf(stderr, "Could not allocate audio codec context\n"); LOGE("Could not allocate audio codec context\n"); exit(1); } /* open it */ if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); LOGE("Could not open codec\n"); exit(1); } f = fopen(filename, "rb"); if (!f) { fprintf(stderr, "Could not open %s\n", filename); LOGE("Could not open %s\n", filename); exit(1); } /* decode until eof */ avpkt.data = inbuf; avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); while (avpkt.size > 0) { int i, ch; int got_frame = 0; if (!decoded_frame) { if (!(decoded_frame = av_frame_alloc())) { fprintf(stderr, "Could not allocate audio frame\n"); LOGE("Could not allocate audio frame\n"); exit(1); } } len = avcodec_decode_audio4(c, decoded_frame, & got_frame, & avpkt); if (len < 0) { fprintf(stderr, "Error while decoding\n"); LOGE("Error while decoding\n"); exit(1); } if (got_frame) { /* if a frame has been decoded, output it */ int data_size = av_get_bytes_per_sample(c - > sample_fmt); if (data_size < 0) { /* This should not occur, checking just for paranoia */ fprintf(stderr, "Failed to calculate data size\n"); LOGE("Failed to calculate data size\n"); exit(1); } if (data_size > 0) { jbyte * bytes = ( * env) - > GetByteArrayElements(env, array, NULL); memcpy(bytes, decoded_frame, got_frame); // ( * env) - > ReleaseByteArrayElements(env, array, bytes, 0); ( * env) - > CallVoidMethod(env, obj, play, array, got_frame); LOGE("DECODING ERROR5"); } } avpkt.size -= len; avpkt.data += len; avpkt.dts = avpkt.pts = AV_NOPTS_VALUE; if (avpkt.size < AUDIO_REFILL_THRESH) { /* Refill the input buffer, to avoid trying to decode * incomplete frames. Instead of this, one could also use * a parser, or use a proper container format through * libavformat. */ memmove(inbuf, avpkt.data, avpkt.size); avpkt.data = inbuf; len = fread(avpkt.data + avpkt.size, 1, AUDIO_INBUF_SIZE - avpkt.size, f); if (len > 0) avpkt.size += len; } } fclose(f); avcodec_free_context( & c); av_frame_free( & decoded_frame); }
The Java code :
package com.example.home.hellondk; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioTrack; import android.media.MediaPlayer; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class MainActivity extends AppCompatActivity { static { System.loadLibrary("MyLibraryPlayer"); } public native void createEngine(); public native void audio_decode_example(String outfilename, byte[] array); private AudioTrack track; private FileOutputStream os; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); createEngine(); /* MediaPlayer mp = new MediaPlayer(); mp.start();*/ int bufSize = AudioTrack.getMinBufferSize(32000, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT); track = new AudioTrack(AudioManager.STREAM_MUSIC, 32000, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT, bufSize, AudioTrack.MODE_STREAM); byte[] bytes = new byte[bufSize]; try { os = new FileOutputStream("/storage/emulated/0/Cloud Radio/a.out", false); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } audio_decode_example("/storage/emulated/0/Cloud Radio/test.mp3", bytes); } void playSound(byte[] buf, int size) { //android.util.Log.v("ROHAUPT", "RAH Playing"); if (track.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) track.play(); track.write(buf, 0, size); try { os.write(buf, 0, size); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
I always got this error : Error while decoding . i've tried to change the decoder "AV_CODEC_ID_MP3" no sucess ! Thank you so much for your help. Kind regards