Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
iOS - Convert Audio Format (opus to mp3)
30 mai 2017, par Android0077Recently I started to develop application that work with .opus file (Audio Format).
I am working with external SDK that can processor a mp3/wav file, unfortunately my local file is a .opus file and I need to convert it to mp3/wav format in order to process the file.
I read and research a lot around the network to find a solution, I found the FFmpegWrapper library that can convert two type of Audio Format but when I try to convert .opus to .mp3/ , I get this error: opus codec not supported in WAVE format I do not know what can be done, I'll be happy to help.
Any information about how to convert .Opus format to any other format will be appreciated.
Thanks
-
Ffmpeg alpha from udp input
30 mai 2017, par Bob RossI'm trying to stream a video that is composed from a base video and an overlay video with an alpha channel.
I receive both of the incoming input streams as udp inputs so I can change them at runtime.
The problem is that when I use avi as the format for the overlay stream i get this error:
udp://127.0.0.1:${port2}: Invalid data found when processing input
and when I use mpegts as the format for the overlay stream I get this error:
Stream specifier ':v' in filtergraph description [0:v][1:v]overlay=format=rgb matches no streams
The main ffmpeg command:
ffmpeg -re -i udp://127.0.0.1:${port1} -vcodec qtrle -i udp://127.0.0.1:${port2} -s 854x480 -filter_complex [0:v][1:v]overlay=format=rgb -c:v libx264 -preset ultrafast -f flv ${output}
The base stream:
ffmpeg -re -i ${hls_source} -c:v libx264 -vf scale=854:480 -f mpegts udp://127.0.0.1:${port1}
The overlay stream with alpha channel:
ffmpeg -re -i z.mov -vcodec qtrle -f avi udp://127.0.0.1:${port2}
It's worth noting that when I switch one of the udp inputs with a recorded file, It does work.
-
ffmpeg android issues reading frame
30 mai 2017, par DweebsUnitedI am using FFMPEG on android (compiled using this as a reference). I can open a file, read its stream info, and get set up to remux it perfectly. On the first call to av_read_frame however, ffmpeg errors with "Invalid data found while processing input". When I try to enable logging, and redirect all of ffmpeg's logs to logcat, it prints a whole lot of garbled text, then crashes. Very helpful.
Is it possible something got messed up in compiling? It builds and links just fine, all calls work as expected (except logging). The video files I am testing with play fine in other media players, and I can work with them using ffmpeg command line on my host pc, but I cannot get ffmpeg on android to read any real data with them.
Code for reference:
// Build an ffmpeg call char path[512]; sprintf(path, "pipe:%d", fileno(fp)); // Turn on verbosity av_log_set_level( AV_LOG_DEBUG ); av_log_set_callback( avLogCallback ); av_register_all(); avcodec_register_all(); AVOutputFormat *ofmt = NULL; AVFormatContext *ifmt_ctx = avformat_alloc_context(), *ofmt_ctx = NULL; AVPacket pkt; int ret, i; if ((ret = avformat_open_input(&ifmt_ctx, path, av_find_input_format("mp4"), NULL)) < 0) { LOG( "Could not open input file '%s'", path); goto end; } if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) { LOG( "Failed to retrieve input stream information", ""); goto end; } avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename); if (!ofmt_ctx) { LOG( "Could not create output context\n"); ret = AVERROR_UNKNOWN; goto end; } ofmt = ofmt_ctx->oformat; for (i = 0; i < ifmt_ctx->nb_streams; i++) { AVStream *in_stream = ifmt_ctx->streams[i]; AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec); if (!out_stream) { LOG( "Failed allocating output stream\n"); goto end; } LOG( "Stream number %d", i); switch( in_stream->codecpar->codec_type ) { case AVMEDIA_TYPE_VIDEO: LOG( "Stream type VIDEO"); break; case AVMEDIA_TYPE_AUDIO: LOG( "Stream type AUDIO"); break; case AVMEDIA_TYPE_DATA: LOG( "Stream type DATA"); break; case AVMEDIA_TYPE_UNKNOWN: LOG( "Stream type UNKNOWN"); break; case AVMEDIA_TYPE_ATTACHMENT: LOG( "Stream type ATTACHMENT"); break; case AVMEDIA_TYPE_NB: LOG( "Stream type NB"); break; case AVMEDIA_TYPE_SUBTITLE: LOG( "Stream type SUBTITLE"); break; } ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar); if (ret < 0) { LOG( "Failed to copy context from input to output stream codec context\n"); goto end; } out_stream->codecpar->codec_tag = 0; } if (!(ofmt->flags & AVFMT_NOFILE)) { ret = avio_open(&ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE); if (ret < 0) { LOG( "Could not open output file '%s'", out_filename); goto end; } } ret = avformat_write_header(ofmt_ctx, NULL); if (ret < 0) { LOG( "Error occurred when opening output file\n"); goto end; } // int indexs[8] = {0}; // int64_t start_from = 8*AV_TIME_BASE; ret = av_seek_frame(ifmt_ctx, -1, from_seconds*AV_TIME_BASE, AVSEEK_FLAG_ANY); if (ret < 0) { LOG( "Error seek\n"); goto end; } int64_t *dts_start_from; int64_t *pts_start_from; dts_start_from = (int64_t *) malloc(sizeof(int64_t) * ifmt_ctx->nb_streams); memset(dts_start_from, 0, sizeof(int64_t) * ifmt_ctx->nb_streams); pts_start_from = (int64_t *) malloc(sizeof(int64_t) * ifmt_ctx->nb_streams); memset(pts_start_from, 0, sizeof(int64_t) * ifmt_ctx->nb_streams); while (1) { AVStream *in_stream, *out_stream; ret = av_read_frame(ifmt_ctx, &pkt); LOG( "while %d", ret); LOG( "Packet size: %d", pkt.size); LOG( "Packet stream: %d", pkt.stream_index); if (ret < 0) break; in_stream = ifmt_ctx->streams[pkt.stream_index]; out_stream = ofmt_ctx->streams[pkt.stream_index]; if (av_q2d(in_stream->time_base) * pkt.pts > end_seconds) { av_packet_unref(&pkt); break; } if (dts_start_from[pkt.stream_index] == 0) { dts_start_from[pkt.stream_index] = pkt.dts; printf("dts_start_from: %s\n", av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0},dts_start_from[pkt.stream_index])); } if (pts_start_from[pkt.stream_index] == 0) { pts_start_from[pkt.stream_index] = pkt.pts; printf("pts_start_from: %s\n", av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0},pts_start_from[pkt.stream_index])); } /* copy packet */ pkt.pts = ::av_rescale_q_rnd(pkt.pts - pts_start_from[pkt.stream_index], in_stream->time_base, out_stream->time_base, (AVRounding) (AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX)); pkt.dts = ::av_rescale_q_rnd(pkt.dts - dts_start_from[pkt.stream_index], in_stream->time_base, out_stream->time_base, (AVRounding) (AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX)); if (pkt.pts < 0) { pkt.pts = 0; } if (pkt.dts < 0) { pkt.dts = 0; } pkt.duration = (int) av_rescale_q((int64_t) pkt.duration, in_stream->time_base, out_stream->time_base); pkt.pos = -1; printf("\n"); ret = av_interleaved_write_frame(ofmt_ctx, &pkt); if (ret < 0) { LOG( "Error muxing packet\n"); break; } av_packet_unref(&pkt); } free(dts_start_from); free(pts_start_from); av_write_trailer(ofmt_ctx); end: LOG( "END"); avformat_close_input(&ifmt_ctx); /* close output */ if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE)) avio_closep(&ofmt_ctx->pb); avformat_free_context(ofmt_ctx); if (ret < 0 && ret != AVERROR_EOF) { LOG( "-- Error occurred: %s\n", av_err2str(ret)); return 1; }
Thanks for any help you can offer.
-
How one video overlay with 2 different videos with ffmpeg ?
30 mai 2017, par FatasHow one video overlay with 2 different videos with ffmpeg?
I have code like this:
ffmpeg -i video.mov -i ov1.mp4 -i ov2.mp4 \ -filter_complex "[0:v]setpts=PTS-STARTPTS[v0];[1:v]setpts=PTS-STARTPTS+1/TB[v1];[2:v]setpts=PTS-STARTPTS+10/TB[v2];[v0][v1]overlay=enable='between(t,1,10)';[v0][v2]overlay=enable='between(t,10,15)'" \ -t 30 \ -pix_fmt yuv420p -c:a copy \ out.mp4
But for result i have, that one overlay video is missing
-
Pass camera input to ffmpeg
30 mai 2017, par Sachin SononeI am trying to develop an delphi app which will show a preview of the camera in the delphi form and then send the frames of video as images to the ffmpeg in the stdin of ffmpeg. ffmpeg then broadcast the video to wowza server over rtmp. but fmpeg gives an error 'pipe:0 Bad file descriptor'
FFMPEG command: ffmpeg -f image2pipe -i pipe:0 -c:v libx264 -y -report -f flv wowza_url
I followed this https://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx article to build the parent app which will open ffmpeg as a child and use FFmpeg's stdin to pass input
// Create a pipe for the child process's STDOUT. Createpipe(STDOut_ReadPipe, STDOut_WritePipe, @Security,0); // Ensure the read handle to the pipe for STDOUT is not inherited. SetHandleInformation(STDOut_ReadPipe,HANDLE_FLAG_INHERIT,0); // Create a pipe for the child process's STDIN. if ( CreatePipe(STDIn_ReadPipe , STDIn_WritePipe, @Security, 0) = true) then // Ensure the write handle to the pipe for STDIN is not inherited. SetHandleInformation(STDIn_WritePipe, HANDLE_FLAG_INHERIT, 0) ;
This the code to start ffmpeg process
FillChar(StartupInfo,Sizeof(StartupInfo),0); StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.dwFlags := STARTF_USESTDHANDLES; StartupInfo.wShowWindow := 1; S := args; UniqueString(S); StartupInfo.hStdError := STDOut_WritePipe; StartupInfo.hStdOutput := STDOut_WritePipe; StartupInfo.hStdInput := STDIn_ReadPipe;
but as soon as program start ffmpeg exits with the error.
This is the full console log of the ffmpeg
ffmpeg started on 2017-05-30 at 18:45:36 Report written to "ffmpeg-20170530-184536.log" Command line: "ffmpeg.exe" -f image2pipe -i pipe:0 -report -movflags +faststart -tune zerolatency -an -pix_fmt yuv420p -preset ultrafast -vcodec libx264 -b:v 250k -y -f flv test.flv ffmpeg version N-85750-ga75ef15 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable- avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable- libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable- libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg -- enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr -- enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable- libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable- libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib libavutil 55. 61.100 / 55. 61.100 libavcodec 57. 93.100 / 57. 93.100 libavformat 57. 72.101 / 57. 72.101 libavdevice 57. 7.100 / 57. 7.100 libavfilter 6. 88.100 / 6. 88.100 libswscale 4. 7.101 / 4. 7.101 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 Splitting the commandline. Reading option '-f' ... matched as option 'f' (force format) with argument 'image2pipe'. Reading option '-i' ... matched as input url with argument 'pipe:0'. Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'. Reading option '-movflags' ... matched as AVOption 'movflags' with argument '+faststart'. Reading option '-tune' ... matched as AVOption 'tune' with argument 'zerolatency'. Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'. Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'. Reading option '-preset' ... matched as AVOption 'preset' with argument 'ultrafast'. Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'. Reading option '-b:v' ... matched as option 'b' (video bitrate (please use - b:v)) with argument '250k'. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'. Reading option 'test.flv' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option report (generate a report) with argument 1. Applying option y (overwrite output files) with argument 1. Successfully parsed a group of options. Parsing a group of options: input url pipe:0. Applying option f (force format) with argument image2pipe. Successfully parsed a group of options. Opening an input file: pipe:0. [pipe @ 003bdea0] Setting default whitelist 'crypto' [AVIOContext @ 03115e60] Statistics: 0 bytes read, 0 seeks pipe:0: Bad file descriptor'