Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Is there any way to stream video while encoding except using ffmpeg ?
25 novembre 2016, par Ruslan DoronichevI am developing a cloud service, that allow users to upload video files from torrents and watch them online. In order to view the media, while transcoding - I convert the source file into hls format. I don't really like this approach, as every user has a storage limit and he has to use his space for storing both hls and source files, even if he is not going to watch the video while encoding. What would be the best solution in this case?
-
Regarding ffmpeg conversion ts to mp4
25 novembre 2016, par deepI have a ts file and extracting around 31 seconds from it.
ffmpeg -ss 00:20:06.080 -i 215_30.ts -t 00:00:31.000 -c copy test_g.mp4 If i use -c copy with ffmpeg it produces Duration: 00:00:31.22, start: 0.224000. Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy)
ffmpeg -ss 00:20:06.080 -i 215_30.ts -t 00:00:31.000 test.mp4 and without -c copy Duration: 00:00:31.04, start: 0.042667, bitrate: 1310 kb/s. Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (mp2 (native) -> aac (libfdk_aac))
Video frames is same both the case but the audio is shifted 200ms if i compare in audacity. Why is that so? How can the duration increase? What is the start: field which is displayed from ffmpeg output?
-
ffmpeg:transcoding.c problems
25 novembre 2016, par Park Han WoolI am studying about ffmpeg in c++ to see example of ffmpeg
but I dont' know how to solve this problem in transcoding.c
here is my problem
and here is code
static int open_output_file(const char *filename) { AVCodecContext *dec_ctx, *enc_ctx; AVCodec *encoder; AVStream *in_stream, *out_stream; int ret; unsigned int i; ofmt_ctx = NULL; avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, filename); if (!ofmt_ctx) { av_log(NULL, AV_LOG_ERROR, "Could not create output context\n"); return AVERROR_UNKNOWN; } for (i = 0; i < ifmt_ctx->nb_streams; i++) { in_stream = ifmt_ctx->streams[i]; out_stream = avformat_new_stream(ofmt_ctx,NULL); if (!out_stream) { av_log(NULL, AV_LOG_ERROR, "Failed allocating output stream\n"); return AVERROR_UNKNOWN; } dec_ctx = in_stream->codec; enc_ctx = out_stream->codec; printf("codec name : %s \n", avcodec_get_name(enc_ctx->codec_id)); if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { /* in this example, we choose transcoding to same codec */ encoder = avcodec_find_encoder(dec_ctx->codec_id); if (!encoder) { av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n"); return AVERROR_INVALIDDATA; } /* In this example, we transcode to same properties (picture size, * sample rate etc.). These properties can be changed for output * streams easily using filters */ if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { enc_ctx->height = dec_ctx->height; enc_ctx->width = dec_ctx->width; enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio; /* take first format from list of supported formats */ enc_ctx->pix_fmt = encoder->pix_fmts[0]; /* video time_base can be set to whatever is handy and supported by encoder */ enc_ctx->time_base = dec_ctx->time_base; } else { enc_ctx->sample_rate = dec_ctx->sample_rate; enc_ctx->channel_layout = dec_ctx->channel_layout; enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout); /* take first format from list of supported formats */ enc_ctx->sample_fmt = encoder->sample_fmts[0]; enc_ctx->time_base.num = 1; enc_ctx->time_base.den = enc_ctx->sample_rate; } /* Third parameter can be used to pass settings to encoder */ ret = avcodec_open2(enc_ctx, encoder, NULL); if (ret < 0) { cout << "ret<0" << endl; av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i); return ret; } } else if (dec_ctx->codec_type == AVMEDIA_TYPE_UNKNOWN) { av_log(NULL, AV_LOG_FATAL, "Elementary stream #%d is of unknown type, cannot proceed\n", i); return AVERROR_INVALIDDATA; } else { /* if this stream must be remuxed */ ret = avcodec_copy_context(ofmt_ctx->streams[i]->codec, ifmt_ctx->streams[i]->codec); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Copying stream context failed\n"); return ret; } } if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; } av_dump_format(ofmt_ctx, 0, filename, 1); if (!(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) { ret = avio_open(&ofmt_ctx->pb, filename, AVIO_FLAG_WRITE); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Could not open output file '%s'", filename); return ret; } } /* init muxer, write output file header */ ret = avformat_write_header(ofmt_ctx, NULL); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error occurred when opening output file\n"); return ret; } return 0; }
I found this problem in open_output_file function....
but I can't fix this problem..
how I can approach this problem..
I need your help,.
-
Republish RTMP or RTSP stream to Windows Media Services
25 novembre 2016, par Ioannis KokkinisI would like a definite answer on if it is possible to republish an RTMP stream to a windows media services publishing point with any free software (preferably ffmpeg).If yes, how? This point can be a smooth streaming publishing point or the older version of media services.
for the smooth streaming scenario there is some information on the internet, but no real answers or working examples on how it was achieved. People suggest to use ffmpeg this way :
ffmpeg -re -i rtmp://xxx.xxx.xxx.xxx:1935/application/stream -movflags isml+frag_keyframe -f ismv -threads 0 -acodec copy -vcodec copy 'http://xxx.xxx.xxx.xxx/publishpoint_name.isml/Streams(video)'
This ofcourse requires for the the source video to be h264 and source audio to be aac. also requires that you have setup IIS and installed the smooth streaming web component and have setup a push publishing point with the name "publishpoint_name" (not sure if the isml is needed)
The above does not work for me, and information is scarce on the internet.
-
ffmpeg throwing "Output file #0 does not contain any stream" when trying to make a slideshow out of images
25 novembre 2016, par Abdou TahiriIm trying to create video streaming using phantomjs that create screenshots from a url then it will pipe the frames to ffmpeg so he can use it to stream the video to an rtmp url . here is what i tried so far :
phantomjs runner.js | ffmpeg -f image2pipe -vcodec png -c:a copy -c:v libx264 -f flv rtmp://localhost/mystream
and here is the script :
var page = require('webpage').create(); page.viewportSize = { width: 640, height: 480 }; page.open('http://www.goodboydigital.com/pixijs/examples/12-2/', function () { setInterval(function() { page.render('/dev/stdout', { format: "png" }); }, 25); });
and this is the output :
ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers built with Apple LLVM version 7.3.0 (clang-703.0.29) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda libavutil 55. 17.103 / 55. 17.103 libavcodec 57. 24.102 / 57. 24.102 libavformat 57. 25.100 / 57. 25.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 31.100 / 6. 31.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Output #0, flv, to 'rtmp://localhost/mystream': Output file #0 does not contain any stream