Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
ffmpeg very big duration and very small fps with mpeg4 rtsp input
16 septembre 2014, par XuchI'm trying to dump video from network camera to HDD with ffmpeg libraries. It's fine working with h264 rtsp input, but with mpeg4 rtsp I've got corrupted video file: its duration more than 3000 hours and invalid fps but in fact duration is 300 seconds.
At start I doing (var 'Index' contain index valid video stream from input rtsp):
ofmt = av_guess_format(NULL, FullPath().c_str(), NULL); Ofcx = avformat_alloc_context(); Ofcx->oformat = ofmt; avio_open2(&Ofcx->pb, FullPath().c_str(), AVIO_FLAG_WRITE, NULL, NULL); Ost = avformat_new_stream(Ofcx, Ifcx->streams[Index]->codec->codec); avcodec_copy_context(Ost->codec, Ifcx->streams[Index]->codec); Ost->sample_aspect_ratio.num = Iccx->sample_aspect_ratio.num; Ost->sample_aspect_ratio.den = Iccx->sample_aspect_ratio.den; Ost->r_frame_rate = Ist->r_frame_rate; Ost->avg_frame_rate = Ist->avg_frame_rate; Ost->time_base = Ist->time_base; Ost->codec->time_base = Ost->time_base; avformat_write_header(Ofcx, NULL); Ost->codec->ticks_per_frame = Iccx->ticks_per_frame; Ost->codec->sample_aspect_ratio.num = Iccx->sample_aspect_ratio.num;
And next srtart dumping cycle:
int FfPipeline::DumpCycle() { AVPacket pkt; int index = GetVideoIndex(); av_init_packet(&pkt); av_read_play(Ifcx); while((av_read_frame(Ifcx, &pkt) >= 0) && (!IsNeedStop())) { if (pkt.stream_index == index) // Then packet is video { if ((IsWaitingKeyframe()) && !(pkt.flags & AV_PKT_FLAG_KEY)) { av_free_packet(&pkt); continue; } if (IsWaitingKeyframe()) { ClearWaitingKeyframeFlag(); pkt.pts = pkt.dts = AV_NOPTS_VALUE; SetStartTimestamp(); SetRecState(REC_WRITING); } pkt.stream_index = Ost->id; // Need to be remove in next time?? Ofcx->streams[index]->avg_frame_rate = Ifcx->streams[index]->avg_frame_rate; pkt.pts = av_rescale_q(pkt.pts, Ifcx->streams[index]->codec->time_base, Ofcx->streams[index]->time_base); pkt.dts = av_rescale_q(pkt.dts, Ifcx->streams[index]->codec->time_base, Ofcx->streams[index]->time_base); pkt.pts *= Ifcx->streams[index]->codec->ticks_per_frame; pkt.dts *= Ifcx->streams[index]->codec->ticks_per_frame; av_interleaved_write_frame(Ofcx, &pkt); } av_free_packet(&pkt); av_init_packet(&pkt); } // Now we stopping av_free_packet(&pkt); av_read_pause(Ifcx); av_write_trailer(Ofcx); avio_close(Ofcx->pb); avformat_close_input(&Ifcx); avformat_free_context(Ofcx); AddEndClipToDb(); Ifcx = NULL; Ofcx = NULL; return 0; }
- Input stream: 'rtsp://192.168.0.15:554/axis-media/media.amp?videocodec=mpeg4&fps=25&resolution=800x600&audio=0'
- Output file: test_out.mkv
I'm trying various output format but result was fully equal - very big duration and very small fps.
Please tell me in what direction I need seek?
Thanks a big!
P.S. dump_format():
Input #0, rtsp, from 'rtsp://192.168.0.11:554/mpeg4/media.amp?resolution=800x600&audio=0': Metadata: title : Media Presentation Duration: N/A, start: 0.133344, bitrate: N/A Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 100 fps, 100 tbr, 90k tbn, 100 tbc Output #0, matroska, to '/me': Metadata: encoder : Lavf53.32.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 100 fps, 100 tbr, 1k tbn, 90k tbc
-
Set content-length when converting video stream to audio (w/ FFMPEG & Node.js)
15 septembre 2014, par TaconutSo I'm building a program that requires that I take a video and convert it to audio. I'm currently streaming the audio directly to the browser via node.js, but I've run into a major problem: I don't know how to find out how many bytes my audio is. As a result, the browser keeps throwing
net::ERR_CONTENT_LENGTH_MISMATCH
when I don't get the right content-length. I've tried several strategies, all of which have failed:Computing the size manually (Seconds * bitrate(kbps) * (1024 / 8)).
This produces an approximate answer, since I only know the length down to the nearest couple of seconds. Even though I'm relatively close, I still end up getting the same MISMATCH error.Piping the Stream to a buffer, getting the buffer's length, and piping the buffer to the browser
This works, but it can take 15-20 seconds to load each song. It's incredibly slow and puts a considerably larger load on the server
-
how should I run ffmpeg examples ?
15 septembre 2014, par ranshI'm trying to run ffmpeg examples as exist is ~/ffmpeg_sources/doc/examples I've compiled successfuly, but when trying to execute I get some complains:
ubuntu@ubuntu-laptop:~/ffmpeg_sources/ffmpeg-2.3.3/doc/examples$ ./muxing usage: ./muxing output_file API example program to output a media file with libavformat.
...
ubuntu@ubuntu-laptop:~/ffmpeg_sources/ffmpeg-2.3.3/doc/examples$ ./muxing test.mp4 [aac @ 0x9519a40] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it. Could not open audio codec: Experimental feature
...
ubuntu@ubuntu-laptop:~/ffmpeg_sources/ffmpeg-2.3.3/doc/examples$ ./muxing test.mp4 -strict -2 usage: ./muxing output_file
...
Where is the input file input ? How is it that only output file should be given as argument ?
Thanks, Ran
-
Create video from series of images using android
15 septembre 2014, par Farrakh JavedI'm trying to write an android application in which we allow user to create video from series of images. I did lot of investigation like C/C++ libraries FFMPEG, X264. These can be used using NDK, but i dont know how to use it via NDK, i also did investigation but did not get about this. I find another library JCodec It is java based. I tried different codes of JCodec but did not get any success. Below are Links related to JCodec:
Now can anyone guide me about this question and can i have some suggestion how to implement this feature.
-
ffmpeg cut video at specified start position
15 septembre 2014, par user2648561I'm trying to use ffmpeg to cut out part of an avi file. I know similar questions have been asked before, but i've trawled through loads of other posts and I can't see where I'm going wrong.
The command line args i'm using to test on a 7 second video is:
-ss 00:00:01 -t 00:00:01 -i "C:\recordings\2013-09-11\Camera 1\Camera 1_2013-09-11_22-23-43.avi" -vcodec copy -acodec copy "I:\clip2.avi"
The output is:
ffmpeg version N-56254-gb7bd688 Copyright (c) 2000-2013 the FFmpeg developers built on Sep 12 2013 21:00:14 with gcc 4.7.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 43.100 / 52. 43.100 libavcodec 55. 31.101 / 55. 31.101 libavformat 55. 16.102 / 55. 16.102 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 84.100 / 3. 84.100 libswscale 2. 5.100 / 2. 5.100 libswresample 0. 17.103 / 0. 17.103 libpostproc 52. 3.100 / 52. 3.100Guessed Channel Layout for Input Stream #0.1 : mono Input #0, avi, from 'C:\recordings\2013-09-11\Camera 1\Camera 1_2013-09-11_22-23-43.avi': Duration: 00:00:07.03, start: 0.000000, bitrate: 787 kb/s Stream #0:0: Video: msmpeg4v3 (DIV3 / 0x33564944), yuv420p, 800x448, 30 fps, 30 tbr, 30 tbn, 30 tbc Stream #0:1: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 44100 Hz, mono, s16, 176 kb/s Output #0, avi, to 'I:\clip2.avi': Metadata: ISFT : Lavf55.16.102 Stream #0:0: Video: msmpeg4v3 (DIV3 / 0x33564944), yuv420p, 800x448, q=2-31, 30 fps, 30 tbn, 30 tbc Stream #0:1: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 44100 Hz, mono, 176 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 88 fps=0.0 q=-1.0 Lsize= 226kB time=00:00:02.03 bitrate= 908.7kbits/s video:146kB audio:66kB subtitle:0 global headers:0kB muxing overhead 6.345259%
I end up with a clip which is 3 seconds long !!!?? In the output I can see that the -ss flag is completely ignored.
Can anyone see where I'm going wrong?
Thanks