VIM4 HDMI input as camera?

OK. Thank you. I’m now downloading. Best Regards

Hello goenjoy,
All worked fine :smiling_face_with_three_hearts: :+1: I installed the related image for hdmi in as camera. Thank you for your efforts :pray: :slightly_smiling_face:
Can you add a feature to rotate and flip the hdmi in signal so that we can adjust the video orientation in the app. I use the display in portrait mode. The streaming apps open in the correct direction but some apps show the video in upside down direction (Though, the apps open in the correct orientaion).
If you need, I can upload some screenshots here.
Best Regards
Ziya

@zet34 Send it for a look.


Here is how it works on instagram
The display is Vertical(Portrait)
My friend took a screenshot from his phone and he confirms the same playback.
Best Regards
Ziya










The video scene is created in OBS studio (on Windows 10) and I do full projection of the scene to AML TV. Scene canvas is 1080x1920 pixels. In the display settings of Windows, AML is set to portrait (portrait flipped option is also available but I use deault portrait)
On VIM4, I use rotation app from google play to rotate the screen. The rotation settings of VIM4 on Khadas settings are default values. Rotation 0 degrees.
Now I have only one VIM4 board but I will buy 1 or 2 more and on each VIM4, a different streaming app will be working for parallel multiple streaming. I will split the hdmi out of the scene PC (the output of the graphics card of the PC) by using an HDMI splitter, so my source video must always be same and shouldn’t be flipped from windows settings. Depending on the app running on each VIM4 the video signal may be flipped or not.
Using the same settings in the screenshots, Tiktok opens the video in correct direction but Tiklive opens the video in opposite direction. I think this is due how each app handle the video orientation.

There are also 2 minor issues today I found.

  1. For example, on Tiktok, before going live, my camera opens in correct direction but when I press go live button, the camera video turns upside down. On other app TikLive, they are both in correct direction.
  2. I tested the video as a guest in a multi guest live room on TikLive (i.e 4,6,9,12 seats). My live video preview on VIM4 is distorted as shown in the screenshot, but I also entered the room as a watcher from my iphone and my video was good.

Best Regards
Ziya

@zet34 HDMI-in as camera image is mirrored sometimes

Hi @zet34 I’m looking at using the VIM4 for the same purpose, for TikTok streaming.

Can I ask, what was your solution for getting audio input into the VIM4?

Is the VIM4 working correctly for you on TikTok?

1 Like

Can you reshare the firmware? The download no longer works, thank you.

1 Like

@Ben_Knight update.img - Google Drive

1 Like

@Ben_Knight Are there any further issues with your verification?

1 Like

@goenjoy thank you for the firmware image. I’ll purchase a VIM4 now and try it out. Thank you.

1 Like

Hello I am writing from Turkey.

1 - ) Has anyone tested whether the sound transferred from HDMI in Instagram or Tiktok application is Stereo or Mono?

2 -) Does it also recognize USB sound cards?

3- ) If it recognizes USB sound cards as in and out, is there a synchronization problem between the image and sound transferred via Hdmi?

4- ) Mr. Ziya mentioned in his experience that there is a camera rotation problem between applications. Was this problem solved? Is the camera fixed for all apps now?

5- ) Does Vim4 encode 2 channels of 16bit 48000khz when sending audio to applications? Does it support external high audio qualities? For example 2 channels 24-32bit 48000khz?

Thank you very much for your reply in advance.

Best Regards

Efe Özgür Yıldırım

1 Like

Hi Ben, sorry for late reply. I was busy with alot of stuff. Tiktok works without problems.
You can use a DSLR camera having a clean HDMI output for the video HDMI in of VIM4. Also usb webcams work fine without issues. For the audio, I use a usb analog mixer.
The biggest issue on tiktok is, you are not visible in tiktok explore. Very few even almost nobody visits your stream. I think this is related to the device brand and model number. Maybe tiktok is filtering out the devices except mobile phones and tablets. We are discussing this issue with my friend.

We guess somehow the device should make a trick and introduce itself like a mobile phone. Maybe there exists and app for this but I haven’t made any search for that.
Best Regards
Ziya

1 Like

Hello Efe.
We contacted each other by phone.
Stay in touch regarding the topic.
Best Regards
Ziya

1 Like

I absolutely agree. TikTok does not provide discovery support for devices it does not define as mobile, including its own software, TikTok Live Studio (Windows 10+). Only people who follow you can see your broadcasts. There must be different ways around this.

1-) Android rum version must be mobile phone version.
2-) The device ID for TikTok-style applications should be brands and models recognized by the applications (For example, Samsung S23 should be shown instead of Khadas Vim4)
3-) Probably the device should have an IMEI number
4-) A GSM module should be added or made to appear to exist

I am not a software developer. I have been doing research on mobile broadcasting for a long time. I examine all the devices in this field. I measure the reactions of platforms against devices. Yololiv Instream, for example, is a broadcasting device built on a SMARTISAN DE106 phone motherboard with a QUALCOM SNAPDRAGON 845 processor. It has no discover problem. The app recognizes and detects it as a phone. I think this can also be done on existing KHADAS products. We need developers’ ideas and help in this regard.

KHADAS can be a very good and ambitious broadcasting device. Why not? :slight_smile:

1 Like

Hi All,
Is there a plan to support audio from the HDMI stream when using the HDMI stream as a camera?
Thanks

Hi @goenjoy, Could you let us know if Khadas will implement audio over HDMI. It’s crucial IMO for full HDMI IN functionality with the video recording function of the camera and camera API. Thanks

@mph070770 The previous information received was that sound recording is not supported. I will consult with amlogic again. What is the specific reason? See if it’s possible to add recording of sound.

Thanks @goenjoy I think there’s 2 usecases - recording video (video+audio) locally on the VIM4 (i.e. camera footage) and also streaming the camera footage to a remote client from the VIM4. I’d be using the camera API in preference to the camera app but, I assume the app uses the API.

@mph070770 What can currently be achieved is that the videos recorded by Camera have sound. There will be no sound during preview because there is no sound during camera preview.

frameworks/av$ git diff
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
old mode 100755
new mode 100644
index 7aa681cad8..515fdc4dbf
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -34,6 +34,7 @@
 #include <media/AudioContainers.h>
 #include <utils/String8.h>
 #include <utils/Log.h>
+#include <cutils/properties.h>
 
 namespace android
 {
@@ -540,13 +541,18 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource)
                     AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, String8(""), AUDIO_FORMAT_DEFAULT);
             if (device != nullptr) break;
         }
-        device = availableDevices.getFirstExistingDevice({
+               if (property_get_int32("vendor.media.hdmi.camera", 0) == 1) {
+             ALOGI("%s: hdmi camera is recording", __func__);
+             device = availableDevices.getFirstExistingDevice({AUDIO_DEVICE_IN_HDMI});
+        } else {
+             device = availableDevices.getFirstExistingDevice({
                 AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET,
                 /*[Amlogic start]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
                 /* Change-Id: If40b3570059ef2df207e9116889fe9f1d8ce39ab */
                 AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BLUETOOTH_BLE,
                 AUDIO_DEVICE_IN_BUILTIN_MIC});
                 /*[Amlogic end]----------------------------------------------------------*/
+               }
         break;
 
     case AUDIO_SOURCE_VOICE_COMMUNICATION:
@@ -620,9 +626,14 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource)
         break;
     case AUDIO_SOURCE_CAMCORDER:
         // For a device without built-in mic, adding usb device
-        device = availableDevices.getFirstExistingDevice({
+               if (property_get_int32("vendor.media.hdmi.camera", 0) == 1) {
+             ALOGI("%s: hdmi camera is recording", __func__);
+             device = availableDevices.getFirstExistingDevice({AUDIO_DEVICE_IN_HDMI});
+        } else {
+             device = availableDevices.getFirstExistingDevice({
                 AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BACK_MIC,
                 AUDIO_DEVICE_IN_BUILTIN_MIC});
+               }

hardware/amlogic$ git diff
diff --git a/camera/v3/fake-pipeline2/HDMISensor.cpp b/camera/v3/fake-pipeline2/HDMISensor.cpp
index 0d452105..ca379577 100644
--- a/camera/v3/fake-pipeline2/HDMISensor.cpp
+++ b/camera/v3/fake-pipeline2/HDMISensor.cpp
@@ -113,12 +113,15 @@ int HDMISensor::streamOn(channel ch) {
             return -1;
     } else {
         ALOGE("HDMI success streamOn");
+       property_set("vendor.media.hdmi.camera", "1");
         successStreamOn = true;
         return 0;
     }
 }
 
 int HDMISensor::streamOff(channel ch) {
+    ALOGE("HDMISensor::streamOff");
+    property_set("vendor.media.hdmi.camera", "0");
     return mMPlaneCameraIO->stopCameraIO();
 }
 
hardware/amlogic/audio$ git diff 
diff --git a/audio_hal/audio_hw.c b/audio_hal/audio_hw.c
index d194086..14ea70d 100644
--- a/audio_hal/audio_hw.c
+++ b/audio_hal/audio_hw.c
@@ -2902,7 +2902,10 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte
 
     if (ret >= 0) {
         in->frames_read += in_frames;
-        in->timestamp_nsec = pcm_get_timestamp(in->pcm, in->config.rate, 0 /*isOutput*/);
+       if (property_get_int32("vendor.media.hdmi.camera", 0) && in->device & AUDIO_DEVICE_IN_HDMI) {
+           in->timestamp_nsec = aml_audio_get_systime_ns();
+       } else
+            in->timestamp_nsec = pcm_get_timestamp(in->pcm, in->config.rate, 0 /*isOutput*/);
     }
     bool mic_muted = false;
     adev_get_mic_mute((struct audio_hw_device*)adev, &mic_muted);
@@ -9106,9 +9109,10 @@ static int adev_create_audio_patch(struct audio_hw_device *dev,
             }
             aml_dev->active_inport = inport;
             aml_dev->src_gain[inport] = 1.0;
-            if (inport == INPORT_HDMIIN || inport == INPORT_ARCIN || inport == INPORT_SPDIF
-                || inport == INPORT_LINEIN || ((inport == INPORT_TUNER) && (aml_dev->patch_src == SRC_ATV))) {
-                 aml_dev->dev2mix_patch = true;
+            if ((inport == INPORT_HDMIIN || inport == INPORT_ARCIN || inport == INPORT_SPDIF
+                || inport == INPORT_LINEIN || ((inport == INPORT_TUNER) && (aml_dev->patch_src == SRC_ATV)))
+                && (!property_get_int32("vendor.media.hdmi.camera", 0))) {
+                    aml_dev->dev2mix_patch = true;
 #if 0
                 aml_dev2mix_parser_create(dev, src_config->ext.device.type);