I've been using this command to convert my public rtmp audio/video stream to a local mp3 audio icecast2 stream, but I have been unable to do the same for both video and audio.
[Audio Only] (This works fine)
ffmpeg -re -i rtmp://162.142.xx.xxx:xxx/stream -vn -codec:a libmp3lame -b:a 128k -f mp3 -content_type audio/mpeg icecast://source:password#192.168.1.xxx:80/live
I've tried to re-write in order to support video, but I keep hitting dead ends
[Audio & Video Attempt] (this does not work)
ffmpeg -re -i rtmp://162.142.xx.xxx:xxx/stream -codec:v -f mpeg4 -b:v -f mpeg4 -content_type video/mpeg4 icecast://source:password#192.168.1.xxx:80/live
When I run this command, it gives me the error below asking for a suitable format.
$ ffmpeg -re -i rtmp://162.142.xx.xxx:xxx/stream -codec:v -f mpeg4 -b:v -f mpeg4 -content_type video/mpeg4 icecast://source:password#192.168.1.xxx:80/live
[h264 # 0x5598ffbb8980] co located POCs unavailable
[h264 # 0x5598ffbb8980] mmco: unref short failure
Input #0, flv, from 'rtmp://162.142.xx.xxx:xxx/stream':
Metadata:
|RtmpSampleAccess: true
Server : NGINX RTMP (github.com/sergey-dryabzhinsky/nginx-rtmp-module)
displayWidth : 1280
displayHeight : 720
fps : 48
videokeyframe_frequency: 0
profile :
level :
Duration: 00:00:00.00, start: 28117.779000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 327 kb/s
Stream #0:1: Video: h264 (High), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 2560 kb/s, 48 fps, 48 tbr, 1k tbn
[NULL # 0x5598ffb8bec0] Unable to find a suitable output format for 'mpeg4'
mpeg4: Invalid argument
I am positive that icecast2 can support video streams, however on the few occasions that I was able to actively stream successfully to it, it only showed an empty video embed.
I've re-written the command for AV multiple times while referencing ffmpeg documentation, however my above attempt seems to be the closest (concept-wise) that I have gotten.
What flags/formatting might I be missing which are causing the stream not to work?
Related
I'm attempting to transcode a DVD to a single MKV file. I've had success in the past with other DVDs, but I'm running into an error I haven't seen before.
First I concatenate the VOB files I want to transcode:
cat VTS_02_1.VOB VTS_02_2.VOB VTS_02_3.VOB > WMAV.VOB
ffprobe output:
$ ffprobe -analyzeduration 100M -probesize 100M WMAV.VOB Input #0, mpeg, from 'WMAV.VOB':
Duration: 01:05:19.42, start: 0.300300, bitrate: 5686 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, smpte170m, top first), 720x480 [SAR 32:27 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Unsupported codec with id 100357 for input stream 0
Then I run this command to transcode the file:
ffmpeg -analyzeduration 100M -probesize 100M \
-i WMAV.VOB \
-map 0:1 -map 0:2 \
-c:v libx264 -preset slow -tune film -crf 21 \
-c:a aac -b:a 192k \
wmav.mkv
However, when I include -c:a aac, I get thousands of errors like this:
Error while decoding stream #0:2: Error number -16976906 occurred
[ac3 # 000002bd24d8eec0] expacc 127 is out-of-range
[ac3 # 000002bd24d8eec0] error decoding the audio block
There doesn't seem to be any issue with the audio stream since it plays back fine in VLC. The transcode succeeds if I use -c:a copy.
What is causing this error and how could I fix the problem?
I want to create a webpage with a video player that can play a H264 mpeg-ts live stream. I can't find any web player that can do that.
I read that JWPlayer is capable of doing that, but only in the paid version.
The stream can be played in VLC and any other players.
What can I do? I tried using ffmpeg to convert the stream to something more useful, but no succes.
ffmpeg -i "http://localhost:9002/tv.ts" -vcodec libx264 -r 20 -s 320x240 -threads 2 -vprofile baseline -vpre zoom -strict experimental -acodec aac -ab 96000 -ar 48000 -ac 1 -f rtsp rtsp://192.168.0.28:1935/live/_definst_/c3
This is what I get:
Last message repeated 1 times
[h264 # 0xbb9500] decode_slice_header error
[h264 # 0xbb9500] no frame!
[mpegts # 0xbaa6e0] decoding for stream 1 failed
[mpegts # 0xbaa6e0] Could not find codec parameters for stream 1 (Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'http://192.168.0.28:9002/tv.ts':
Duration: N/A, start: 30764.854700, bitrate: N/A
Program 1
Stream #0:0[0x44](???): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:1[0x45]: Video: h264 ([27][0][0][0] / 0x001B), none, 25 fps, 25 tbr, 90k tbn, 180k tbc
File for preset 'zoom' not found
You can attempt to include hls.js player in your website. This player transmuxes your TS stream into MP4 fragments in order to be played in any browser. It is free and easily integrated.
Demo page https://video-dev.github.io/hls.js/demo/
Github page https://github.com/video-dev/hls.js/
I am beginning to be more serious about video. I am processing my videos with ffmpeg in a fully updated Linux into mp4 to use it in HTML5 directly.
Now, I have old AVI videos that I want to convert to mp4 with ffmpeg for use with HTML5. In particular, I have this one:
http://luis.impa.br/photo/1101_aves_ce/caneleiro-de-chapeu-preto_femea_Quixada-CE-110126-E_05662+7a.avi
(I know, terrible quality... sorry). According to ffprobe:
Duration: 00:01:35.30, start: 0.000000, bitrate: 1284 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (DX50 / 0x30355844), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1144 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
That seems perfect: mpeg4 video and mp3 audio. So I tried:
ffmpeg -i input.avi -acodec copy -vcodec copy output.mp4
It generates a file that plays nicely in mplayer, but not in firefox getting an error:
Video format or MIME type not supported.
Chrome plays the audio, but no video is shown... Now, if I do:
ffmpeg -i input.avi output.mp4
firefox works, but the video is reencoded in another one with half the size (half the bitrate). This is what ffprobe says about the reencoded video:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Duration: 00:01:35.30, start: 0.000000, bitrate: 685 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 548 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
I suppose that I am loosing lots of quality (and time processing the video). So, my questions:
Why are browsers not playing my video with the copy codecs ?
Can I work with ffmpeg in this particular file without reencoding? If yes, how?
If I need to reencode, which are "reasonable" parameters to keep close to the original quality? Would something like
ffmpeg -i input.avi -b:v 1024k -bufsize 1024k output.mp4
suffice for this video? This generates a new video with size closer to the original one.
Thanks!
According to ffprobe and if I see it correctly, you have a DivX (5) video file. Do not use it for web!! ;)
mpeg4 (Simple Profile) (DX50 / 0x30355844)
So I don't see any chance to use this video without reencoding. Not if you wish to support firefox.
Use WebM or h264: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
UPDATE
Good settings for reencode depends on your input (bitrate, resolution, fps, kind of material ...), so there is no standard answer.
But you have to specify a codec or ffmpeg choose one depending on your output file extension (so it can be the wrong one).
You can try this:
ffmpeg -i input.avi -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv
Presets and tunes can help to find the best choice: https://trac.ffmpeg.org/wiki/Encode/H.264
EDIT: It already works. My new router seems to block rtmp traffic. I edited the firewall config and now it works!
I'm trying to stream to YouTube with ffmpeg with the following command:
ffmpeg -f alsa -ac 2 -i hw:0,0 -f v4l2 -s 1280x720 -r 10 -i /dev/video0 -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -strict experimental -r 25 -g 20 -b:v 2500k -codec:a libmp3lame -ar 44100 -b:a 11025 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/45ee-qka9-0djm-796z
My ffmpeg version 2.8.11 on Linux Mint 18.2 then says:
Input #0, alsa, from 'hw:0,0':
Duration: N/A, start: 1511081240.166016, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[video4linux2,v4l2 # 0xacba60] The driver changed the time per frame from 1/10 to 2/15
Input #1, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 5907.755626, bitrate: 110592 kb/s
Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 110592 kb/s, 7.50 fps, 7.50 tbr, 1000k tbn, 1000k tbc
After that it does nothing for about 3 minutes,then it finally returns the following error:
RTMP_Connect0, failed to connect socket. 110 (Connection timed out)
rtmp://a.rtmp.youtube.com/live2: Unknown error occurred
I used these instructions:
https://gist.github.com/laurenarcher/4644aacef51e734d33d5
FFMPEG to Youtube Live
Finally, I found an easy solution. Quite unexpectedly, the firewall of my router blocks outgoing RTMP traffic by default. By adding a port trigger rule for the well-known RTMP port (1935-TCP), I managed to work around this issue.
I am aware that this is not the most elegant fix, but my ISP's router does not exactly boast with configuration options, so the method above was the only possible way to address this problem.
I have a mov file :
Metadata:
timecode: 09:59:50:00
Duration: 00:00:30.00, bitrate: 117714 kb/s
Stream #0.0(eng): Video: dvvideo, yuv422p, 1440x1080i tff [PAR 4:3 DAR 16:9]
, 115200 kb/s, 25.00 fps
Metadata:
codec_name: DVCPRO HD 1080i50
Stream #0.1(eng): Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
Stream #0.2(eng): Data: unknown (tmcd)
I can see from MediaInfo
That the Audio is Muxed into the video. I'm trying to re-wrap this into an XDCAM, and copy over the audio streams. The problem is that I don't know how to map the audio that is wrapped into the video?
This is the command I have so far:
ffmbc -threads 8 -i "input.mov" -threads 8 -tff
-pix_fmt yuv422p -vcodec mpeg2video -timecode 09:59:50:00
.. other tags omitted ..
-acodec pcm_s24le
-map_audio_channel 0.1:0-0.1:0
-map_audio_channel 0.1:1-0.1:1
-f mov -y "output.mov"
-acodec pcm_s24le
-map_audio_channel 0.2:0-0.2:0
-map_audio_channel 0.2:1-0.2:1 -newaudio
When executed this returns "Cannot find audio channel 0.2.0". I changed the input stream identifier to stream 0, and 1 for the audios. Which when executed returned "Cannot find audio channel #0.0.0" presumably because it's trying to find a audio channel within the video stream?
How can I extract the audio from this file?
You may notice I'm using FFMBC, not FFMPEG ( there is no tag for FFMBC ), but I imagine it's the same for both. I'm not constrained to FFMBC, I can move to FFMPEG if it has a solution.
Thanks