Quantcast
Channel: C#nedir?com Forum
Viewing all articles
Browse latest Browse all 613

Visual C# : Video Downloader FFmpeg Sorunu

$
0
0
Author: telase
Subject: Video Downloader FFmpeg Sorunu
Posted: 25 Ocak 2020 at 18:28

Merhaba arkadaşlar,Visual Studio 2019 kullanıyorum.
Şöyle bir sorunum var,bir program üzerinde uğraşıyorum.Program internet üzerinden ffmpeg yardımıyla m3u8 linklerini mp4 olarak bilgisayara download etmemizi sağlıyor.

Programla misal atv,phu tv dizilerinin m3u8 linklerini download yapıp bittiğinde ffmpeg kendini kapatıyor.
ama,canlı yayınları download edildiğinde programda çıkış butonun bassak bile ffmpeg arka planda halen download ediyor.FFmpeg.exe yi taktill den kapattığımızda download edilen videoda sorun olup açmıyor,bende bu yüzden program klasörünün içine İndermeyi Sonlandır.bat oluşturup SendSignal.exe yi çalıştırıp ffmpeg.exe yi kapatıyorum.SendSignal ile kapatılan ffmpeg,videolar normal çalışıyor.

Program ve kod bu linkte.
http://www.mediafire.com/file/mdp404sdcgpakhs/M3U8DownloaderCode.rar/file

Yani yaptığım programda canlı yayınlarda çıkış butonuna bassam bile,program kapanıyor ama ffmpeg halen çalışıyor.
Normal film indirdiğimde download bitince zaten video tamamlanmış ve ffmpeg kendini kapatmış oluyor.
cs nini için
---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace M3U8Downloader
{
    public partial class Form1 : Form
    {
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam);

        private const int SbBottom = 0x7;
        private const int WmVscroll = 0x115;

        public string URLlink { get; private set; }

        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        public void ExecuteCommand(string command)
        {

            //Create process

            System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
            pProcess.StartInfo.FileName = "CMD.exe";
            pProcess.StartInfo.Arguments = command;
            pProcess.StartInfo.CreateNoWindow = true;
            pProcess.StartInfo.UseShellExecute = false;
            pProcess.StartInfo.RedirectStandardOutput = true;

            //pProcess.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
            // Start the asynchronous read
            pProcess.Start();
            pProcess.BeginOutputReadLine();
            pProcess.WaitForExit();
            pProcess.Close();
        }
       
        

        private void txtURL_MouseClick(object sender, MouseEventArgs e)
        {
            txtURL.SelectAll();
        }

        private void txtM3U8_MouseClick(object sender, MouseEventArgs e)
        {
            txtM3U8.SelectAll();
        }

        private void btnDownload_Click(object sender, EventArgs e)
        {
            btnDownload.Text = "İndiriliyor...";
            bgDownload.RunWorkerAsync();
        }

        public void Download()
        {
            string m3u8 = txtM3U8.Text;
            string Title = "Video_"+ DateTime.Now.ToString("dd_MM_yyyy_hhmmss");

            string cmd = "/C ffmpeg -i \"" + m3u8 + "\" -acodec copy -vcodec copy -absf aac_adtstoasc " + Title+".mp4";
            ExecuteCommand(cmd);
        }

        private void bgDownload_DoWork(object sender, DoWorkEventArgs e)
        {
            Download();
        }

        private void bgDownload_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            MessageBox.Show("Bitti");
            btnDownload.Text = "DOWNLOAD";
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void txtURL_TextChanged(object sender, EventArgs e)
        {
            txtURL.ForeColor = Color.Black;
            txtURL.Font = new Font(txtURL.Font, FontStyle.Regular);
        }

        private void txtURL_Leave(object sender, EventArgs e)
        {
            txtURL.ForeColor = SystemColors.GrayText;
            txtURL.Font = new Font(txtURL.Font, FontStyle.Italic);
        }

        private void txtM3U8_TextChanged(object sender, EventArgs e)
        {
            txtM3U8.ForeColor = Color.Black;
            txtM3U8.Font = new Font(txtM3U8.Font, FontStyle.Regular);
        }

        private void txtM3U8_Leave(object sender, EventArgs e)
        {
            txtM3U8.ForeColor = SystemColors.GrayText;
            txtM3U8.Font = new Font(txtM3U8.Font, FontStyle.Italic);
        }
    }
}
---------------------------------------------------------------------------------
Şimdi bana lazım olan,çıkış butununa bastığımda ffmpeg.exe yi kapatacak cod veya çıkış botonuna bastığımda SendSignal.exe yi çalıştıracak cod lazım.
Application.Exit(); veya  Environment.Exit(0); denedim olmadı.
programa katkı yapacak arkadaşlara şimdiden teşekkür ederim.



Viewing all articles
Browse latest Browse all 613

Trending Articles