ffmpeg do stream copy together with draw text

0

I need to record an RTSP stream, before storing it I need draw some text on the video.

And the below command works fine for recording stream only(no text write).

openRTSP -D 10 -v -t -c -b 800000 rtsp://video_link.mov | ./ffmpeg -r 15 -i - -codec copy -hls_list_size 65535 -hls_time 2 "./video/live.m3u8"

But I also need to draw some text on the video before recording. So I re-write the above command like

openRTSP -D 10 -v -t -c -b 800000 rtsp://video_link.mov | ./ffmpeg -r 15 -i - -vf drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf: text='Some Text': fontcolor=white: fontsize=24: box=1: boxcolor=black: x=(w-text_w)/2: y=(h-text_h-line_h)/2" -codec copy -hls_list_size 65535 -hls_time 2 "./video/live.m3u8"

But giving the error like,

input #0, h264, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p, 704x480, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Filtergraph 'drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf: text='Stack Overflow': fontcolor=white: fontsize=24: box=1: boxcolor=black: x=(w-text_w)/2: y=(h-text_h-line_h)/2' was defined for video output stream 0:0 but codec copy was selected.
Filtering and streamcopy cannot be used together.

I understand that both recording and drawing cannot perform together. Any method exist similar, to solve the above problem?.

Haris

Posted 2016-03-09T05:21:58.187

Reputation: 117

2Filtering requires re-encoding, so you can't stream copy and filter the same stream. – llogan – 2016-03-09T07:36:09.253

Thanks for the response, so is there any method exist to receive stream->draw some text->write to video file. Or do I need to reopen the recorded file and then draw text as explained here http://stackoverflow.com/questions/17623676/text-on-video-ffmpeg

– Haris – 2016-03-09T07:54:04.570

Answers

1

Filtering requires re-encoding, so you can't stream copy and filter the same stream.

Remove -codec copy or avoid filtering. You can still stream copy the audio with -c:a copy since it is not being filtered:

llogan

Posted 2016-03-09T05:21:58.187

Reputation: 31 929