You are not logged in.

1

Sunday, July 10th 2016, 3:42pm

mp4 to webm converter?

With the format of webm that's needed for 360video, please post any good program that converts from mp4 to webm and your assessment of the output quality if possible.

2

Monday, July 11th 2016, 6:05pm

ffmpeg of course! ;-)

3

Monday, July 11th 2016, 10:24pm

PanoVideo Converter (free) It's based on ffmpeg. But no scripting. Simply make settings. It's produce .mp4 .webm .ogv from any source file in any combination.
Or better - PanoVideo Creator. based on converter. It's also make posters, tour.xml, preview navigation and so on.

4

Tuesday, July 12th 2016, 5:55pm

Hi Klaus,

ffmpeg is great for the job but I'm getting lost in the commandline settings!

In the Pano Video Converter, on clicking convert, a command line window opens but closes immediately and nothing happens. I tried with all the possible settings.

Could kindly share the line to use to convert an mp4 1920x960 to 2 webm files one same size and second 1024x512 as you use in the panovideo examples?

This post has been edited 1 times, last edit by "Islander" (Jul 13th 2016, 7:02am)


5

Wednesday, July 13th 2016, 7:02am

Hi Islander!
ffmpeg script generally will look like this:
ffmpeg: input.mp4 output.webm
But it is only the start of troubles. Because:
1. you need to work with command line
2. you need to write input and output path
3. you need to prepare separatly each webm and mp4 files in different qualities
4. additionally you need in posters - 2 qualities
5.Perhaps you want to prepare audio for iphone
6. No batch files. You need to prepare all sets of files for each video. It means repeat operations for each file
Panovideo converter is free program and it takes care to do all this operations and provides you with wysiwyg interface.

Tuur

Sage

Posts: 3,193

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

6

Wednesday, July 13th 2016, 9:38am

Are you really gonna advertise in every post about that panovideo converter?
This is a forum not folder!
Please!!

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

7

Wednesday, July 13th 2016, 2:34pm

I'm try to help. And I'm didn't write anything that exceed the theme.
Thank. *g*

8

Wednesday, July 13th 2016, 2:56pm

In the Pano Video Converter, on clicking convert, a command line window opens but closes immediately and nothing happens. I tried with all the possible settings.
Hi Islander!
as you have edited your post I can write you additional information This information from TourCreator may be useful for you, as well as for others.



Don't try to convert video from krpano examples version 1.19.4 and higher. This file is protect from convertation.

Of course we can remove protect information. But among other it will
mean that anyone can download any video from net and create his own
panovideo tour. We think that it is not the good approach.

So, try convert your own video or find on your computer archive file from version 1.18.5 or earlier and try it.

This video (part 2) demonstrate how you can convert video files with PanoVideo Converter.

https://www.youtube.com/watch?v=u3myANAcKkg

9

Friday, July 15th 2016, 5:21pm

Hi Denis,
I appreciate your help.
I've freezed a video capture of the error appearing in the blink of a eye.

As you notice the error reads: no such file or directory. I think it has nothing to do with the file being locked. It's not the sample video; it's an equirectangular video that I could even upload as vr360 to youtube.

I would really like to use the PanoVideo Converter for its simplicity. Anyone experiencing this is welcome for comments.

10

Sunday, July 17th 2016, 1:30am

VLC for anyone on a Mac will work. In VLC go to File>Convert/Stream

11

Monday, July 18th 2016, 11:38am

I've freezed a video capture of the error appearing in the blink of a eye.

Hi Islander!
Great job. Not easy to get this picture.
You are the first who report about troubles in converting formats with ffmpeg.
There are few variants for this. Either file protected or it is corrupted.
Please, give me your file. I can see what wrong with it.
Best regards.

13

Tuesday, July 19th 2016, 3:50pm

Hi Islander!
Thank you for help. There are was two problems:
1. incorrect file name (white space between words)
2. problem with audio converting (there are empty audio channel in your file with strange format)
Now this bugs are fixed.
You can download the new version of program from our site. http://www.tcreator.classic-ru.org/programs/videoconverter/



If somebody else have problems with file conversion, please, feel free to write us. We can help. It's better to do in the thread with PanoVideo Converter [url]http://www.krpano.com/forum/wbb/index.php?page=Thread&postID=66729#post66729[/url]

14

Wednesday, November 13th 2019, 12:15pm

As for me, Joyoshare Video Converter is dencent. It is esay to use. I prefer some programs that are not very complicated since I am a beginner. *g*

Posts: 99

Location: Fairfax, CA

Occupation: Code-Slave

  • Send private message

15

Wednesday, November 13th 2019, 6:56pm

