#3107(undetermined:new): Problem using muxing example
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Type: defect Status: new | Priority: normal Component: | Version: undetermined | unspecified Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Summary of the bug: I am having issues using muxing example provided with the ffpmeg version ffmpeg-20131026-git-c78a416-win32-dev When i use it to generate 1. .mpg i get following error muxing.exe test.mpg [mp2 @ 004462a0] Specified sample format fltp is invalid or not supported Could not open audio codec: Error number -22 occurred 2. mp4 i get following error muxing.exe test.mp4 [libx264 @ 00613280] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64 [libx264 @ 00613280] profile High, level 1.3 [libx264 @ 00613280] 264 - core 138 r2358 9e941d1 - H.264/MPEG-4 AVC codec - Cop yleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deb lock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 m e_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro ma_qp_offset=-2 threads=3 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=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=12 keyint_min=1 scenecut =40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=400 ratetol=1.0 qcom p=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 [libvo_aacenc @ 00614040] Specified sample format fltp is invalid or not support ed Could not open audio codec: Error number -22 occurred It seems like error is coming from avcodec_open2() in open_audio() Please let me know if i am missing something or i need to set something else to make it work How to reproduce: {{{ % muxing.exe test.mpg ffmpeg version ffmpeg-20131026-git-c78a416-win32-dev built on Windows using MSVC 2012 }}} Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): I was wondering if anybody get a chance to review this issue # 3107 Please let me know 1. if I am not setting somthing for the proper functioning of the mux sample code 2. if there is a work around for this issue Appriciate your help -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:1> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by easonic): Hi, ahsan Um, I came across the same problem, too. It seemed that the ffmpeg I was using didn't support the AV_SAMPLE_FMT_FLTP (I used the windows version though), which is planar float. I changed my mux example in open_audio function, by assigning '''c->sample_fmt = AV_SAMPLE_FMT_S16;''' you can always change the sample format I bet~ -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:2> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): Thx Easonic! In my case audio_codec->sample_fmt is already set to AV_SAMPLE_FMT_S16 and i get this error -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:3> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by easonic): I guess you need to modify the '''/* create resampler context */''' one to get the resampler context; I made the '''if (c->sample_fmt == AV_SAMPLE_FMT_S16)''' change for the audio~ Replying to [comment:3 ahsan]:
Thx Easonic!
In my case audio_codec->sample_fmt is already set to AV_SAMPLE_FMT_S16 and i get this error
-- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:4> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): I made two changes 1. add_stream() changed c->sample_fmt from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16 2. open_audio() changed if(c->sample_fmt != AV_SAMPLE_FMT_S16) to if(c->sample_fmt == AV_SAMPLE_FMT_S16) it is not failing any more in open_audio, I will try it out and see if the change can work Thanks -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:5> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by easonic): That's exactly the two changes, good luck~ Replying to [comment:5 ahsan]:
I made two changes 1. add_stream() changed c->sample_fmt from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16 2. open_audio() changed if(c->sample_fmt != AV_SAMPLE_FMT_S16) to if(c->sample_fmt == AV_SAMPLE_FMT_S16) it is not failing any more in open_audio,
I will try it out and see if the change can work
Thanks
-- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:6> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): Above solution seems to get synthetic audio in the stream from muxing application, thx for your help I am still having an issue where i am trying to 1. demux the .mp4 using demuxing example and then 2. mux it using muxing application in the demux i have decoded data in frame->extended_data buffer with the size of unpadded_linesize = frame->nb_symbols*frame->format where nb_symbols=1024, format=8, it is 8k of data in the muxing example the audio buffer is filled up using nb_symbols=1024 and nb_channel=2 I am not sure how to map 8k data into the muxing buffer, i have couple of questions 1. how can i map this decoded buffer [demuxing example] to the emcoder buffer [muxing example] 2. Is it possible to not decode the audio samples and just mux the audio sample after getting it from the demux Please let me know if there is a sample example for that available Really appriciate your help -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:7> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): i did an experiment where i used orig_pkt from demuxing example when it is audio packet interleaved it bypassing the encoding of the decoded audio in muxing example I can now hear the correct sound during the playback but it is not sync at all, i guess some kind of a/v sync logic is needed, any ideas? -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:8> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by easonic): I'm also doing the remuxing stuff now; let's keep in touch. I will do that part during weekend, now I'm handling the video part by extracting the '''AVPacket.data''' and encapsulate into NALUs...lol Replying to [comment:8 ahsan]:
i did an experiment where i used
orig_pkt from demuxing example when it is audio packet interleaved it bypassing the encoding of the decoded audio in muxing example
I can now hear the correct sound during the playback but it is not sync at all, i guess some kind of a/v sync logic is needed, any ideas?
-- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:9> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): I merged, demux and mux example codes so that i can take in any .mp4/.avi/mpg files and then re-encode them in the same format I am having following issues 1. MUX example code uses avformat_alloc_output_context2() to create the output context for example for .mpg it will choose MPEG1 encoder, the .mpg file i used is encoded using MPEG2 encoder. I was wondering how can i select different encoders, is there any API call which i can use to re-set the encoder name in the context encoder fails 2. I uses the fmt_ctx from decoder to set the encoder parameters, i try to memcpy the context (decoder to encoder for the codec) but it fails by setting the different parameters from fmt_ctx to the c c->width = fmt_ctx->streams[video_stream_idx]->codec->width; c->height = fmt_ctx->streams[video_stream_idx]->codec->height; c->coded_width = fmt_ctx->streams[video_stream_idx]->codec>coded_width; ........................ c->gop_size = fmt_ctx->streams[video_stream_idx]->codec->gop_size; /* emit one intra frame every twelve frames at most */ c->bit_rate = (fmt_ctx->streams[video_stream_idx]->codec->bit_rate == 0) ? 400000 : fmt_ctx->streams[video_stream_idx]->codec->bit_rate; /* i am seting it to 400kbps in case it is set to 0 as i am seeing it for some stream */ ........................ I am seeing different issue 1. GOP Size fmt_ctx most of the time has gop_size = 12 which does not seems like the case for the original/input stream 2. bit-rate i am getting in the output .mp4 is way higher then the one i see from the fmt_ctx, it seems like encoded bit-stream is in 50Mbits/sec where as input .mp4 was 300kbps or 400kbps bit-rate I am wondering what is the best way to set the encoder context using the input bitstream [.mp4, .avi, .mpg etc] files Please let me know if you are able to figure it out -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:10> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by easonic): Replying to [comment:10 ahsan]:
I merged, demux and mux example codes so that i can take in any .mp4/.avi/mpg files and then re-encode them in the same format
I am having following issues
1. MUX example code uses avformat_alloc_output_context2() to create the output context for example for .mpg it will choose MPEG1 encoder, the .mpg file i used is encoded using MPEG2 encoder.
I was wondering how can i select different encoders, is there any API call which i can use to re-set the encoder name in the context encoder fails
2. I uses the fmt_ctx from decoder to set the encoder parameters, i try to memcpy the context (decoder to encoder for the codec) but it fails by setting the different parameters from fmt_ctx to the c
c->width = fmt_ctx->streams[video_stream_idx]->codec->width; c->height = fmt_ctx->streams[video_stream_idx]->codec->height; c->coded_width = fmt_ctx->streams[video_stream_idx]->codec>coded_width; ........................ c->gop_size = fmt_ctx->streams[video_stream_idx]->codec->gop_size; /* emit one intra frame every twelve frames at most */
c->bit_rate = (fmt_ctx->streams[video_stream_idx]->codec->bit_rate == 0) ? 400000 : fmt_ctx->streams[video_stream_idx]->codec->bit_rate; /* i am seting it to 400kbps in case it is set to 0 as i am seeing it for some stream */
........................
I am seeing different issue
1. GOP Size fmt_ctx most of the time has gop_size = 12 which does not seems like the case for the original/input stream
2. bit-rate i am getting in the output .mp4 is way higher then the one i see from the fmt_ctx, it seems like encoded bit-stream is in 50Mbits/sec where as input .mp4 was 300kbps or 400kbps bit-rate
I am wondering what is the best way to set the encoder context using the input bitstream [.mp4, .avi, .mpg etc] files
Please let me know if you are able to figure it out
Hi, ahsan Sorry for the delay, really busy for the project. Um, do you resolve that issue? I met maybe the same problem here, what I did was just: '''avcodec_copy_context(vStream->codec, inFormatCtx->streams[video_idx]->codec);''' but found that the '''output avformatcontext''' complains about the codec_tag. Thus, I traced the problem, found that after '''avformat_write_header(outFmtCtx, NULL);''', some parameter in the '''output avformatcontext->streams[video]->codec''' will change; thus I set the parameter to zero before '''avformat_write_header(outFmtCtx, NULL);''' and that works. For my experiment, I found that to get the correct duration and time_base (you can treat it as after parsing the codeccontext parameter), I need to set videostream's codec to: ''/* * IMPORTANT!!! Set the stream->codec information: * Copy all the CodecFormat info except the time_base and codec_tag * video_stream->codec->time_base: set to inputFmtCtx->vStream->time_base * video only! * video_stream->codec->codec_tag: calculate by av_write_header * video_stream->codec->flags : set global if the output format need * global **/'' Um, and for audio, just skip the time_base part, and it works for me, too. If you need my code (what I was doing was to remux files without reencoding.), I will email to you later~ -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/3107#comment:11> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | Status: new Priority: normal | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 0 -------------------------------------+------------------------------------- Comment (by ahsan): Hi easonic, I am still having the issues where output frame rate, bit rate, codec fields has issues, Please see if you can send me you remux - re encoding sample code I will appreciate that Regards Ahsan -- Ticket URL: <https://trac.ffmpeg.org/ticket/3107#comment:12> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | er.anshul.maheshwari@… Priority: normal | Status: open Version: git-master | Component: avcodec Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 0 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Changes (by er.anshul.maheshwari@…): * status: new => open * reproduced: 0 => 1 * cc: er.anshul.maheshwari@… (added) * component: undetermined => avcodec * version: unspecified => git-master * owner: => er.anshul.maheshwari@… -- Ticket URL: <https://trac.ffmpeg.org/ticket/3107#comment:13> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | er.anshul.maheshwari@… Priority: normal | Status: closed Version: git-master | Component: Keywords: | undetermined Blocking: | Resolution: invalid Analyzed by developer: 0 | Blocked By: | Reproduced by developer: 0 -------------------------------------+------------------------------------- Changes (by cehoyos): * status: open => closed * resolution: => invalid * component: avcodec => undetermined * reproduced: 1 => 0 Comment: Please move this discussion to the libav-devel mailing list, this is a bug tracker, not a support forum. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3107#comment:14> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | er.anshul.maheshwari@… Priority: normal | Status: closed Version: git-master | Component: Keywords: | documentation Blocking: | Resolution: invalid Analyzed by developer: 1 | Blocked By: | Reproduced by developer: 0 -------------------------------------+------------------------------------- Changes (by saste): * analyzed: 0 => 1 * component: undetermined => documentation Comment: Replying to [comment:1 ahsan]:
I was wondering if anybody get a chance to review this issue # 3107
Please let me know 1. if I am not setting somthing for the proper functioning of the mux sample code 2. if there is a work around for this issue
Appriciate your help
This was fixed in: {{{ commit 2aa2b4ac6555bb4af3f3542c88e7710eca1a57c0 Author: Stefano Sabatini <stefasab@gmail.com> Date: Tue Jul 2 16:28:47 2013 +0200 examples/muxing: add support to audio resampling Allows to encode to output in case the destination sample format is different from AV_SAMPLE_FMT_S16. }}} and in the following commits. Also the error message you got was pretty explicit in my opinion. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3107#comment:15> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3107: Problem using muxing example -------------------------------------+------------------------------------- Reporter: ahsan | Owner: Type: defect | er.anshul.maheshwari@… Priority: minor | Status: closed Version: git-master | Component: Keywords: | documentation Blocking: | Resolution: fixed Analyzed by developer: 1 | Blocked By: | Reproduced by developer: 0 -------------------------------------+------------------------------------- Changes (by cehoyos): * priority: normal => minor * resolution: invalid => fixed -- Ticket URL: <https://trac.ffmpeg.org/ticket/3107#comment:16> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg