[mythtv-users] Recording from input video on demand, no tuner; update: troubles capturing video using RPI4

John Pilkington johnpilk222 at gmail.com
Thu Mar 2 20:02:10 UTC 2023


On 02/03/2023 16:39, Jay Harbeston wrote:
> 
> 
>> On Mar 2, 2023, at 9:39 AM, Peter Bennett <pb.mythtv at gmail.com> wrote:
>>
>> Looks good, so if you change your format to -f mpegts and the file to 
>> have a ts extension, does that work? If so you may be able to use that 
>> ffmpeg command to create a stream into mythtv using the external recorder.
>>
>> Peter
>>
> 
> So I took the commands to create the mkv and avi files and changed the 
> output to -f mpegts, and while it created a file with what looks like 
> the same bit rate, mythffprobe/ffprobe didn’t like the resulting .ts file.
> 
> I don’t think it matters which command I try to modify to become the ts 
> file since the inputs for audio and video are the same.
> 
> I am pasting information here regarding the creation of the ts file as 
> follows:
> 
> #############################################################################
> 
> Using the mkv version of the command line and changing -f matroska to -f 
> mpegts
> 
> ffmpeg -f pulse -thread_queue_size 1024 -i default  -f v4l2 
> -thread_queue_size 1024 -input_format mjpeg -video_size 1920x1080 
> -framerate 30 -i /dev/video0 -f mpegts -codec copy pipe:1 > ~/file.ts
> 
> 
> 
>   libavutil      56. 51.100 / 56. 51.100
>   libavcodec     58. 91.100 / 58. 91.100
>   libavformat    58. 45.100 / 58. 45.100
>   libavdevice    58. 10.100 / 58. 10.100
>   libavfilter     7. 85.100 /  7. 85.100
>   libavresample   4.  0.  0 /  4.  0.  0
>   libswscale      5.  7.100 /  5.  7.100
>   libswresample   3.  7.100 /  3.  7.100
>   libpostproc    55.  7.100 / 55.  7.100
> Guessed Channel Layout for Input Stream #0.0 : stereo
> Input #0, pulse, from 'default':
>   Duration: N/A, start: 1677770329.137014, bitrate: 1536 kb/s
>     Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> Input #1, video4linux2,v4l2, from '/dev/video0':
>   Duration: N/A, start: 1187563.678101, bitrate: N/A
>     Stream #1:0: Video: mjpeg (Baseline), yuvj422p(pc, 
> bt470bg/unknown/unknown), 1920x1080, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
> Output #0, mpegts, to 'pipe:1':
>   Metadata:
>     encoder         : Lavf58.45.100
>     Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, 
> bt470bg/unknown/unknown), 1920x1080, q=2-31, 30 fps, 30 tbr, 90k tbn, 
> 1000k tbc
>     Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> Stream mapping:
>   Stream #1:0 -> #0:0 (copy)
>   Stream #0:0 -> #0:1 (copy)
> Press [q] to stop, [?] for help
> [mpegts @ 0x7af170] Stream 0, codec mjpeg, is muxed as a private data 
> stream and may not be recognized upon reading.
> [mpegts @ 0x7af170] Stream 1, codec pcm_s16le, is muxed as a private 
> data stream and may not be recognized upon reading.
> frame=   16 fps=0.0 q=-1.0 size=    4030kB time=00:00:00.52 
> bitrate=62506.7kbits
> frame=   31 fps= 31 q=-1.0 size=    6697kB time=00:00:01.02 
> bitrate=53353.8kbits
> 
> and the bit  rate reflects that there is  video/audio being captured, 
> but ffprobe doesn’t like it.
> 
> ######################################################################################
> 
> ffmpeg -f v4l2 -thread_queue_size 1024 -input_format mjpeg -video_size 
> 1920x1080 -framerate 30 -i /dev/video0 -f pulse -thread_queue_size 1024 
> -i default -f mpegts -codec copy vid_1080p_30.ts
> 
> 

>   libpostproc    55.  7.100 / 55.  7.100
> [mjpeg @ 0x2194eb0] EOI missing, emulating
> Input #0, video4linux2,v4l2, from '/dev/video0':
>   Duration: N/A, start: 1191788.917809, bitrate: N/A
>     Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, 
> bt470bg/unknown/unknown), 1920x1080, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
> Guessed Channel Layout for Input Stream #1.0 : stereo
> Input #1, pulse, from 'default':
>   Duration: N/A, start: 1677774554.726233, bitrate: 1536 kb/s
>     Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> File 'vid_1080p_30.ts' already exists. Overwrite? [y/N] y
> Output #0, mpegts, to 'vid_1080p_30.ts':
>   Metadata:
>     encoder         : Lavf58.45.100
>     Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, 
> bt470bg/unknown/unknown), 1920x1080, q=2-31, 30 fps, 30 tbr, 90k tbn, 
> 1000k tbc
>     Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
>   Stream #1:0 -> #0:1 (copy)
> Press [q] to stop, [?] for help
> [mpegts @ 0x219e880] Stream 0, codec mjpeg, is muxed as a private data 
> stream and may not be recognized upon reading.
> [mpegts @ 0x219e880] Stream 1, codec pcm_s16le, is muxed as a private 
> data stream and may not be recognized upon reading.
> [mpegts @ 0x219e880] Non-monotonous DTS in output stream 0:1; previous: 
> 13490, current: 13485; changing to 13491. This may result in incorrect 
> timestamps in the output file.
> [mpegts @ 0x219e880] Non-monotonous DTS in output stream 0:1; previous: 
> 16219, current: 16201; changing to 16220. This may result in incorrect 
> timestamps in the output file.
> [mpegts @ 0x219e880] Non-monotonous DTS in output stream 0:1; previous: 
> 34791, current: 34788; changing to 34792. This may result in incorrect 
> timestamps in the output file.
> [mpegts @ 0x219e880] Non-monotonous DTS in output stream 0:1; previous: 
> 110242, current: 110233; changing to 110243. This may result in 
> incorrect timestamps in the output file.
> frame=   45 fps=0.0 q=-1.0 size=    6400kB time=00:00:03.16 
> bitrate=16568.0kbits
> frame=   60 fps= 59 q=-1.0 size=   10752kB time=00:00:03.66 
> bitrate=24035.9kbits
> frame=   75 fps= 49 q=-1.0 size=   15104kB time=00:00:04.16 
> bitrate=29710.3kbits
> 
> 
> 
> 
> I’m guessing that I’m gonna have to give up on trying to capture 
> directly into mythtv?  I can create a test file as either the mkv or 
> avi, or the ‘broken’ ts file If needed.
> 
> 
> Thanks in advance, and Regards!
> 

I've seen the 'non-monotonous' complaint before (and think it ought to 
be non-monotonic).  For file-to-file stuff I use

ionice -c3 mythffmpeg -hide_banner -ignore_unknown -fflags +genpts \
  -i infile.ts -vcodec copy -acodec copy -avoid_negative_ts make_zero \
-f mpegts  outfile.ts

where the '-fflags +genpts' before the -i seems important.  I think the 
'avoid_negative make_zero' bits affect concatenation, and IDK whether 
they would help here.

John P




More information about the mythtv-users mailing list