
Recherche avancée
Médias (1)
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
Autres articles (58)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Librairies et binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...) -
Utilisation et configuration du script
19 janvier 2011, parInformations spécifiques à la distribution Debian
Si vous utilisez cette distribution, vous devrez activer les dépôts "debian-multimedia" comme expliqué ici :
Depuis la version 0.3.1 du script, le dépôt peut être automatiquement activé à la suite d’une question.
Récupération du script
Le script d’installation peut être récupéré de deux manières différentes.
Via svn en utilisant la commande pour récupérer le code source à jour :
svn co (...)
Sur d’autres sites (10937)
-
How to use audio frame after decode mp3 file using pyav, ffmpeg, python
2 janvier 2021, par Long Tran DaiI am using using python with pyav, ffmpeg to decode mp3 in the memory. I know there are some other way to do it, like pipe ffmpeg command. However, I would like to explore pyav and ffmpeg API. So I have the following code. It works but the sound is very noisy, although hearable :


import numpy as np
import av # to convert mp3 to wav using ffmpeg
import pyaudio # to play music

mp3_path = 'D:/MyProg/python/SauTimThiepHong.mp3'

def decodeStream(mp3_path):
 # Run NOT OK
 
 container = av.open(mp3_path)
 stream = next(s for s in container.streams if s.type == 'audio')
 frame_count = 0
 data = bytearray()
 for packet in container.demux(stream):
 # <class>
 # We need to skip the "flushing" packets that `demux` generates.
 #if frame_count == 5000 : break 
 if packet.dts is None:
 continue
 for frame in packet.decode(): 
 #
 # type(frame) : <class>
 #frame.samples = 1152 : 1152 diem du lieu : Number of audio samples (per channel)
 # moi frame co size = 1152 (diem) * 2 (channels) * 4 (bytes / diem) = 9216 bytes
 # 11021 frames
 #arr = frame.to_ndarray() # arr.nbytes = 9216

 #channels = [] 
 channels = frame.to_ndarray().astype("float16")
 #for plane in frame.planes:
 #channels.append(plane.to_bytes()) #plane has 4 bytes / sample, but audio has only 2 bytes
 # channels.append(np.frombuffer(plane, dtype=np.single).astype("float16"))
 #channels.append(np.frombuffer(plane, dtype=np.single)) # kieu np.single co 4 bytes
 if not frame.is_corrupt:
 #data.extend(np.frombuffer(frame.planes[0], dtype=np.single).astype("float16")) # 1 channel: noisy
 # type(planes) : <class>
 frame_count += 1
 #print( '>>>> %04d' % frame_count, frame) 
 #if frame_count == 5000 : break 
 # mix channels:
 for i in range(frame.samples): 
 for ch in channels: # dec_ctx->channels
 data.extend(ch[i]) #noisy
 #fwrite(frame->data[ch] + data_size*i, 1, data_size, outfile)
 return bytes(data)
</class></class></class>


I use pipe ffmpeg to get decoded data to compare and find they are different :


def RunFFMPEG(mp3_path, target_fs = "44100"):
 # Run OK
 import subprocess
 # init command
 ffmpeg_command = ["ffmpeg", "-i", mp3_path,
 "-ab", "128k", "-acodec", "pcm_s16le", "-ac", "0", "-ar", target_fs, "-map",
 "0:a", "-map_metadata", "-1", "-sn", "-vn", "-y",
 "-f", "wav", "pipe:1"]
 # excute ffmpeg command
 pipe = subprocess.run(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize= 10**8)
 # debug
 #print(pipe.stdout, pipe.stderr)
 # read signal as numpy array and assign sampling rate
 #audio_np = np.frombuffer(buffer=pipe.stdout, dtype=np.uint16, offset=44)
 #audio_np = np.frombuffer(buffer=pipe.stdout, dtype=np.uint16)
 #sig, fs = audio_np, target_fs
 #return audio_np
 return pipe.stdout[78:] 



Then I use pyaudio to play data and find it very noisy


p = pyaudio.PyAudio()
streamOut = p.open(format=pyaudio.paInt16, channels=2, rate= 44100, output=True)
#streamOut = p.open(format=pyaudio.paInt16, channels=1, rate= 44100, output=True)

