Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
raspberry pi, ffmpeg, libmp3lame stream to icecast2 fails with : av_interleaved_write_frame() : Connection reset by peer
9 avril 2016, par seekwhencerfinally, i want to merge or mix audio channels from two streams into one new audio stream. but at first i want to relay or reencode an existing stream from an icecast2 server - and send it back to the icecast as new mountpoint. this stream comes from mpd on the same raspberry pi 2. and it works fine.
i've got lame and ffmpeg on this way:
cd /usr/src git clone https://github.com/rbrito/lame cd lame sudo ./configure sudo make sudo make install
then ffmpeg
cd /usr/src sudo rm -R ffmpeg git clone git://source.ffmpeg.org/ffmpeg.git cd ffmpeg sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libmp3lame --enable-nonfree sudo make sudo make install
A simple test fails with:
**av_interleaved_write_frame(): Connection reset by peer Error writing trailer of icecast://admin:hackme@127.0.0.1:8000/listen: Connection reset by peersize= 5kB time=00:00:00.28 bitrate= 144.7kbits/s speed=1.73x**
(with strange spaces)
The reencoding ffmpeg script:
ffmpeg \ -i http://127.0.0.1:8000/live \ -c:a libmp3lame -b:a 128k \ -legacy_icecast 1 \ -content_type audio/mpeg \ -ice_name "hack radio" \ -f mp3 icecast://admin:hackme@127.0.0.1:8000/listen \ -y \ -stats \ -report
I tried legacy_icecast 1 or 0.
The ffmpeg report:
ffmpeg started on 2016-04-09 at 00:57:56 Report written to "ffmpeg-20160409-005756.log" Command line: ffmpeg -i http://127.0.0.1:8000/live -muxpreload 10 -c:a libmp3lame -b:a 128k -legacy_icecast 1 -content_type audio/mpeg -ice_name "NFS One Radio" -f mp3 icecast://admin:hackme@127.0.0.1:8000/listen -y -stats -report ffmpeg version N-79262-gae8a13c Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.6 (Debian 4.6.3-14+rpi1) configuration: --arch=armel --target-os=linux --enable-gpl --enable-libmp3lame --enable-nonfree libavutil 55. 20.100 / 55. 20.100 libavcodec 57. 34.100 / 57. 34.100 libavformat 57. 31.100 / 57. 31.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 41.100 / 6. 41.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Splitting the commandline. Reading option '-i' ... matched as input file with argument 'http://127.0.0.1:8000/live'. Reading option '-muxpreload' ... matched as option 'muxpreload' (set the initial demux-decode delay) with argument '10'. Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'libmp3lame'. Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '128k'. Reading option '-legacy_icecast' ... matched as AVOption 'legacy_icecast' with argument '1'. Reading option '-content_type' ... matched as AVOption 'content_type' with argument 'audio/mpeg'. Reading option '-ice_name' ... matched as AVOption 'ice_name' with argument 'NFS One Radio'. Reading option '-f' ... matched as option 'f' (force format) with argument 'mp3'. Reading option 'icecast://admin:hackme@127.0.0.1:8000/listen' ... matched as output file. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-stats' ... matched as option 'stats' (print progress report during encoding) with argument '1'. Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option stats (print progress report during encoding) with argument 1. Applying option report (generate a report) with argument 1. Successfully parsed a group of options. Parsing a group of options: input file http://127.0.0.1:8000/live. Successfully parsed a group of options. Opening an input file: http://127.0.0.1:8000/live. [http @ 0x343cee0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy' [http @ 0x343cee0] request: GET /live HTTP/1.1 User-Agent: Lavf/57.31.100 Accept: */* Range: bytes=0- Connection: close Host: 127.0.0.1:8000 Icy-MetaData: 1 [mp3 @ 0x343c7e0] Format mp3 probed with size=262144 and score=50 [mp3 @ 0x343c7e0] Skipping 656 bytes of junk at 0. [mp3 @ 0x343c7e0] Before avformat_find_stream_info() pos: 656 bytes read:272000 seeks:0 [mp3 @ 0x343c7e0] All info found [mp3 @ 0x343c7e0] After avformat_find_stream_info() pos: 42640 bytes read:272000 seeks:0 frames:50 Input #0, mp3, from 'http://127.0.0.1:8000/live': Metadata: icy-br : 256 icy-name : NFS One Radio icy-pub : 0 StreamTitle : x Duration: N/A, start: 0.000000, bitrate: 256 kb/s Stream #0:0, 50, 1/14112000: Audio: mp3, 44100 Hz, stereo, s16p, 256 kb/s Successfully opened the file. Parsing a group of options: output file icecast://admin:hackme@127.0.0.1:8000/listen. Applying option muxpreload (set the initial demux-decode delay) with argument 10. Applying option c:a (codec name) with argument libmp3lame. Applying option b:a (video bitrate (please use -b:v)) with argument 128k. Applying option f (force format) with argument mp3. Successfully parsed a group of options. Opening an output file: icecast://admin:hackme@127.0.0.1:8000/listen. [icecast @ 0x34492c0] No default whitelist set [http @ 0x344b9e0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy' [http @ 0x344b9e0] request: SOURCE /listen HTTP/1.1 User-Agent: Lavf/57.31.100 Accept: */* Connection: close Host: 127.0.0.1:8000 Content-Type: audio/mpeg Icy-MetaData: 1 Ice-Name: NFS One Radio Ice-Public: 0 Authorization: Basic YWRtaW46bWFyc2Jhc2U=
The Output from ffmpeg:
ffmpeg started on 2016-04-09 at 01:06:46 Report written to "ffmpeg-20160409-010646.log" ffmpeg version N-79262-gae8a13c Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.6 (Debian 4.6.3-14+rpi1) configuration: --arch=armel --target-os=linux --enable-gpl --enable-libmp3lame --enable-nonfree libavutil 55. 20.100 / 55. 20.100 libavcodec 57. 34.100 / 57. 34.100 libavformat 57. 31.100 / 57. 31.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 41.100 / 6. 41.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 [mp3 @ 0x25ec7e0] Skipping 501 bytes of junk at 0. Input #0, mp3, from 'http://127.0.0.1:8000/live': Metadata: icy-br : 256 icy-name : NFS One Radio icy-pub : 0 StreamTitle : x Duration: N/A, start: 0.000000, bitrate: 256 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 256 kb/s Output #0, mp3, to 'icecast://admin:hackme@127.0.0.1:8000/listen': Metadata: icy-br : 256 icy-name : NFS One Radio icy-pub : 0 StreamTitle : x TSSE : Lavf57.31.100 Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 128 kb/s Metadata: encoder : Lavc57.34.100 libmp3lame Stream mapping: Stream #0:0 -> #0:0 (mp3 (native) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help av_interleaved_write_frame(): Connection reset by peer Error writing trailer of icecast://admin:hackme@127.0.0.1:8000/listen: Connection reset by peersize= 16kB time=00:00:00.96 bitrate= 132.9kbits/s speed=3.14x video:0kB audio:16kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.183730%
The icecast works fine with mpd. And icecast creates a new mountpoint when feeded.
For some reason the connection to the icecast drops. Ideas?
Thanks
-
How to add libmp3lame, libx264, libvo_aacenc and libvorbis codecs to existing ffmpeg install on Redhat 6.7
9 avril 2016, par rjnAdobe cq uses ffmpeg to transcode videos. There is a workflow that is triggered when a user uploads any video to the digital asset management (DAM) section. This workflow internally uses ffmpeg to transcode the uploaded video and spits out additional video renditions in formats like ogg, m4v, mp3.
The server (Red Hat Enterprise Linux Server release 6.5) on which adobe cq runs needs to have ffmpeg installed for the DAM workflow to function. ffmpeg has already installed been installed, but it is missing certain codecs: libmp3lame, libx264, libvo_aacenc and libvorbis.
How to add and enable these codecs ?
-
Decoding EVRC speech codec
8 avril 2016, par NitinGI want to decode the EVRC speech codec. I have checked the ffmpeg library but it seems like, EVRC is not being currently supported by ffmpeg.
Is there any alternate library which can be used to decode EVRC data?
Or if anybody have some algorithm or decoding mechanism or code snippet to do so, please let me know.
Thanks Nitin
-
Recursively convert media directory from HEVC to h.264 with ffmpeg
8 avril 2016, par chuckcastleI have media server with two directories: Movies and TV Shows. Within each of those directories, each entry exists in a sub-directory which contains the video file and subtitle files.
I've scoured the web and have found an excellent perl script from Michelle Sullivan, posted here:
#!/usr/bin/perl use strict; use warnings; open DIR, "ls -1 |"; while (
) { chomp; next if ( -d "$_"); # skip directories next unless ( -r "$_"); # if it's not readable skip it! my $file = $_; open PROBE, "ffprobe -show_streams -of csv '$file' 2>/dev/null|" or die ("Unable to launch ffmpeg for $file! ($!)"); my ($v, $a, $s, @c) = (0,0,0); while ( ) { my @streaminfo = split(/,/, $_); push(@c, $streaminfo[2]) if ($streaminfo[5] eq "video"); $a++ if ($streaminfo[5] eq "audio"); $s++ if ($streaminfo[5] eq "subtitle"); } close PROBE; $v = scalar @c; if (scalar @c eq 1 and $c[0] eq "ansi") { warn("Text file detected, skipping...\n"); next; } warn("$file: Video Streams: $v, Audio Streams: $a, Subtitle Streams: $s, Video Codec(s): " . join (", ", @c) . "\n"); if (scalar @c > 1) { warn("$file has more than one video stream, bailing!\n"); next; } if ($c[0] eq "hevc") { warn("HEVC detected for $file ...converting to AVC...\n"); system("mkdir -p h265"); my @params = ("-hide_banner", "-threads 2"); push(@params, "-map 0") if ($a > 1 or $s > 1 or $v > 1); push(@params, "-c:a copy") if ($a); push(@params, "-c:s copy") if ($s); push(@params, "-c:v libx264 -pix_fmt yuv420p") if ($v); if (system("mv '$file' 'h265/$file'")) { warn("Error moving $file -> h265/$file\n"); next; } if (system("ffmpeg -xerror -i 'h265/$file' " . join(" ", @params) . " '$file' 2>/dev/null")) { warn("FFMPEG ERROR. Cannot convert $file restoring original...\n"); system("mv 'h265/$file' '$file'"); next; } } else { warn("$file doesn't appear to need converting... Skipping...\n"); } } close DIR; The script performs perfectly - as long as it is run from within the directory containing the media.
My question: Can this script be modified to run recursively from the root directory? How?
Thanks in advance.
(Michelle's script can be seen here: http://www.michellesullivan.org/blog/1636)
-
How can I limit the file size when doing a write() while writing data from a video stream in Python
8 avril 2016, par Michael BaileyI am pulling in a video stream of an unknown length and writing that file to disc using
.write()
in Python. My basic need is to have a rolling 2-3 minutes of video recorded to that file at all times VS having that file grow to a huge size. On the other end I'm using FFMPEG to grab clips from the .dat file being written.with open("./site/files/tmp/" + hashid + ".dat", 'wb') as f: while True: data = stream.read(1024) f.write(data)
Alternately if you know a way I could store that same data in memory probably only 20-50mb (2-3 mins) and send that to FFMPEG that might be an even better option as well. I'm calling FFMPEG via Popen subprocess.