Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

ffmpeg opperation not permtted on rtmp

I am trying to make a internet radio using ffmpeg. I have a folder full of mp3 and have a 5sec mp4 that i want to use in a infinite loop. so here is the code i came up with to stream on YouTube

#! /bin/bash

    VBR="1500k"
    FPS="30"
    QUAL="ultrafast"
    YOUTUBE_URL=" rtmp://a.rtmp.youtube.com/live2"
    YOUTUBE_KEY="YOUTUBE_KEY_HERE"
    VIDEO_SOURCE="output.mp4"
    AUDIO_ENCODER="aac"
    
    ffmpeg 
     -stream_loop -1 
     -re 
     -i "$VIDEO_SOURCE" 
     -thread_queue_size 512 
     -stream_loop -1 
     -re 
     -f concat -safe 0 -i audio.txt 
     -c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR -bufsize 3000k -maxrate $VBR 
     -c:a $AUDIO_ENCODER -ar 44100 -b:a 128k -pix_fmt yuv420p 
     -f flv -flvflags no_duration_filesize $YOUTUBE_URL/$YOUTUBE_KEY

The problem is the i am getting an error saying operation not permitted

here is the error log

Error while filtering: Operation not permittede=00:00:03.73 bitrate=1369.7kbits/s speed=0.854x
frame=   46 fps=9.4 q=16.0 Lsize=     742kB time=00:00:04.50 bitrate=1350.0kbits/s speed=0.921x
video:668kB audio:70kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.622114%
[libx264 @ 0x5584c6bcf620] frame I:1     Avg QP:37.00  size: 50802
[libx264 @ 0x5584c6bcf620] frame P:45    Avg QP:23.92  size: 14046
[libx264 @ 0x5584c6bcf620] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x5584c6bcf620] mb P  I16..4:  4.3%  0.0%  0.0%  P16..4: 17.9%  0.0%  0.0%  0.0%  0.0%    skip:77.8%
[libx264 @ 0x5584c6bcf620] coded y,uvDC,uvAC intra: 30.5% 41.6% 16.6% inter: 7.3% 10.1% 1.9%
[libx264 @ 0x5584c6bcf620] i16 v,h,dc,p: 44% 43%  8%  5%
[libx264 @ 0x5584c6bcf620] i8c dc,h,v,p: 32% 40% 24%  5%
[libx264 @ 0x5584c6bcf620] kb/s:1187.63
[aac @ 0x5584c6bd2f20] Qavg: 320.800

I think this error is due to the video that I am looping is too short and the -stream_loop -1 flag seems buggy according to some guys on superuser and stackoverflow.

Is there any other way to fix this

question from:https://stackoverflow.com/questions/65863337/ffmpeg-opperation-not-permtted-on-rtmp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

ok i found the solution. you can use the movie filter. it has a loop. You can provide the same file that you want to loop as a input and put a movie filter to it and then chain that to the concat

here is the modified code this may help to understand

#! /bin/bash

    VBR="1500k"
    FPS="30"
    QUAL="ultrafast"
    YOUTUBE_URL=" rtmp://a.rtmp.youtube.com/live2"
    YOUTUBE_KEY="YOUTUBE_KEY_HERE"
    VIDEO_SOURCE="output.mp4"
    AUDIO_ENCODER="aac"

    ffmpeg 
     -stream_loop -1 
     -re 
 -filter_complex movie=/root/LiveStreamRadio/media/output.mp4:loop=0,setpts=N/FRAME_RATE/TB 
     -i "$VIDEO_SOURCE" 
     -thread_queue_size 512 
     -stream_loop -1 
     -re 
     -f concat -safe 0 -i audio.txt 
     -c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR -bufsize 3000k -maxrate $VBR 
     -c:a $AUDIO_ENCODER -ar 44100 -b:a 128k -pix_fmt yuv420p 
     -f flv -flvflags no_duration_filesize $YOUTUBE_URL/$YOUTUBE_KEY

look at this section

-filter_complex movie=/root/LiveStreamRadio/media/output.mp4:loop=0,setpts=N/FRAME_RATE/TB -i "$VIDEO_SOURCE"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...