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.
Related
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?
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 have a problem about transcode with ffmpeg
i want to cover m3u8 to mp4, so i transcode every ts file first, and then concat them to a mp4, but i found that the duration will be bigger than source file.
source file is :
http://oc7iy3eta.bkt.clouddn.com/src_20.ts
after transcode, test file is:
http://oc7iy3eta.bkt.clouddn.com/test_20.ts
i use the command as bellow to change to 5fps, and 400k bitrate:
sudo ffmpeg -analyzeduration 2147483647 -probesize 2147483647 -nostdin -y -v warning -i ./src_20.ts -threads 3 -movflags faststart -metadata:s:v rotate=0 -chunk_duration 520000 -video_track_timescale 25000 -pix_fmt yuv420p -copytb 1 -vcodec libx264 -b:v 400000 -minrate 400000 -maxrate 400000 -bufsize 500k -force_key_frames "expr:gte(t,n_forced*2)" -vsync 1 -r 5 -s 544*960 -acodec libfaac -async 1 ./test_20.ts
i use ffprobe command to see video info:
source file info:
Duration: 00:00:01.26, start: 28.346989, bitrate: 921 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 23 kb/s
Stream #0:1[0x101]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 544x960, 10.67 tbr, 90k tbn, 180k tbc
test file:
Input #0, mpegts, from 'test_20.ts':
Duration: 00:00:01.62, start: 1.576778, bitrate: 447 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 544x960, 5 fps, 5 tbr, 90k tbn, 10 tbc
Stream #0:1[0x101]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 5 kb/s
=======================================================================
question
so , we can see that the duration of src file is 1.26s , but after transcode, the test file is 1.62s.
why? can anybody help
I suggest you save the m3u8 to a single TS and then transcode that to MP4.
ffmpeg -i in.m3u8 -c copy src.ts
Your current command is transcoding each TS to CFR at half the rate but your source timestamps have some jitter, so due to PTS quantization, there will be a mismatch. A single file transcode will minimize it.
Want to batch convert a bunch of different video files from cli instead of Rolands old-and-slow-drag-and-drop-one-file-at-a-time-software. I have used ffprobe in OS X Terminal here. This shows us what the software did to the file and I want to do the same. MJPEG AVI I get but the rest, how would my ffmpeg syntax look to achieve this result efter converting?
Example: My ffprobe give me this
Input #0, avi, from 'P10_0001.AVI':
Metadata:
comment :
encoder : Roland Corporation
Duration: 00:03:17.64, start: 0.000000, bitrate: 16694 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 15285 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
What would the ffmpeg syntax look like to do this with a new file.
I've been trying some simple ones but those are not accepted by the machine (Edirol p-10) and I hope someone can point me in the right direction. :)
Edit:
OK. The syntax I want to do is involving 3 files.
File that has the correct codec and everything to work with the machine. P10_0001.AVI
A file that does not have the correct format (codec etc.) softvision.mpg
A new file just as file 2 but with the codec of file number 1. P10_0002.AVI
ffmpeg -i gradomat.mpg -framerate 25 -vf scale=640:480 -vcodec mjpeg -pix_fmt yuvj422p -b:v 15285k -b:a 1411k -acodec pcm_s16le -ar 44100 -ac 2 -metadata encoder="Roland Corporation" P10_000X.AVI
Think this solved it temporarily but the problem is that I have to write that my self, it would have been better if ffprobe gave me that syntax instead.
This is also a solution, but in python.
https://github.com/cskonopka/rolandp10fp