This might be a bit over-kill but here is the code we use to convert our mp4's into several versions for deployment. Not exactly what you want but it might have something useful in it. This is Python used in a Lambda deployment system, pulling media fam an S3 bucket.



Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import osimport stat
import shutil
import sys
import boto3
import logging

logger = logging.getLogger()
logger.setLevel(logging.INFO)

# clean out /tmp
folder = '/tmp'
for the_file in os.listdir(folder):
    file_path = os.path.join(folder, the_file)
    try:
        if os.path.isfile(file_path):
            os.unlink(file_path)
        elif os.path.isdir(file_path): shutil.rmtree(file_path)
    except Exception as e:
        logger.info("cleanup /tmp exception: " + e)
        print(e)

lambda_tmp_dir = '/tmp'  # Lambda fuction can use this directory.

# ffmpeg loading
ffmpeg = "{0}/ffmpeg".format(lambda_tmp_dir)
shutil.copyfile('/var/task/ffmpeg', ffmpeg)
os.environ['ffmpeg'] = ffmpeg
os.chmod(ffmpeg, os.stat(ffmpeg).st_mode | stat.S_IRWXU)
os.chmod("/tmp", stat.S_IRWXU)

s3 = boto3.client('s3')

# Make sure the target directory exists
def prepare_path(target):
    if os.path.exists(target):
        logger.info("{0} exists".format(target))
        shutil.rmtree(target)

    os.mkdir(target)


# Copy/download the file to local
# standard way of doing things
"""
def copy_object(bucket, source, dest):
    name = source.split('/')[-1]
    local_file = "{0}/{1}".format(dest, name)
    logger.debug("{0} to {1}".format(source, local_file))
    s3.download_file(bucket, source, local_file)
    if os.path.exists(local_file):
        b = open(local_file, "r")
    return local_file
"""

# The following function can be used to upload directory to s3 via boto.
def upload_files(path, bucket, mediaId, fileType):
    logger.info("upload_files() path-> " + path + " | bucket-> " + bucket + " | mediaId-> " + mediaId + " | fileType-> " + fileType)
    for subdir, dirs, files in os.walk(path):
        for file in files:
            full_path = os.path.join(subdir, file)
            with open(full_path, 'rb') as data:
                thisKey = 'media/' + fileType + '/' + mediaId + '/' + full_path[len(path) + 1:]
                logger.info("upload_files() thisKey-> " + thisKey)
                s3.put_object(Bucket=bucket, Key=thisKey, Body=data)


def create_presigned_url(bucket_name, object_name, expiration=3600):
    """Generate a presigned URL to share an S3 object

    :param bucket_name: string
    :param object_name: string
    :param expiration: Time in seconds for the presigned URL to remain valid
    :return: Presigned URL as string. If error, returns None.
    """

    # Generate a presigned URL for the S3 object
    s3_client = boto3.client('s3')
    try:
        response = s3_client.generate_presigned_url('get_object',
                                                    Params={'Bucket': bucket_name,
                                                            'Key': object_name},
                                                    ExpiresIn=expiration)
    except ClientError as e:
        logging.error(e)
        return None

    # The response contains the presigned URL
    return response


