Giter Site home page Giter Site logo

Comments (8)

aminyazdanpanah avatar aminyazdanpanah commented on July 22, 2024

Ok I will try to find a solution for this feature request.

from python-ffmpeg-video-streaming.

hiteshgarg14 avatar hiteshgarg14 commented on July 22, 2024

Thank you so much @aminyazdanpanah

from python-ffmpeg-video-streaming.

aminyazdanpanah avatar aminyazdanpanah commented on July 22, 2024

@hiteshgarg14 you're welcome

Unfortunately, I do not have access to an AWS account. Please test the following code and if you get any error, post it here.

import sys

import ffmpeg_streaming
from ffmpeg_streaming import S3, CloudManager, Formats


def monitor(ffmpeg, duration, time_):
    per = round(time_ / duration * 100)
    sys.stdout.write("\rTranscoding...(%s%%) [%s%s]" % (per, '#' * per, '-' * (100 - per)))
    sys.stdout.flush()


s3 = S3(aws_access_key_id='YOUR_KEY_ID', aws_secret_access_key='YOUR_KEY_SECRET', region_name='YOUR_REGION')
video = ffmpeg_streaming.input(s3, bucket_name="bucket-name", key="folder1/folder2/../video.mp4")
# you can also open a file from a local path
# video = ffmpeg_streaming.input("/var/media/video.mp4")

hls = video.hls(Formats.h264())
hls.auto_generate_representations()

save_to_s3 = CloudManager(filename="hls_stream.m3u8").add(s3, bucket_name="bucket-name", folder="folder1/folder2/...")
hls.output(clouds=save_to_s3, monitor=monitor)
#  you can also pass a local path to save a copy of files to your server

from python-ffmpeg-video-streaming.

aminyazdanpanah avatar aminyazdanpanah commented on July 22, 2024

I just have released a new version of the package and now you can update the package.

pip install --upgrade python-ffmpeg-video-streaming

For now, you can only set this value for an AWS cloud.

from python-ffmpeg-video-streaming.

hiteshgarg14 avatar hiteshgarg14 commented on July 22, 2024

Hi @aminyazdanpanah, I uninstalled the previous version and installed python-ffmpeg-video-streaming-0.1.3 and tried running below code

import sys

import ffmpeg_streaming
from ffmpeg_streaming import S3, CloudManager, Formats


def monitor(ffmpeg, duration, time_):
    per = round(time_ / duration * 100)
    sys.stdout.write("\rTranscoding...(%s%%) [%s%s]" % (per, '#' * per, '-' * (100 - per)))
    sys.stdout.flush()


s3 = S3(aws_access_key_id='XXXXX',
        aws_secret_access_key='XXXXX', region_name='ap-south-1')
video = ffmpeg_streaming.input(s3, bucket_name="staging", key="videos/etvideo.mp4")
# you can also open a file from a local path
# video = ffmpeg_streaming.input("/var/media/video.mp4")

hls = video.hls(Formats.h264())
hls.auto_generate_representations()

save_to_s3 = CloudManager(filename="hls_stream.m3u8").add(s3, bucket_name="staging", folder="videos/converted/")
hls.output(clouds=save_to_s3, monitor=monitor)

And it is giving below error

FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/v5/9155pbg92g5bpkhtylq7zyd40000gn/T/tmpt7w7bxso_videos/etvideo.mp4_py_ff_vi_st.tmp'

Probably, the problem is a slash at videos/etvideo

from python-ffmpeg-video-streaming.

aminyazdanpanah avatar aminyazdanpanah commented on July 22, 2024

Could you post the line number of the error code and in which file did you get this error(e.x. File ".../clouds.py", line 6)?

from python-ffmpeg-video-streaming.

hiteshgarg14 avatar hiteshgarg14 commented on July 22, 2024

Hi @aminyazdanpanah, Please find below full traceback:

Traceback (most recent call last):
  File "video_streaming.py", line 73, in <module>
    video = ffmpeg_streaming.input(s3, bucket_name="staging", key="videos/etvideo.mp4")
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/site-packages/ffmpeg_streaming/_input.py", line 116, in input
    return Media(InputOption(_input, **options))
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/site-packages/ffmpeg_streaming/_media.py", line 185, in __init__
    options = dict(input_opts)
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/site-packages/ffmpeg_streaming/_input.py", line 86, in __iter__
    yield from self._create().items()
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/site-packages/ffmpeg_streaming/_input.py", line 93, in _create
    options.update(get_from_cloud(self.input_, self.options))
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/site-packages/ffmpeg_streaming/_input.py", line 69, in get_from_cloud
    'i': cloud.download(save_to, **options),
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/site-packages/ffmpeg_streaming/_clouds.py", line 74, in download
    filename = tempfile.NamedTemporaryFile(suffix='_' + key + '_py_ff_vi_st.tmp', delete=False)
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/tempfile.py", line 541, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/Users/hiteshgarg14/Workspace/venv/lib/python3.8/tempfile.py", line 250, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/v5/9155pbg92g5bpkhtylq7zyd40000gn/T/tmptpdnlbtj_videos/etvideo.mp4_py_ff_vi_st.tmp'

from python-ffmpeg-video-streaming.

aminyazdanpanah avatar aminyazdanpanah commented on July 22, 2024

I fixed this problem in 6ab7aeb.

Please update the package and try it again.

from python-ffmpeg-video-streaming.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.