Ubuntu 16.04 Linux Web GUI Hardware Encoding Error

Hello,

I am attempting to transition the Channels DVR server from my Mac to my Linux server. This is a sever running Ubuntu 16.04. I am getting an error when I use hardware encoding for Web GUI playback of recordings.

Here’s the log info:

2017/02/05 14:27:52 [HLS] Starting transcoder for channel 4.1 (encoder=h264_vaapi, resolution=720, deinterlacer=blend, bitrate=10000)
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: va_openDriver() returns 0
pipe:: could not seek to position 77959.515
[ac3 @ 0x2824500] frame sync error
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 0x23ce740] Queue input is backward in time
[hls @ 0x23141e0] Non-monotonous DTS in output stream 0:1; previous: 95520, current: 94560; changing to 95521. This may result in incorrect timestamps in the output file.
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
[mpegts @ 0x2865d00] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
2017/02/05 14:28:20 [HLS] Stopping transcoder session 10458BB8-ch4.1 @ 0s
2017/02/05 14:28:38 [HLS] Starting transcoder for channel 4.1 (encoder=libx264, resolution=480, deinterlacer=blend, bitrate=2000)
pipe:: could not seek to position 78006.299
[ac3 @ 0x27c0d60] frame sync error
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 0x2864980] Queue input is backward in time
[hls @ 0x2c377a0] Non-monotonous DTS in output stream 0:1; previous: 81120, current: 80160; changing to 81121. This may result in incorrect timestamps in the output file.
2017/02/05 14:30:05 [HLS] Stopping transcoder session 10458BB8-ch4.1 @ 1m10.120055s

Here’s my procinfo:

cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel® Celeron® CPU G530 @ 2.40GHz
stepping : 7
microcode : 0x26
cpu MHz : 2400.000
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave lahf_lm epb tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts
bugs :
bogomips : 4800.38
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

Thanks for looking into this.

Forgot to mention the version that I am using: 2017.02.03.0335

What hdhomerun?

It’s an HDHomeRun Connect. Connected to only OTA channels.

Strange, I’m not sure why no one else has encountered this. Can you copy/paste the OS/CPU section from the Settings tab?

What about if you use the software encoder, does that one work?

Here’s the info you requested:

OS
Linux Ubuntu
16.04 (kernel: 4.4.0-59-generic)
CPU
2 cores / Intel® Celeron® CPU G530 @ 2.40GHz
load averages: 0.53 0.41 0.40
RAM
8.05 GB
73.7% free

The encoding works without any difficulty using the software encoder.

Thanks for your help with this, Aman. I’ve been using Channels since it was first released on the App Store. Love the work you all are doing.

1 Like

Interesting, according to https://ark.intel.com/m/products/53414/Intel-Celeron-Processor-G530-2M-Cache-2_40-GHz#@product/specifications the G530 does not offer Quick Sync

I’m surprised the driver is loading at all… seems like it might be partially supported.

Can you ssh in and run:

./channels-dvr/latest/ffmpeg -hide_banner -t 10 -f lavfi -i color=black:1280x720 -vaapi_device /dev/dri/renderD128 -c:v h264_vaapi -vf format=nv12,hwupload -b:v 4000k -f hls -hls_time 2 -y /tmp/test.m3u8

and post the output.

I didn’t realize that Quick Sync isn’t supported with that chip. That’s likely the problem.

Here’s the output:

$ ./latest/ffmpeg -hide_banner -t 10 -f lavfi -i color=black:1280x720 -vaapi_device /dev/dri/renderD128 -c:v h264_vaapi -vf format=nv12,hwupload -b:v 4000k -f hls -hls_time 2 -y /tmp/test.m3u8
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: va_openDriver() returns 0
Input #0, lavfi, from ‘color=black:1280x720’:
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Output #0, hls, to ‘/tmp/test.m3u8’:
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_vaapi) (High), vaapi_vld, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 4000 kb/s, 25 fps, 90k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.100 h264_vaapi
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
[mpegts @ 0x35ecc80] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
frame= 3 fps=0.0 q=-0.0 Lsize=N/A time=-00:00:00.03 bitrate=N/A speed=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Conversion failed!

Okay, as expected. Now can you try again but add “-bsf:v h264_mp4toannexb” before -f

./channels-dvr/latest/ffmpeg -hide_banner -t 10 -f lavfi -i color=black:1280x720 -vaapi_device /dev/dri/renderD128 -c:v h264_vaapi -vf format=nv12,hwupload -b:v 4000k -bsf:v h264_mp4toannexb -f hls -hls_time 2 -y /tmp/test.m3u8

Same error:

$ ./latest/ffmpeg -hide_banner -t 10 -f lavfi -i color=black:1280x720 -vaapi_device /dev/dri/renderD128 -c:v h264_vaapi -vf format=nv12,hwupload -b:v 4000k -bsf:v h264_mp4toannexb -f hls -hls_time 2 -y /tmp/test.m3u8
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: va_openDriver() returns 0
Input #0, lavfi, from ‘color=black:1280x720’:
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Output #0, hls, to ‘/tmp/test.m3u8’:
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_vaapi) (High), vaapi_vld, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 4000 kb/s, 25 fps, 90k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.100 h264_vaapi
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
[mpegts @ 0x33f70c0] H.264 bitstream malformed, no startcode found, use the video bitstream filter ‘h264_mp4toannexb’ to fix it (’-bsf:v h264_mp4toannexb’ option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
frame= 3 fps=0.0 q=-0.0 Lsize=N/A time=-00:00:00.03 bitrate=N/A speed=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Conversion failed!

Okay, basically its outputting nothing because quicksync is missing.

Time to upgrade my server… :slight_smile:

Thanks for looking into it.

1 Like

Wanted to update the topic. I ended up upgrading from my sandy bridge processor to a kaby lake i3. Hardware encoding is working perfectly on Ubuntu 16.04.2 with this new setup.

Thanks for writing such a great app and service.

1 Like