def ffmpeg_lambda_handler(event, context):
    # determine the ID
    the_file_path = event['Records'][0]['s3']['object']['key']
    the_bucket = event['Records'][0]['s3']['bucket']['name']




    the_file_path_array = the_file_path.split('/')
    the_file_name = the_file_path_array[-1]
    the_file_name_array = the_file_name.split('.')
    mediaId = str(the_file_name_array[0])
    fileType = the_file_path_array[1]

    # create the local_path
    local_path = "{0}/{1}".format(lambda_tmp_dir, mediaId)
    prepare_path(local_path)





    # copy_object to destination path.
    # localInputFile = copy_object(the_bucket, the_file_path, local_path)
    localInputFile = create_presigned_url(the_bucket, the_file_path, expiration=3600)

    # ++++++++++++++++++++++++++++++++++++++++ FFMPEG ++++++++++++++++++++++++++++++++++++++++++

    audioPath = "{0}/{1}".format(local_path, 'audio_file.mp3')

    if fileType == 'transition':
        # GoPro settings
        brPairs = [[1080, 16000], [1080, 7000], [720, 3000], [540, 1500], [224, 440]]

    else:
        # Spherical Video settings
        brPairs = [[1920, 16000], [720, 3000], [960, 7000], [1440, 16000], [2048, 40000]]


    for p in brPairs:
        # size
        thisKey = str(p[0])

        # get bit-rate
        bitrate = p[1]

        # buffer rate
        bufs = str(bitrate * 0.75)

        # convert num to string
        bitstring = str(bitrate)

        # final file path
        final_file = thisKey + '_' + bitstring + '.mp4'

        localOutputPath = "{0}/{1}".format(local_path, final_file)
        localOutputPath = str(localOutputPath)

        s3Path = 's3://xplorit-media/processor/360video/170968.mp4'
        httpsPath = 'https://s3-us-west-2.amazonaws.com/xplorit-media/processor/360video/170968.mp4'

        buff_temp_name = str('temp_' + mediaId + '_' + thisKey + '_' + bitstring)
        localTempPath = "{0}/{1}".format(local_path, buff_temp_name)
        localTempPath = str(localTempPath)
        myPassLogFile = folder + '/my_passlog_' + mediaId + '_' + thisKey + '_' + bitstring

        # Pass Commands
        # pass_one_command = ffmpeg + ' -y -i ' + localInputFile + ' -c:v libx264 -strict -2 -b:v ' + bitstring + 'k -maxrate ' + bitstring + 'k -bufsize ' + bufs + 'k -vf scale=-2:' + thisKey + ' -an -pass 1 -passlogfile ' + myPassLogFile + ' -f mp4 ' + localTempPath
        # pass_two_command = ffmpeg + ' -y -i ' + localInputFile + ' -c:v libx264 -strict -2 -b:v ' + bitstring + 'k -maxrate ' + bitstring + 'k -bufsize ' + bufs + 'k -vf scale=-2:' + thisKey + ' -c:a aac -b:a 128k -pass 2 -passlogfile ' + myPassLogFile + ' -movflags +faststart -f mp4 ' + localOutputPath

        pass_one_command = ffmpeg + ' -y -i "' + localInputFile + '" -c:v libx264 -strict -2 -b:v ' + bitstring + 'k -maxrate ' + bitstring + 'k -bufsize ' + bufs + 'k -vf scale=-2:' + thisKey + ' -an -pass 1 -passlogfile ' + myPassLogFile + ' -f mp4 /dev/null'
        pass_two_command = ffmpeg + ' -y -i "' + localInputFile + '" -c:v libx264 -strict -2 -b:v ' + bitstring + 'k -maxrate ' + bitstring + 'k -bufsize ' + bufs + 'k -vf scale=-2:' + thisKey + ' -c:a aac -b:a 128k -pass 2 -passlogfile ' + myPassLogFile + ' -movflags +faststart -f mp4 ' + localOutputPath

        # aws s3 cp - s3: // my - amazing - bucket / geoip_v4_data.csv.gz
        # ffmpeg - re - i in.ts - f hls - method PUT http: // example.com / live / out.m3u8

        # Pass one
        logger.info("Pass One " + pass_one_command)
        os.system(pass_one_command)

        # Pass two
        logger.info("Pass two " + pass_two_command)
        os.system(pass_two_command)

        # delete temp
        os.system('rm -f ' + localTempPath)

        # delete log
        os.system('rm -f ' + myPassLogFile)

        # delete mbtree
        os.system('rm -f ' + myPassLogFile + '-0.log.mbtree')

        logger.info("B -> DONE PROCESSING = " + mediaId + '_' + thisKey + '_' + bitstring)

        # upload file localOutputPath
        key_create = 'media/' + fileType + '/' + mediaId + '/' + final_file
        logger.info("UPLOADING localOutputPath = " + localOutputPath + ' the_bucket = ' + the_bucket + ' key_create = ' + key_create)
        s3.upload_file(localOutputPath, the_bucket, key_create)
        # remove file
        os.system('rm -f ' + localOutputPath)


    # encode audio
    audioCommand = ffmpeg + ' -y -i "' + localInputFile + '" -f mp3 -ab 192000 -vn ' + audioPath
    logger.info("Audio extraction " + audioCommand)
    try:
        os.system(audioCommand)
        key_create = 'media/' + fileType + '/' + mediaId + '/audio_file.mp3'
        logger.info("UPLOADING audioPath = " + audioPath + ' the_bucket = ' + the_bucket + ' key_create = ' + key_create)
        s3.upload_file(audioPath, the_bucket, key_create)
        logger.info("Audio extraction SUCCESS " + audioCommand)
    except:
        logger.info("Audio extraction ERROR" + audioCommand)
    # upload audio file localOutputPath


    # ++++++++++++++++++++++++++++++++++++++++ KRPANOTOOLS ++++++++++++++++++++++++++++++++++++++++++

    # Upload to s3.
    # upload_files(local_path, the_bucket, mediaId, fileType)
    # key_create = 'media/' + fileType + '/' + mediaId + '/' + mediaId + '.mp4'
    # logger.info("UPLOADING localInputFile = " + localInputFile + ' the_bucket = ' + the_bucket + ' key_create = ' + key_create)
    # s3.upload_file(localInputFile, the_bucket, key_create)

    logger.info("OK WE'RE DONE!!!")

Similar threads