mydata = decodeStream(mp3_path)
print("bytes of mydata = ", len(mydata))
#print("bytes of mydata = ", mydata.nbytes)

ffMpegdata = RunFFMPEG(mp3_path)
print("bytes of ffMpegdata = ", len(ffMpegdata)) 
#print("bytes of ffMpegdata = ", ffMpegdata.nbytes)

minlen = min(len(mydata), len(ffMpegdata))
print("mydata == ffMpegdata", mydata[:minlen] == ffMpegdata[:minlen]) # ffMpegdata.tobytes()[:minlen] )

#bytes of mydata = 50784768
#bytes of ffMpegdata = 50784768
#mydata == ffMpegdata False

streamOut.write(mydata)
streamOut.write(ffMpegdata)
streamOut.stop_stream()
streamOut.close()
p.terminate()



Please help me to understand decoded frame of pyav api (after for frame in packet.decode() :). Should it be processed more ? or I have some error ?


It makes me crazy for 3 days. I could not guess where to go.


Thank you very much.


-
Invalid data found when processing input
22 novembre 2012, par user1726619I want to use ffmpeg lib in my library.For that purpose,i have successfully compiled it.The input video is otherwise running fine,but when i try to execute any command,i am getting this message :
Invalid data found when processing input.
I don't know whats the reason behind it.This is the code :
public class Videokit extends Activity {
String FilePath;
String OutPut;
Context mycontext;
Videokit vk ;
static
{
System.loadLibrary("videokit");
}
public native void run(String[] args);
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FilePath =Environment.getExternalStorageDirectory().toString()+"/output.3gp";
try {
ffmpegrun();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String ffmpegrun() throws IOException
{
boolean success=false;
File folder = new File(Environment.getExternalStorageDirectory().toString() + "/image-%3d.jpeg");
File file = new File(FilePath);
System.out.println("filepath exists at:"+file.getAbsolutePath());
if (!folder.exists()) {
success = folder.mkdirs();
// Toast.makeText(mycontext,"outfile.mp4 exists at"+folder.getAbsolutePath(),Toast.LENGTH_LONG).show();
OutPut = folder.getAbsolutePath();
}
System.out.println("outfile.flv exists at:"+folder.getAbsolutePath());
run(new String[]{
"ffmpeg",
"-i",
FilePath,
"-r 1",
"-f",
"image2",
"image-%3d.jpeg"
});
return OutPut;
}
}This is the log :
10-07 17:00:03.707: D/dalvikvm(8760): Trying to load lib /data/data/uk.co.halfninja.videokit/lib/libvideokit.so 0x44e8c958
10-07 17:00:03.837: D/dalvikvm(8760): Added shared lib /data/data/uk.co.halfninja.videokit/lib/libvideokit.so 0x44e8c958
10-07 17:00:03.837: I/Videokit(8760): Loading native library compiled at 13:52:27 Oct 7 2012
10-07 17:00:03.917: I/System.out(8760): filepath exists at:/sdcard/output.3gp
10-07 17:00:03.917: I/System.out(8760): outfile.flv exists at:/sdcard/image-%3d.jpeg
10-07 17:00:03.917: D/dalvikvm(8760): +++ not scanning '/system/lib/libwebcore.so' for 'run' (wrong CL)
10-07 17:00:03.917: D/dalvikvm(8760): +++ not scanning '/system/lib/libmedia_jni.so' for 'run' (wrong CL)
10-07 17:00:03.928: D/dalvikvm(8760): +++ not scanning '/system/lib/libexif.so' for 'run' (wrong CL)
10-07 17:00:03.928: D/Videokit(8760): run() called
10-07 17:00:03.928: D/Videokit(8760): run passing off to main()
10-07 17:00:03.928: D/Videokit(8760): main(): registering all modules
10-07 17:00:03.938: D/Videokit(8760): main(): registered everything
10-07 17:00:03.938: D/Videokit(8760): main(): initting opts
10-07 17:00:03.968: D/Videokit(8760): main(): initted opts.
10-07 17:00:03.968: E/Videokit(8760): ffmpeg version N-30996-gf925b24, Copyright (c) 2000-2011 the FFmpeg developers
10-07 17:00:03.979: E/Videokit(8760): built on Oct 7 2012 13:52:32 with gcc 4.4.3
10-07 17:00:03.979: E/Videokit(8760): configuration: --enable-cross-compile --arch=arm5te --enable-armv5te --target-os=linux --disable-stripping --prefix=../output --disable-neon --enable-version3 --disable-shared --enable-static --enable-gpl --enable-memalign-hack --cc=arm-linux-androideabi-gcc --ld=arm-linux-androideabi-ld --extra-cflags='-fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated' --disable-everything --enable-decoder=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg --enable-demuxer=image2 --enable-muxer=mp4 --enable-encoder=libx264 --enable-libx264 --enable-decoder=rawvideo --enable-protocol=file --enable-hwaccels --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-filter=buffer --enable-filter=buffersink --disable-demuxer=v4l --disable-demuxer=v4l2 --disable-indev=v4l --disable-indev=v4l2 --extra-cflags='-I../x264 -Ivideokit' --extra-ldflags=-L../x264
10-07 17:00:03.987: D/Videokit(8760): main(): parsing options
10-07 17:00:03.987: D/Videokit(8760): parse_options has 7 options to parse
10-07 17:00:04.050: E/Videokit(8760): /sdcard/output.3gp: Invalid data found when processing input
10-07 17:00:04.050: E/Videokit(8760): ffmpeg_exit(1) called!Please help me.I am clueless about this problem.Thanks in advance.
-
EXC_BAD_ACCESS at avformat_find_stream_info in FFMPEG
27 décembre 2018, par Mubin MallI achieved IP Camera streaming using ffmpeg with the help of this library : https://github.com/kolyvan/kxmovie also I am recording IPCamera streaming coming and same is done using ffmpeg.
Now I am facing one issue as soon as I add R5ProStreaming.framework in project and run application in real device application is getting crashed at
if (avformat_find_stream_info(formatCtx, NULL) < 0)
here.
And when I remove that framework and move it to trash and run again then all working fine.- (kxMovieError) openInput: (NSString *) path
{
AVFormatContext *formatCtx = NULL;
if (_interruptCallback) {
formatCtx = avformat_alloc_context();
if (!formatCtx)
return kxMovieErrorOpenFile;
AVIOInterruptCB cb = {interrupt_callback, (__bridge void *)(self)};
formatCtx->interrupt_callback = cb;
}
AVDictionary *opts = 0;
//
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
if (avformat_open_input(&formatCtx, [path cStringUsingEncoding: NSUTF8StringEncoding], NULL, &opts) < 0) {
av_log(NULL, AV_LOG_ERROR, "Couldn't open file\n");
return kxMovieErrorStreamInfoNotFound;
}
if (avformat_open_input(&formatCtx, [path cStringUsingEncoding: NSUTF8StringEncoding], NULL, NULL) < 0) {
if (formatCtx)
avformat_free_context(formatCtx);
return kxMovieErrorOpenFile;
}
//-----APP IS GETTING CRASHED HERE AND GIVING EXC_BAD_ACCESS---//
if (avformat_find_stream_info(formatCtx, NULL) < 0)
{
avformat_close_input(&formatCtx);
return kxMovieErrorStreamInfoNotFound;
}
//
av_dump_format(formatCtx, 0, [path.lastPathComponent cStringUsingEncoding: NSUTF8StringEncoding], false);
_formatCtx = formatCtx;
inputFormatCtx = _formatCtx;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"newdemo" ofType:@".mov"];
if (filePath)
{
NSLog(@"%s - %d # File found", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # File NOT found", __PRETTY_FUNCTION__, __LINE__);
}
/*
* av_find_input_format(const char *short_name)
*
* Find AVInputFormat based on the short name of the input format.
*/
AVInputFormat *inputFormat = av_find_input_format([@"mpeg" UTF8String]);
if (inputFormat)
{
NSLog(@"%s - %d # inputFormat identifed", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # inputFormat NOT identifed", __PRETTY_FUNCTION__, __LINE__) ;
}
const char *utf8FilePath = [filePath UTF8String];
NSLog(@"%s - %d # utf8FilePath = %s", __PRETTY_FUNCTION__, __LINE__, utf8FilePath);
/*
* avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
*
* Open an input stream and read the header. The codecs are not opened.
*/
int openInputValue =0;
NSLog(@"%s - %d # openInputValue = %d", __PRETTY_FUNCTION__, __LINE__, openInputValue);
if (openInputValue == 0)
{
NSLog(@"%s - %d # Can open the file", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # Cannot open the file", __PRETTY_FUNCTION__, __LINE__);
avformat_close_input(&inputFormatCtx);
}
/*
* Read packets of a media file to get stream information.
*
* avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
*/
// int streamInfoValue = avformat_find_stream_info(inputFormatCtx, NULL);
// NSLog(@"%s - %d # streamInfoValue = %d", __PRETTY_FUNCTION__, __LINE__, streamInfoValue);
//
// if (streamInfoValue < 0)
// {
// NSLog(@"%s - %d # streamInfoValue Error", __PRETTY_FUNCTION__, __LINE__);
// avformat_close_input(&inputFormatCtx);
// }
/*
* nb_streams : Number of Audio and Video streams of the input file
*/
NSUInteger inputStreamCount = inputFormatCtx->nb_streams;
NSLog(@"%s - %d # inputStreamCount = %lu", __PRETTY_FUNCTION__, __LINE__, (unsigned long)inputStreamCount);
for(unsigned int i = 0; istreams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
{
NSLog(@"%s - %d # Found Video Stream", __PRETTY_FUNCTION__, __LINE__);
inputVideoStreamIndex = i;
inputVideoStream = inputFormatCtx->streams[i];
}
if(inputFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
{
NSLog(@"%s - %d # Found Audio Stream", __PRETTY_FUNCTION__, __LINE__);
inputAudioStreamIndex = i;
inputAudioStream = inputFormatCtx->streams[i];
}
}
if(inputVideoStreamIndex == -1 && inputAudioStreamIndex == -1)
{
NSLog(@"%s - %d # Have not found any Video or Audio stream", __PRETTY_FUNCTION__, __LINE__);
}
/*
* Finding duration of the stream
*/
if(inputFormatCtx->duration == AV_NOPTS_VALUE)
{
NSLog(@"%s - %d # Undefined timestamp value", __PRETTY_FUNCTION__, __LINE__);
if(_videoStream != -1 && inputFormatCtx->streams[_videoStream])
{
// if(inputFormatCtx->streams[_videoStream]->duration != AV_NOPTS_VALUE)
// {
inputEndtimeInt64 = (inputFormatCtx->streams[_videoStream]->duration)/(inputFormatCtx->streams[_videoStream]->time_base.den/inputFormatCtx->streams[_videoStream]->time_base.num);
// }
// else
// {
// inputEndtimeInt64 = (inputFormatCtx->duration)/(AV_TIME_BASE);
//
// }
}
else if(_audioStream != -1 && inputFormatCtx->streams[_audioStream])
{
// if(inputFormatCtx->streams[_audioStream]->duration != AV_NOPTS_VALUE)
// {
inputEndtimeInt64 = (inputFormatCtx->streams[_audioStream]->duration)/(AV_TIME_BASE);
// }
// else
// {
// inputEndtimeInt64 = (inputFormatCtx->duration)/(AV_TIME_BASE);
//
// }
}
}
else
{
NSLog(@"%s - %d # Defined timestamp value", __PRETTY_FUNCTION__, __LINE__);
inputEndtimeInt64 = (inputFormatCtx->duration)/(AV_TIME_BASE);
}
NSLog(@"%s - %d # inputEndtimeInt64 = %lld", __PRETTY_FUNCTION__, __LINE__, inputEndtimeInt64);
/*
* Finding out the frame rate
*/
if(_videoStream != -1 && inputFormatCtx->streams[_videoStream])
{
framesPerSec = (inputFormatCtx->streams[_videoStream]->r_frame_rate.num)/ (inputFormatCtx->streams[_videoStream]->r_frame_rate.den);
}
else
{
framesPerSec = 24;
}
numberOfFrames = framesPerSec * (int) inputEndtimeInt64;
NSLog(@"%s - %d # numberOfFrames = %d", __PRETTY_FUNCTION__, __LINE__, numberOfFrames);
/*
* Seek to timestamp ts.
*
* avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
*/
if(avformat_seek_file(inputFormatCtx, inputAudioStreamIndex, INT64_MIN, outputStartTimeInt64, INT64_MAX, AVSEEK_FLAG_FRAME) < 0)
{
NSLog(@"%s - %d # Seek OK", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # Seek ERROR", __PRETTY_FUNCTION__, __LINE__);
}
/*
* Creating output file path1
*/
// NSString * timestamp = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970] * 1000];
//
// NSArray *directoryPathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// NSString *documentsDirectory = [directoryPathsArray objectAtIndex:0];
// NSString *outputFilePath = [NSString stringWithFormat:@"%@/%@.mov",documentsDirectory,timestamp]; // Not working if we replace .avi with .mp4
NSString* filename = [NSString stringWithFormat:@"IPCamera%d.mov", _currentFile];
NSString* outputFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:filename];
_url = [NSURL fileURLWithPath:outputFilePath];
/*
* Return the output format in the list of registered output formats
* which best matches the provided parameters, or return NULL if
* there is no match.
*
* av_guess_format(const char *short_name, const char *filename, const char *mime_type)
*/
outputFormat = av_guess_format(NULL, [outputFilePath UTF8String], NULL);
NSLog(@"%s - %d # outputFormat->name = %s", __PRETTY_FUNCTION__, __LINE__, outputFormat->name);
if(outputFormat == NULL)
{
NSLog(@"%s - %d # outputFormat == NULL", __PRETTY_FUNCTION__, __LINE__);
}
else
{
/*
* Allocate an AVFormatContext.
*/
outputContext = avformat_alloc_context();
if(outputContext)
{
outputContext->oformat = outputFormat; // The output container format.
snprintf(outputContext->filename, sizeof(outputContext->filename), "%s", [outputFilePath UTF8String]);
}
else
{
NSLog(@"%s - %d # outputContext == NULL", __PRETTY_FUNCTION__, __LINE__);
}
}
outputVideoCodec = outputAudioCodec = NULL;
/*
* video_codec = default video codec
*/
if(outputFormat->video_codec != AV_CODEC_ID_NONE && inputVideoStream != NULL)
{
/*
* Find a registered encoder with a matching codec ID.
*
* avcodec_find_encoder(enum AVCodecID id)
*/
outputVideoCodec = avcodec_find_encoder(outputFormat->video_codec);
if(NULL == outputVideoCodec)
{
NSLog(@"%s - %d # Could Not Find Vid Encoder", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # Found Out Vid Encoder", __PRETTY_FUNCTION__, __LINE__);
/*
* Add a new stream to a media file.
*
* avformat_new_stream(AVFormatContext *s, const AVCodec *c)
*/
outputVideoStream = avformat_new_stream(outputContext, outputVideoCodec);
if(NULL == outputVideoStream)
{
NSLog(@"%s - %d # Failed to Allocate Output Vid Strm", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # Allocated Video Stream", __PRETTY_FUNCTION__, __LINE__);
/*
* Copy the settings of the source AVCodecContext into the destination AVCodecContext.
*
* avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
*/
if(avcodec_copy_context(outputVideoStream->codec, inputFormatCtx->streams[inputVideoStreamIndex]->codec) != 0)
{
NSLog(@"%s - %d # Failed to Copy Context", __PRETTY_FUNCTION__, __LINE__);
}
else
{
AVStream *st = _formatCtx->streams[_videoStream];
outputVideoStream->sample_aspect_ratio.den = outputVideoStream->codec->sample_aspect_ratio.den; // denominator
outputVideoStream->sample_aspect_ratio.num = st->codec->sample_aspect_ratio.num; // numerator
NSLog(@"%s - %d # Copied Context 1", __PRETTY_FUNCTION__, __LINE__);
outputVideoStream->codec->codec_id = st->codec->codec_id;
outputVideoStream->codec->time_base.num = st->codec->time_base.num;
outputVideoStream->codec->time_base.den = STREAM_FRAME_RATE;
outputVideoStream->time_base.num = st->time_base.num;
outputVideoStream->time_base.den = st->time_base.den;
outputVideoStream->r_frame_rate.num =st->r_frame_rate.num;
outputVideoStream->nb_frames = STREAM_NB_FRAMES;
outputVideoStream->r_frame_rate.den = st->r_frame_rate.den;
outputVideoStream->avg_frame_rate.den = st->avg_frame_rate.num;
outputVideoStream->avg_frame_rate.num = st->avg_frame_rate.num;
// outputVideoStream->duration = st->duration;
}
}
}
}
if(outputFormat->audio_codec != AV_CODEC_ID_NONE && inputAudioStream != NULL)
{
outputAudioCodec = avcodec_find_encoder(outputFormat->audio_codec);
if(NULL == outputAudioCodec)
{
NSLog(@"%s - %d # Could Not Find Out Aud Encoder", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # Found Out Aud Encoder", __PRETTY_FUNCTION__, __LINE__);
outputAudioStream = avformat_new_stream(outputContext, outputAudioCodec);
if(NULL == outputAudioStream)
{
NSLog(@"%s - %d # Failed to Allocate Out Vid Strm", __PRETTY_FUNCTION__, __LINE__);
}
else
{
if(avcodec_copy_context(outputAudioStream->codec, inputFormatCtx->streams[inputAudioStreamIndex]->codec) != 0)
{
NSLog(@"%s - %d # Failed to Copy Context", __PRETTY_FUNCTION__, __LINE__);
}
else
{
// AVStream *st = _formatCtx->streams[_audioStream];
NSLog(@"%s - %d # Copied Context 2", __PRETTY_FUNCTION__, __LINE__);
outputAudioStream->codec->codec_id = inputAudioStream->codec->codec_id;
outputAudioStream->codec->codec_tag = 0;
// outputAudioStream->pts = inputAudioStream->pts;
// outputAudioStream->duration = inputAudioStream->duration;
outputAudioStream->time_base.num = inputAudioStream->time_base.num;
outputAudioStream->time_base.den = inputAudioStream->time_base.den;
}
}
}
}
if (!(outputFormat->flags & AVFMT_NOFILE))
{
/*
* Create and initialize a AVIOContext for accessing the resource indicated by url.
*
* avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
*/
if (avio_open2(&outputContext->pb, [outputFilePath UTF8String], AVIO_FLAG_WRITE, NULL, NULL) < 0)
{
NSLog(@"%s - %d # Could Not Open File", __PRETTY_FUNCTION__, __LINE__);
}
}
/* Write the stream header, if any. */
/*
* Allocate the stream private data and write the stream header to an output media file.
*
* avformat_write_header(AVFormatContext *s, AVDictionary **options);
*/
if (avformat_write_header(outputContext, NULL) < 0)
{
NSLog(@"%s - %d # Error Occurred While Writing Header", __PRETTY_FUNCTION__, __LINE__);
}
else
{
NSLog(@"%s - %d # Written Output header", __PRETTY_FUNCTION__, __LINE__);
initDone = true;
}
return kxMovieErrorNone;
}More over I contacted Red5Pro team and asked them regarding that along with video demo. They replied me like this
What’s most likely happening is that the version of FFMPEG that’s being loaded by that project is incompatible with the customized version of it that’s embedded in our SDK, and some duplicate definition error is causing the wrong version to be loaded. It could also be any number of conflicts between one of the libraries in that project with the SDK, or one of the support libraries that the sdk requires ( I have to assume that since it compiled, that you did add the libraries listed in step four here : https://www.red5pro.com/docs/streaming/ios.html#project-setup ) and if that’s the case, I don’t know of a good way to correct the issue as chasing down individual third-party libraries that raise incompatibilities with our SDKs to correct them is beyond the reach of our team. (edited)
Can anybody have idea where to look ?
Thanks