1

how i can change input on ffmpeg without stop process on linux Debian 9? im user decklink input and i need to change to file mp4 input.

ffmpeg -f decklink -i 'DeckLink Mini Recorder' -vf setpts=PTS-STARTPTS -pix_fmt uyvy422 -s 1920x1080 -r 25000/1000 -f decklink 'DeckLink Mini Monitor'
1
  • ffmpeg can't reconfigure input mid-process.
    – Gyan
    Jul 11, 2018 at 5:22

2 Answers 2

2

For any other person looking forward to this answer I got to the following solution (using python and CV2):

STEP 1: Run your camera (or any other ffmpeg input) live locally

ffmpeg -i /dev/video0 -b 50k -r 20 -s 720x480 -f mpegts udp://127.0.0.1:2000 

STEP 2: Have the ad or video you want to be displayed with the resolution as your input and most importantly saved as a .3gp video file. STEP 3: Write a switcher.py file in the same directory as your .3gp file

import cv2
import sys
def main(argv):
    adName = argv[0]
    cap = cv2.VideoCapture("udp://127.0.0.1:2000")
    showAd = 2
    while cap.isOpened():
        if showAd == 1:
        cap.release()
        del cap
        cap = cv2.VideoCapture(adName)
        showAd = 0
        if showAd == 2:
        cap.release()
        del cap
        cap = cv2.VideoCapture("udp://127.0.0.1:2000")
        showAd = 0

        ret, frame = cap.read()
        try:
            height, width, channels = frame.shape
        except: 
        cap.release()
        del cap
        cap = cv2.VideoCapture("udp://127.0.0.1:2000")
        key = cv2.waitKey(33)
        if key==27:
        showAd = 1
        if key==32:
        showAd = 2

        if(ret):
        sys.stdout.write(frame.tostring())
        cv2.imshow("frame",frame)


    cap.release()

if __name__ == "__main__":
    main(sys.argv[1:])

STEP 5: Run the switcher.py with your ad name afterward and your output.

python switcher.py ad.3gp| ffplay -f rawvideo -pixel_format bgr24 -video_size 720x480 -i - 

STEP 6: Hit "Esc" to show your ad!

REMEMBER TO CHANGE THE SCREEN VALUES!

Hope I've helped someone! (Probably I'll do some edits to this post)

0

Hmmm, I can't understand your question very well...

If you are having problems in using DeckLink and ffmpeg those website might be useful:

https://www.ffmpeg.org/ffmpeg-devices.html#decklink

https://trac.ffmpeg.org/wiki/Capture/Blackmagic

If you are trying to switch from one DeckLink to a camera or other recording device, then I'm afraid to say you will need to code a "switcher" (probably, if streaming, the stream is going to stop). If you need any help with the coding e-mail me! (I don't have enough reputation to comment)

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .