Closed dani3l0 closed 3 months ago
working as expected from my side
can you send the mediainfo output of the file you are trying to send.?
Here it is:
General
ID : 1 (0x1)
Complete name : KATOWICE Pt. 2.08.2024r. W. Olszański, M. Osadowski NPTV.pl Rodacy Kamraci [6VNRAcrSR].mp4
Format : MPEG-TS
File size : 871 MiB
Duration : 2 h 49 min
Overall bit rate mode : Variable
Overall bit rate : 720 kb/s
FileExtension_Invalid : ts m2t m2s m4t m4s tmf ts tp trp ty
Video
ID : 257 (0x101)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Format settings, GOP : M=1, N=60
Codec ID : 27
Duration : 2 h 49 min
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Standard : NTSC
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Color range : Limited
Color primaries : BT.601 PAL
Transfer characteristics : BT.601
Matrix coefficients : BT.601
Audio
ID : 256 (0x100)
Menu ID : 1 (0x1)
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Format version : Version 4
Muxing mode : ADTS
Codec ID : 15-2
Duration : 2 h 49 min
Bit rate mode : Variable
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Delay relative to video : 43 ms
And to give more background, it's a video downloaded from https://dlive.tv/ via yt-dlp
Its maybe issue with telegram's video formats?
for one file which uploaded as document i ran this
ffmpeg -hwaccel nvdec -i input.mp4 -vf "scale=w=1280:h=720:force_original_aspect_ratio=decrease" -c:v h264_nvenc -preset p1 -b:v 2000k -maxrate 2000k -bufsize 4000k -c:a aac -b:a 128k -movflags +faststart output.mp4
and got uploaded as video. try and experiement, I think its not issue with lib
please update on this.
Any updates?
Not yet, I've been kinda busy today :<
Will let you know tomorrow
Okay, I guess I've discovered the real issue. My observations were a bit misleading, actually it doesn't matter if a video is big or not. For testing, I've been copying small videos to the same directory I run my project in, that's why they worked.
I think, the pattern is when video file is served from a different directory. Here's an updated code snippet:
package main
import (
"myproject/config"
tg "github.com/amarnathcjd/gogram/telegram"
)
var client *tg.Client
func main() {
client, _ = tg.NewClient(tg.ClientConfig{
AppID: config.TelegramApiId,
AppHash: config.TelegramApiHash,
})
client.ConnectBot(config.TelegramBotToken)
// Serve video from a subdirectory
client.SendMedia(config.ChannelId, "./downloads/output.mp4", &tg.MediaOptions{
Caption: "*bold* _italic_ one two three",
ParseMode: "markdown",
})
}
Uploading video this way will result in this:
Still I'm not 100% sure, coz the problem may be somewhere else. Please take a look :>
@dani3l0 maybe ffmpeg commands hardcoded only works for current directory.?
It has nothing to do with ffmpeg. Video formats are ok
@dani3l0 are the document attributes ok too.?
Must be. Video uploaded from current working dir is playable and everything is ok. Problem happens only when serving the file from different directory.
@dani3l0 thats so strange
Check the snippet.
oh subdriectory or diffrent directory?
Both
can you come @rosexchat .
same for ./blah/bx/video_2024-08-06_21-32-07_339.mp4
Okay, I guess I've discovered the real issue. My observations were a bit misleading, actually it doesn't matter if a video is big or not. For testing, I've been copying small videos to the same directory I run my project in, that's why they worked.
I think, the pattern is when video file is served from a different directory. Here's an updated code snippet:
package main import ( "myproject/config" tg "github.com/amarnathcjd/gogram/telegram" ) var client *tg.Client func main() { client, _ = tg.NewClient(tg.ClientConfig{ AppID: config.TelegramApiId, AppHash: config.TelegramApiHash, }) client.ConnectBot(config.TelegramBotToken) // Serve video from a subdirectory client.SendMedia(config.ChannelId, "./downloads/output.mp4", &tg.MediaOptions{ Caption: "*bold* _italic_ one two three", ParseMode: "markdown", }) }
Uploading video this way will result in this:
Still I'm not 100% sure, coz the problem may be somewhere else. Please take a look :>
I think the output.mp4 might be incomplete? can u share the exact file in some place?
even tried videos from https://dlive.tv/p/loupdi+XCGWSkXIg
Okay, something reeeally weird is happening here: If the output.mp4 file is incomplete, then why is it working when uploaded from working dir? wtf
I'll do further investigation and update on this
Anyways, there's a workaround by creating a symlink in working dir
Ah your OS is Linux based, I did all test on Windows, maybe its Linux specific.
use filepath.Abs()
use
filepath.Abs()
irrelevent ig, file path exists, gets uploaded
I've played tday a bit with my project on a work pc with OpenSUSE Tumbleweed, with the same Go version. Now, even the symlink workaround doesn't work. Must be sth wrong on my side.
ig it's a hwaccel or codec issue, as mentioned earlier (also I have very poorly configured hwaccel on this pc)
If I finally get this to work, I'll update xd
so its not an issue with the lib? :
dunno. I tested other videos as well and some of them were working properly, some of them got sent as documents. Finally, idk where the problem is.
dunno. I tested other videos as well and some of them were working properly, some of them got sent as documents. Finally, idk where the problem is.
did you test with another client for eg-: telethon (python)
nope, I will do it now
Telethon is ok
Wow, ok, your system is Linux right Ill try out.
Wow, ok, your system is Linux right Ill try out.
Why would the OS affect it?
Wow, ok, your system is Linux right Ill try out.
Why would the OS affect it?
If the same code works in win, then why not.
I don't understand how the same video would cause something to change. It must be something else. Could you share a zip file of the project to try to reproduce the issue?
Tried to reproduce with an example code, but weird things keeps happening. On sample, one-file code video gets preview correctly. Must be a mistake somewhere in my project.
Sauce code to my project is here (made it public temporarily). You don't have to put ur own video, just set debug_mode: true
in config.yml file and the whole problematic process will begin.
Oh, make sure u upload video from cache dir, this is when the issue happens.
Found the issue; how about now/
Seems like it's working flawlessly now :tada:
Thanks, good job :+1:
Describe the bug Uploading large videos to a channel does not make them playable, they are treated as documents. To watch, I need to download them locally and then play with native video player.
Smaller (and shorter) videos work as expected, I can directly play them in my tg clients.
To Reproduce Steps to reproduce the behavior:
Just upload some big video somewhere (channel in my case)
Code snippet I am using:
var client *tg.Client
func main() { client, _ = tg.NewClient(tg.ClientConfig{ AppID: config.TelegramApiId, AppHash: config.TelegramApiHash, })
}